Ejemplo n.º 1
0
        public static void Close(PersistentContainerInterface containerInterface, UniversalCoords coords)
        {
            PersistentContainer container = Instance(containerInterface.World, coords);

            if (container == null)
            {
                return;
            }
            container.RemoveInterface(containerInterface);
            Chunk chunk = container.World.GetChunk(coords) as Chunk;

            if (chunk == null)
            {
                return;
            }
            PersistentContainer unused;

            if (container is LargeChestContainer && container.IsUnused())
            {
                chunk.Containers.TryRemove(container.Coords.BlockPackedCoords, out unused);
                chunk.Containers.TryRemove((container as LargeChestContainer).SecondCoords.BlockPackedCoords, out unused);
            }
            else if (container is SmallChestContainer && container.IsUnused())
            {
                chunk.Containers.TryRemove(container.Coords.BlockPackedCoords, out unused);
            }
        }
Ejemplo n.º 2
0
        public static void Open(Player player, UniversalCoords coords)
        {
            PersistentContainer container = Instance(player.World, coords);

            if (container == null)
            {
                return;
            }

            Chunk chunk = player.World.GetChunk(coords) as Chunk;

            if (chunk == null)
            {
                return;
            }
            BlockData.Blocks block = chunk.GetType(coords);
            switch (block)
            {
            case BlockData.Blocks.Furnace:
            case BlockData.Blocks.Burning_Furnace:
                player.CurrentInterface = new FurnaceInterface(player.World, coords);
                break;

            case BlockData.Blocks.Dispenser:
                player.CurrentInterface = new DispenserInterface(player.World, coords);
                break;

            case BlockData.Blocks.Chest:
                if (container is LargeChestContainer)
                {
                    UniversalCoords[] doubleChestCoords = GetDoubleChestCoords(player.World, coords);
                    if (doubleChestCoords == null)
                    {
                        return;
                    }
                    if (container.Coords == doubleChestCoords[0])
                    {
                        player.CurrentInterface = new LargeChestInterface(player.World, doubleChestCoords[0], doubleChestCoords[1]);
                    }
                    else
                    {
                        player.CurrentInterface = new LargeChestInterface(player.World, doubleChestCoords[1], doubleChestCoords[0]);
                    }
                }
                else
                {
                    player.CurrentInterface = new SmallChestInterface(player.World, coords);
                }
                break;

            default:
                return;
            }
            player.CurrentInterface.Associate(player);
            container.AddInterface((PersistentContainerInterface)player.CurrentInterface);
            player.CurrentInterface.Open();
        }
Ejemplo n.º 3
0
        public static void Destroy(WorldManager world, UniversalCoords coords)
        {
            PersistentContainer container = Instance(world, coords);

            if (container == null)
            {
                return;
            }
            Chunk chunk = world.GetChunk(coords) as Chunk;

            if (chunk == null)
            {
                return;
            }
            PersistentContainer unused;

            container.Destroy();
            chunk.Containers.TryRemove(container.Coords.BlockPackedCoords, out unused);
            if (container is LargeChestContainer)
            {
                chunk.Containers.TryRemove((container as LargeChestContainer).SecondCoords.BlockPackedCoords, out unused);
            }
        }