]> git.deb.at Git - rhonda/impostor.git/commitdiff
Add useful method
authorAeonLucid <aeonlucid@outlook.com>
Sat, 24 Oct 2020 03:02:24 +0000 (05:02 +0200)
committerAeonLucid <aeonlucid@outlook.com>
Sat, 24 Oct 2020 03:02:24 +0000 (05:02 +0200)
src/Impostor.Api/Innersloth/Net/InnerNetObject.cs

index b800cc62225b6f8ee889be8a599b369fc6880d5d..da1b516359b6a312c3765446e59697b51d6d0297 100644 (file)
@@ -5,6 +5,8 @@ namespace Impostor.Api.Innersloth.Net
 {
     public abstract class InnerNetObject : GameObject
     {
+        private const int HostInheritId = -2;
+
         public uint NetId { get; internal set; }
 
         public int OwnerId { get; internal set; }
@@ -16,5 +18,11 @@ namespace Impostor.Api.Innersloth.Net
         public abstract bool Serialize(IMessageWriter writer, bool initialState);
 
         public abstract void Deserialize(IClientPlayer sender, IClientPlayer? target, IMessageReader reader, bool initialState);
+
+        public bool IsOwnedBy(IClientPlayer player)
+        {
+            return OwnerId == player.Client.Id ||
+                   (OwnerId == HostInheritId && player.IsHost);
+        }
     }
 }
\ No newline at end of file