2022-01-13 23:38:45 -08:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.Messaging;
|
2021-12-30 11:41:59 +00:00
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.EyeOfTheUniverse.ForestOfGalaxies.Messages
|
|
|
|
|
{
|
|
|
|
|
internal class KillGalaxiesMessage : QSBMessage
|
|
|
|
|
{
|
2021-12-30 15:40:06 -08:00
|
|
|
|
private List<float> _deathDelays;
|
2021-12-30 11:41:59 +00:00
|
|
|
|
|
|
|
|
|
public KillGalaxiesMessage(List<float> deathDelays) => _deathDelays = deathDelays;
|
|
|
|
|
|
2022-01-13 23:38:45 -08:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
2021-12-30 11:41:59 +00:00
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
2022-01-21 18:15:35 -08:00
|
|
|
|
writer.WriteList(_deathDelays);
|
2021-12-30 11:41:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 23:38:45 -08:00
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
2021-12-30 11:41:59 +00:00
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
2022-01-21 18:15:35 -08:00
|
|
|
|
_deathDelays = reader.ReadList<float>();
|
2021-12-30 11:41:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 00:27:32 -08:00
|
|
|
|
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
2021-12-30 18:28:24 -08:00
|
|
|
|
|
2021-12-30 11:41:59 +00:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
var galaxyController = QSBWorldSync.GetUnityObjects<MiniGalaxyController>().First();
|
|
|
|
|
|
|
|
|
|
galaxyController._killTrigger.OnEntry -= galaxyController.OnEnterKillTrigger;
|
|
|
|
|
|
2021-12-30 18:28:24 -08:00
|
|
|
|
galaxyController._galaxies = galaxyController.GetComponentsInChildren<MiniGalaxy>(true);
|
2021-12-30 11:41:59 +00:00
|
|
|
|
for (var i = 0; i < galaxyController._galaxies.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
galaxyController._galaxies[i].DieAfterSeconds(_deathDelays[i], true, AudioType.EyeGalaxyBlowAway);
|
|
|
|
|
}
|
2022-01-01 22:19:10 +00:00
|
|
|
|
|
2021-12-30 11:41:59 +00:00
|
|
|
|
galaxyController._forestIsDarkTime = Time.time + 65f;
|
|
|
|
|
galaxyController.enabled = true;
|
|
|
|
|
|
|
|
|
|
galaxyController._musicSource.SetLocalVolume(0f);
|
2021-12-30 18:28:24 -08:00
|
|
|
|
galaxyController._musicSource.FadeIn(5f);
|
2021-12-30 11:41:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|