Advertisement
Finnit

DecayEntity

Dec 7th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. using ProtoBuf;
  2. using System;
  3.  
  4. public class DecayEntity : BaseCombatEntity
  5. {
  6.     [NonSerialized]
  7.     public uint buildingID;
  8.  
  9.     private float decayTimer;
  10.  
  11.     public DecayEntity()
  12.     {
  13.     }
  14.  
  15.     public void AttachToBuilding(uint id)
  16.     {
  17.         if (base.isClient)
  18.         {
  19.             BuildingManager.client.Remove(this);
  20.             this.buildingID = id;
  21.             BuildingManager.client.Add(this);
  22.         }
  23.     }
  24.  
  25.     protected override void ClientInit(Entity info)
  26.     {
  27.         base.ClientInit(info);
  28.         BuildingManager.client.Add(this);
  29.     }
  30.  
  31.     public override bool DisplayHealthInfo(BasePlayer player)
  32.     {
  33.         bool flag;
  34.         if (!this.ShowHealthInfo)
  35.         {
  36.             flag = false;
  37.         }
  38.         else
  39.         {
  40.             flag = (base.healthFraction < 0.95f ? true : player.IsHoldingEntity<Hammer>());
  41.         }
  42.         return flag;
  43.     }
  44.  
  45.     protected override void DoClientDestroy()
  46.     {
  47.         base.DoClientDestroy();
  48.         BuildingManager.client.Remove(this);
  49.     }
  50.  
  51.     public BuildingManager.Building GetBuilding()
  52.     {
  53.         if (!base.isClient)
  54.         {
  55.             return null;
  56.         }
  57.         return BuildingManager.client.GetBuilding(this.buildingID);
  58.     }
  59.  
  60.     public override void Load(BaseNetworkable.LoadInfo info)
  61.     {
  62.         base.Load(info);
  63.         if (info.msg.decayEntity != null)
  64.         {
  65.             this.decayTimer = info.msg.decayEntity.decayTimer;
  66.             if (this.buildingID != info.msg.decayEntity.buildingID)
  67.             {
  68.                 this.AttachToBuilding(info.msg.decayEntity.buildingID);
  69.             }
  70.         }
  71.     }
  72.  
  73.     public override void ResetState()
  74.     {
  75.         base.ResetState();
  76.         this.buildingID = 0;
  77.         this.decayTimer = 0f;
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement