2022-01-14 07:38:45 +00: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;
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.EyeOfTheUniverse.ForestOfGalaxies.Messages;
|
|
|
|
|
|
2023-07-28 18:30:57 +00:00
|
|
|
|
public class KillGalaxiesMessage : QSBMessage
|
2021-12-30 11:41:59 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
private List<float> _deathDelays;
|
2021-12-30 11:41:59 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public KillGalaxiesMessage(List<float> deathDelays) => _deathDelays = deathDelays;
|
2021-12-30 11:41:59 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
writer.WriteList(_deathDelays);
|
|
|
|
|
}
|
2021-12-31 02:28:24 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
_deathDelays = reader.ReadList<float>();
|
|
|
|
|
}
|
2021-12-30 11:41:59 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
2021-12-30 11:41:59 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
2022-05-03 07:48:24 +00:00
|
|
|
|
var galaxyController = QSBWorldSync.GetUnityObject<MiniGalaxyController>();
|
2022-01-01 22:19:10 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
galaxyController._killTrigger.OnEntry -= galaxyController.OnEnterKillTrigger;
|
2021-12-30 11:41:59 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
galaxyController._galaxies = galaxyController.GetComponentsInChildren<MiniGalaxy>(true);
|
|
|
|
|
for (var i = 0; i < galaxyController._galaxies.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
galaxyController._galaxies[i].DieAfterSeconds(_deathDelays[i], true, AudioType.EyeGalaxyBlowAway);
|
|
|
|
|
}
|
2022-02-27 12:40:44 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
galaxyController._forestIsDarkTime = Time.time + 65f;
|
|
|
|
|
galaxyController.enabled = true;
|
2022-02-27 12:40:44 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
galaxyController._musicSource.SetLocalVolume(0f);
|
|
|
|
|
galaxyController._musicSource.FadeIn(5f);
|
2021-12-30 11:41:59 +00:00
|
|
|
|
}
|
2022-02-25 06:04:54 +00:00
|
|
|
|
}
|