示例#1
0
        public GameItem SetupItem(GameEntity ent, string name, Vector3Int pos, Player owner)
        {
            var index = Loader.GetIndexByName(name);
            var npc   = LuaNpcGetter.GetNpcById(index);

            ent.Owner        = owner;
            ent.OriginalName = name;
            ent.name         = name;
            var item = ent as GameItem;

            var evoTo = LuaNpcGetter.GetEvolutionTo(npc);

            if (evoTo.Length > 0)
            {
                if (!UnitEvolution.IsHasSoloEvolution(name))
                {
                    UnitEvolution.AddToSoloDict(name, evoTo);
                }

                if (item != null)
                {
                    item.SoloEvolution = true;
                }
            }

            var evoCross = LuaNpcGetter.GetNpcEvoCrossing(npc);

            if (evoCross.Keys.Count > 0)
            {
                foreach (var pair in evoCross)
                {
                    UnitEvolution.AddToStackDict(name, pair.Key, pair.Value);

                    if (!string.Equals(pair.Key, name, StringComparison.OrdinalIgnoreCase))
                    {
                        UnitEvolution.AddToStackDict(pair.Key, name, pair.Value);
                    }
                }
            }
            if (GroupUtil.IsItem(ent.Group))
            {
                SecondaryGroundLvL.SetGroundEnt(ChunkNumber, pos, item);
            }

            if (GroupUtil.isBuilding(ent.Group))
            {
                ChunkManager.AddVision(ent);
            }
            ItemEvents.OnCreateItem(item, firstCreate);

            Coloring.RecolorObject(ChunkUtil.GetDovvner(ent.CurrentPos));

            return(item);
        }
示例#2
0
        public GameUnit SetupUnit(GameEntity ent, string name, Vector3Int pos, Player owner)
        {
            var index = Loader.GetIndexByName(name);
            var npc   = LuaNpcGetter.GetNpcById(index);

            ent.Owner        = owner;
            ent.OriginalName = name;
            ent.name         = name;
            var unit = ent as GameUnit;

            var evoTo = LuaNpcGetter.GetEvolutionTo(npc);

            if (evoTo.Length > 0)
            {
                if (!UnitEvolution.IsHasSoloEvolution(name))
                {
                    UnitEvolution.AddToSoloDict(name, evoTo);
                }

                if (unit != null)
                {
                    unit.SoloEvolution = true;
                }
            }

            var evoCross = LuaNpcGetter.GetNpcEvoCrossing(npc);

            if (evoCross.Keys.Count > 0)
            {
                foreach (var pair in evoCross)
                {
                    UnitEvolution.AddToStackDict(name, pair.Key, pair.Value);

                    if (!string.Equals(pair.Key, name, StringComparison.OrdinalIgnoreCase))
                    {
                        UnitEvolution.AddToStackDict(pair.Key, name, pair.Value);
                    }
                }
            }

            ChunkManager.AddVision(ent);
            UnitEvents.OnUnitSpawned(unit);


            Coloring.RecolorObject(ChunkUtil.GetDovvner(ent.CurrentPos));

            return(unit);
        }