2022-03-11 04:01:44 +00:00
|
|
|
|
using OWML.Common;
|
2021-12-23 06:59:08 +00:00
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.MeteorSync.WorldObjects;
|
|
|
|
|
using QSB.Utility;
|
2021-11-14 04:41:46 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.MeteorSync.Messages;
|
|
|
|
|
|
2022-03-11 04:01:44 +00:00
|
|
|
|
public class FragmentInitialStateMessage : QSBWorldObjectMessage<QSBFragment,
|
|
|
|
|
(float OrigIntegrity, float Integrity, float LeashLength)>
|
2021-11-14 04:41:46 +00:00
|
|
|
|
{
|
2022-03-11 04:01:44 +00:00
|
|
|
|
public FragmentInitialStateMessage(QSBFragment qsbFragment) : base((
|
|
|
|
|
qsbFragment.AttachedObject._origIntegrity,
|
|
|
|
|
qsbFragment.AttachedObject._integrity,
|
|
|
|
|
(float)qsbFragment.LeashLength // will have a value at this point, so cast is okay
|
|
|
|
|
)) { }
|
2021-12-23 06:59:08 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
2022-03-11 04:01:44 +00:00
|
|
|
|
WorldObject.AttachedObject._origIntegrity = Data.OrigIntegrity;
|
|
|
|
|
WorldObject.SetIntegrity(Data.Integrity);
|
|
|
|
|
if (WorldObject.LeashLength != null)
|
2022-02-25 06:04:54 +00:00
|
|
|
|
{
|
2022-03-11 04:01:44 +00:00
|
|
|
|
DebugLog.ToConsole($"leash length for {WorldObject} already set", MessageType.Warning);
|
|
|
|
|
return;
|
2022-03-03 03:46:33 +00:00
|
|
|
|
}
|
2021-12-23 06:59:08 +00:00
|
|
|
|
|
2022-03-11 04:01:44 +00:00
|
|
|
|
WorldObject.LeashLength = Data.LeashLength;
|
2021-11-14 04:41:46 +00:00
|
|
|
|
}
|
2022-03-11 04:01:44 +00:00
|
|
|
|
}
|