Example #1
0
 bool?OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
 {
     if (entity != null && hitInfo != null)
     {
         JDeployable.Child c = entity?.GetComponent <JDeployable.Child>();
         if (c != null && c.parent != null)
         {
             if (true)                                                 // if nodecay
             {
                 hitInfo.damageTypes.Scale(Rust.DamageType.Decay, 0f); // no decay damage
             }
             float damage = hitInfo.damageTypes.Total();
             if (damage > 0)
             {
                 float newhealth = entity.health - damage;
                 if (newhealth > 0f)
                 {
                     c.parent.SetHealth(newhealth);
                 }
                 else
                 {
                     KillDeployable(c.parent);
                 }
             }
             return(true);
         }
     }
     return(null);
 }
Example #2
0
 void OnStructureRepair(BaseCombatEntity entity, BasePlayer player)
 {
     JDeployable.Child c = entity?.GetComponent <JDeployable.Child>();
     if (c != null && c.parent != null && player != null)
     {
         NextTick(() => c.parent.OnStructureRepair(entity, player));
     }
 }
Example #3
0
 void OnKilledChild(BaseEntity entity)
 {
     JDeployable.Child c = entity?.GetComponent <JDeployable.Child>();
     if (c != null && c.parent != null)
     {
         KillDeployable(c.parent);
     }
 }
Example #4
0
 bool?OnStructureUpgrade(BaseCombatEntity entity, BasePlayer player, BuildingGrade.Enum grade)
 {
     JDeployable.Child c = entity?.GetComponent <JDeployable.Child>();
     if (c != null && c.parent != null && player != null)
     {
         return(c.parent.OnStructureUpgrade(c, player, grade));
     }
     return(null);
 }
Example #5
0
 bool?CanPickupEntity(BaseCombatEntity entity, BasePlayer player)
 {
     JDeployable.Child c = entity?.GetComponent <JDeployable.Child>();
     if (c != null && c.parent != null && player != null)
     {
         return(c.parent.CanPickupEntity(c, player));
     }
     return(null);
 }