Пример #1
0
    public void RegisterFurniture(Furniture placed, int x, int y)
    {
        // Called on both client and servers when the object is spawned.
        if (IsFurnitureAt(x, y))
        {
            Debug.LogWarning("Already something at {0}, {1}".Form(x, y));
            return;
        }

        // Set parent
        placed.transform.SetParent(Parent);

        // Register furniture at that position.
        furniture.Add(GetIndexAt(x, y), placed);

        // Confirm to pending building system.
        PendingBuildingManager.Instance.ConfirmPlaced(PendingBuildingManager.MakeID(x, y));
    }
Пример #2
0
    public void RecievedTileChange(Msg_SendTile data)
    {
        // Called on clients when a tile has been set.

        // Confirm to the pending placement system...
        PendingBuildingManager.Instance.ConfirmPlaced(PendingBuildingManager.MakeID(data.X, data.Y));

        // If we are a host, just stop. Tile has already been set.
        if (isServer)
        {
            return;
        }

        // Check if is in bounds.
        if (!InLayerBounds(data.X, data.Y))
        {
            Debug.LogError("Why did the server send me coordinates out of bounds?!?! (" + data.X + ", " + data.Y + ")");
            return;
        }

        // Check if it is loaded. If it is not ignore this. TODO if it is loading, make it be applied once loaded.
        if (IsChunkLoaded(GetChunkIndexFromTileCoords(data.X, data.Y)))
        {
            // Place tile in position.
            BaseTile oldTile = Tiles[data.X][data.Y];

            BaseTile tile = data.Prefab == null ? null : BaseTile.GetTile(data.Prefab);

            Chunk c = GetChunkFromIndex(GetChunkIndexFromTileCoords(data.X, data.Y));

            if (oldTile != null)
            {
                TileRemoved(data.X, data.Y, oldTile, c);
            }

            // Apply tile.
            Tiles[data.X][data.Y] = tile;

            // Update tiles sourrounding and update physics bodies.
            TilePlaced(data.X, data.Y, tile, c);
        }
    }
 public void OnDestroy()
 {
     Pending.Clear();
     Instance = null;
 }
 public void Awake()
 {
     Instance = this;
     Pending.Clear();
 }
 public string GetID()
 {
     return(PendingBuildingManager.MakeID(X, Y));
 }