quantum-space-buddies/QSB/TornadoSync/WorldObjects/QSBTornado.cs

42 lines
819 B
C#
Raw Normal View History

2022-01-21 23:13:16 +00:00
using QSB.Messaging;
using QSB.TornadoSync.Messages;
using QSB.WorldSync;
2021-12-04 14:21:11 +00:00
namespace QSB.TornadoSync.WorldObjects
{
public class QSBTornado : WorldObject<TornadoController>
{
2022-01-21 23:13:16 +00:00
public override void SendResyncInfo(uint to)
{
if (QSBCore.IsHost)
{
this.SendMessage(new TornadoFormStateMessage(FormState) { To = to });
}
}
2021-12-06 04:09:54 +00:00
public bool FormState
2021-12-05 11:41:07 +00:00
{
2021-12-06 04:09:54 +00:00
get => AttachedObject._tornadoRoot.activeSelf // forming or formed or collapsing
&& !AttachedObject._tornadoCollapsing; // and not collapsing
set
2021-12-05 11:41:07 +00:00
{
2021-12-06 04:09:54 +00:00
if (FormState == value)
{
return;
}
if (value)
{
AttachedObject._tornadoCollapsing = false;
AttachedObject.StartFormation();
}
else
{
AttachedObject._secondsUntilFormation = 0;
AttachedObject.StartCollapse();
}
2021-12-05 11:41:07 +00:00
}
}
2021-12-04 14:21:11 +00:00
}
}