Ejemplo n.º 1
0
        void OnEntityKill(BaseNetworkable networkable)
        {
            var entity = networkable as BaseEntity;

            if (!Ready || entity == null)
            {
                return;
            }

            // If a claim TC was destroyed, remove the claim from the area.
            var cupboard = entity as BuildingPrivlidge;

            if (cupboard != null)
            {
                var area = Areas.GetByClaimCupboard(cupboard);
                if (area != null)
                {
                    PrintToChat(Messages.AreaClaimLostCupboardDestroyedAnnouncement, area.FactionId, area.Id);
                    Log($"{area.FactionId} lost their claim on {area.Id} because the tool cupboard was destroyed (hook function)");
                    Areas.Unclaim(area);
                }
                return;
            }

            // If a tax chest was destroyed, remove it from the faction data.
            var container = entity as StorageContainer;

            if (Options.Taxes.Enabled && container != null)
            {
                Faction faction = Factions.GetByTaxChest(container);
                if (faction != null)
                {
                    Log($"{faction.Id}'s tax chest was destroyed (hook function)");
                    faction.TaxChest = null;
                }
                return;
            }

            // If a helicopter was destroyed, create an event zone around it.
            var helicopter = entity as BaseHelicopter;

            if (Options.Zones.Enabled && helicopter != null)
            {
                Zones.CreateForDebrisField(helicopter);
            }
        }