Пример #1
0
    private void ActionChange(TileChangeEntry changeEntry)
    {
        if (!TilesManager.ValidateTileKey(changeEntry.layerToChange, changeEntry.tileKey))
        {
            Logger.LogError("No key found for Tile Change", Category.TileMaps);
            return;
        }

        //Set the correct z Level for the tile
        changeEntry.cellPosition.z = GetLayerZLevel(changeEntry.layerToChange);

        var tileMap = GetTilemap(changeEntry.layerToChange);

        if (tileMap == null)
        {
            return;
        }
        TileBase newTile = TilesManager.GetTile(changeEntry.layerToChange, changeEntry.tileKey);

        tileMap.SetTile(Vector3Int.RoundToInt(changeEntry.cellPosition), newTile);

        if (isServer)
        {
            RpcActionChange(changeEntry.cellPosition, changeEntry.tileKey, changeEntry.layerToChange);
        }

        //Store the change data and later we will store it in a database (so when a server crashes it is safe or to replay station change events)
        ChangeRegister.allEntries.Add(changeEntry);
    }