예제 #1
0
 void Start()
 {
     openObjects   = new List <GameObject>();
     gameManager   = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
     raiding       = gameManager.GetComponent <Raiding>();
     invading      = gameManager.GetComponent <Invading>();
     tradeListener = tradeObject.GetComponentInChildren <TradeListener>();
 }
예제 #2
0
        object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hit)
        {
            if (entity == null || hit == null)
            {
                return(null);
            }

            object externalResult = Interface.CallHook("CanEntityTakeDamage", new object[] { entity, hit });

            if (externalResult != null)
            {
                if ((bool)externalResult == false)
                {
                    return(false);
                }

                return(null);
            }

            if (hit.damageTypes.Has(Rust.DamageType.Decay))
            {
                return(Decay.AlterDecayDamage(entity, hit));
            }

            User attacker = null;
            User defender = entity.GetComponent <User>();

            if (hit.InitiatorPlayer != null)
            {
                attacker = hit.InitiatorPlayer.GetComponent <User>();
            }

            // A player is being injured by something other than a player/NPC.
            if (attacker == null && defender != null)
            {
                return(Pvp.HandleIncidentalDamage(defender, hit));
            }

            // One player is damaging another player.
            if (attacker != null && defender != null)
            {
                return(Pvp.HandleDamageBetweenPlayers(attacker, defender, hit));
            }

            // A player is damaging a structure.
            if (attacker != null && defender == null)
            {
                return(Raiding.HandleDamageAgainstStructure(attacker, entity, hit));
            }

            // A structure is taking damage from something that isn't a player.
            return(Raiding.HandleIncidentalDamage(entity, hit));
        }