예제 #1
0
        public override void KillSelf()
        {
            if (Destroyed)
            {
                return;
            }
            var chunk = ChunkManager.GetChunkByNum(ChunkNumber);

            chunk.SetIndex(CurrentPos, -1);
            chunk.RemoveObject(CurrentPos);

            if (pickUped != null)
            {
                ItemEvents.OnDeathDropItem(pickUped, this);
            }

            ClickManager.RemoveChosing(gameObject);

            GameMoveManager.CancelAllOrders(this);
            if (GroupUtil.isCreatureGroup(Group))
            {
                GameOrderManager.RemoveMarks(this);
                //SimpleOrderManager.CancelOrders(this);
                if (MovingPath != null)
                {
                    MovingPath.Clear();
                }
            }

            if (SecondaryGroundLvL.isSecondaryGroup(Group))
            {
                SecondaryGroundLvL.RemovePos(ChunkNumber, CurrentPos);
            }

            if (FlagManager.IsFlagAtPos(CurrentPos))
            {
                FlagManager.RemoveFlag(CurrentPos);
            }

            ProgressUnitBar.RemoveProgressBar(this);
            CreatureGroupManager.RemoveEntFromGroup(this);
            BuildingsGroupManager.RemoveBuildingFromGroup(this);

            RemoveAbilities();

            if (research != null)
            {
                var sameBuilds = BuildingsGroupManager.GetAllInChunkWithName(ChunkNumber, OriginalName);
                if (sameBuilds.Count == 0)
                {
                    Owner.RemoveResearch(research);
                }
            }
            Coloring.RecolorObject(ChunkUtil.GetDovvner(CurrentPos));
            Owner.foodCount -= foodCost;
            Owner.foodMax   -= foodGive;

            if (gameObject != null)
            {
                Destroy(gameObject);
            }


            Destroyed = true;
        }