Ejemplo n.º 1
0
        public void OnChangedWithType(Chunk chunk, BlockChangeRequestOrigin origin, Vector3Int blockPosition, ItemTypes.ItemType typeOld, ItemTypes.ItemType typeNew)
        {
            if (Types.ContainsByReference(typeOld, out int idxOld))
            {
                if (Positions.TryRemove(blockPosition, out CivCrate instance))
                {
                    chunk.GetEntities()?.Remove(blockPosition);
                }
            }

            if (Types.ContainsByReference(typeNew, out int idxNew))
            {
                Colony colony = null;
                switch (origin.Type)
                {
                case BlockChangeRequestOrigin.EType.Colony:
                    colony = origin.AsColony;
                    break;

                case BlockChangeRequestOrigin.EType.Player:
                    Players.Player play = origin.AsPlayer;
                    colony = play.ActiveColony;
                    break;
                }

                CivCrate crate = new CivCrate(colony);
                if (chunk.GetOrAllocateEntities().Add(blockPosition, crate))
                {
                    Positions.TryAdd(blockPosition, crate);
                }
            }
        }
Ejemplo n.º 2
0
        public void OnLoadedWithDataPosition(Chunk chunk, Vector3Int blockPosition, ushort type, ByteReader reader)
        {
            Colony colony = null;

            if (reader != null)
            {
                colony = ServerManager.ColonyTracker.Get(reader.ReadVariableInt());
            }
            CivCrate crate = new CivCrate(colony);

            if (chunk.GetOrAllocateEntities().Add(blockPosition, crate))
            {
                Positions.TryAdd(blockPosition, crate);
            }
        }
Ejemplo n.º 3
0
 static bool IsCloseAndHasColony(Vector3Int position, CivCrate crate, ref (Banner[] banners, int range, Colony colony) data)