summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/InnerNet/InnerNetObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/InnerNet/InnerNetObject.cs')
-rw-r--r--Client/Assembly-CSharp/InnerNet/InnerNetObject.cs74
1 files changed, 74 insertions, 0 deletions
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<InnerNetObject>
+ {
+ 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;
+ }
+ }
+}