]> git.deb.at Git - rhonda/impostor.git/commitdiff
Turn derived properties into getters
authorminiduikboot <mini@duikbo.at>
Wed, 23 Jun 2021 18:46:45 +0000 (20:46 +0200)
committerminiduikboot <mini@duikbo.at>
Fri, 25 Jun 2021 16:46:28 +0000 (18:46 +0200)
There is no significant performance difference: while accessing the
getters is slightly slower, this can be balanced against the cost of
setting the property. As this is also cleaner, switch to getters.

src/Impostor.Server/Net/Inner/Objects/InnerMeetingHud.PlayerVoteArea.cs

index 9e0004a0ad170bafbc5e13b24cdd1bae55c940e5..fcd320f32cc4970a2a840d229c4a126210015f84 100644 (file)
@@ -16,16 +16,16 @@ namespace Impostor.Server.Net.Inner.Objects
                 Parent = parent;
                 TargetPlayer = targetPlayer;
 
-                IsDead = isDead;
+                VotedForId = (byte)(isDead ? TVoteType.Dead : TVoteType.HasNotVoted);
             }
 
             public InnerMeetingHud Parent { get; }
 
             public InnerPlayerInfo TargetPlayer { get; }
 
-            public bool IsDead { get; private set; }
+            public bool IsDead => VoteType == TVoteType.Dead;
 
-            public bool DidVote { get; private set; }
+            public bool DidVote => VoteType != TVoteType.HasNotVoted;
 
             public bool DidReport { get; private set; }
 
@@ -40,7 +40,6 @@ namespace Impostor.Server.Net.Inner.Objects
                     switch ((VoteType)value)
                     {
                         case TVoteType.Dead:
-                            IsDead = true;
                             VoteType = TVoteType.Dead;
                             break;
 
@@ -55,8 +54,6 @@ namespace Impostor.Server.Net.Inner.Objects
                             VotedFor = Parent.Game.GameNet.GameData!.GetPlayerById(value)?.Controller;
                             break;
                     }
-
-                    DidVote = VoteType != TVoteType.HasNotVoted;
                 }
             }