From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/InnerNet/InnerNetObject.cs | 74 +++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Client/Assembly-CSharp/InnerNet/InnerNetObject.cs (limited to 'Client/Assembly-CSharp/InnerNet/InnerNetObject.cs') diff --git a/Client/Assembly-CSharp/InnerNet/InnerNetObject.cs b/Client/Assembly-CSharp/InnerNet/InnerNetObject.cs new file mode 100644 index 0000000..0fdcf2d --- /dev/null +++ b/Client/Assembly-CSharp/InnerNet/InnerNetObject.cs @@ -0,0 +1,74 @@ +using System; +using Hazel; +using UnityEngine; + +namespace InnerNet +{ + public abstract class InnerNetObject : MonoBehaviour, IComparable + { + public bool AmOwner + { + get + { + return this.OwnerId == AmongUsClient.Instance.ClientId; + } + } + + public uint SpawnId; + + public uint NetId; + + public uint DirtyBits; + + public SpawnFlags SpawnFlags; + + public SendOption sendMode = SendOption.Reliable; + + public int OwnerId; + + protected bool DespawnOnDestroy = true; + + public void Despawn() + { + UnityEngine.Object.Destroy(base.gameObject); + AmongUsClient.Instance.Despawn(this); + } + + public virtual void OnDestroy() + { + if (AmongUsClient.Instance && this.NetId != 4294967295U) + { + if (this.DespawnOnDestroy && this.AmOwner) + { + AmongUsClient.Instance.Despawn(this); + return; + } + AmongUsClient.Instance.RemoveNetObject(this); + } + } + + public abstract void HandleRpc(byte callId, MessageReader reader); + + public abstract bool Serialize(MessageWriter writer, bool initialState); + + public abstract void Deserialize(MessageReader reader, bool initialState); + + public int CompareTo(InnerNetObject other) + { + if (this.NetId > other.NetId) + { + return 1; + } + if (this.NetId < other.NetId) + { + return -1; + } + return 0; + } + + protected void SetDirtyBit(uint val) + { + this.DirtyBits |= val; + } + } +} -- cgit v1.1-26-g67d0