public void UpdateNewPlayer(NetworkConnection requestedBy)
 {
     if (changeList.List.Count > 0)
     {
         UpdateTileMessage.SendTo(gameObject, requestedBy, changeList);
     }
 }
Esempio n. 2
0
    public static void Process()
    {
        if (!prefabsToSpawn.IsEmpty)
        {
            SpawnSafeThreadData data;
            while (prefabsToSpawn.TryDequeue(out data))
            {
                var result = Spawn.ServerPrefab(data.Prefab, data.WorldPosition, data.ParentTransform == null ? MatrixManager.GetDefaultParent(data.WorldPosition, true) : data.ParentTransform,
                                                count: data.Amount);

                //Greater than one as most items start stacked at 1
                if (result.Successful && data.AmountIfStackable > 1 && result.GameObject.TryGetComponent <Stackable>(out var stackable))
                {
                    // -1 as we are adding, eg if we want 10 in stack, item already starts at 1 so we add 9
                    stackable.ServerIncrease(data.AmountIfStackable - 1);
                }
            }
        }

        if (!tilesToUpdate.IsEmpty)
        {
            Tuple <uint, Vector3Int, TileType, string, Matrix4x4, Color> tuple;
            while (tilesToUpdate.TryDequeue(out tuple))
            {
                UpdateTileMessage.Send(tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5, tuple.Item6);
            }
        }
    }
    private void AlertClients(Vector3Int position, TileType tileType, string tileName,
                              Matrix4x4?transformMatrix = null, Color?color = null)
    {
        if (color == null)
        {
            color = color.GetValueOrDefault(Color.white);
        }

        if (transformMatrix == null)
        {
            transformMatrix = transformMatrix.GetValueOrDefault(Matrix4x4.identity);
        }

        UpdateTileMessage.Send(networkIdentity.netId, position, tileType, tileName, (Matrix4x4)transformMatrix, (Color)color);
    }
Esempio n. 4
0
    public static UpdateTileMessage Send(uint tileChangeManagerNetID, Vector3Int position, TileType tileType, string tileName,
                                         Matrix4x4 transformMatrix, Color colour)
    {
        UpdateTileMessage msg = new UpdateTileMessage
        {
            Position          = position,
            TileType          = tileType,
            TileName          = tileName,
            TransformMatrix   = transformMatrix,
            Colour            = colour,
            TileChangeManager = tileChangeManagerNetID
        };

        msg.SendToAll();
        return(msg);
    }
    public static void Process()
    {
        if (!prefabsToSpawn.IsEmpty)
        {
            Tuple <Vector3, GameObject> tuple;
            while (prefabsToSpawn.TryDequeue(out tuple))
            {
                Spawn.ServerPrefab(tuple.Item2, tuple.Item1, MatrixManager.GetDefaultParent(tuple.Item1, true));
            }
        }

        if (!tilesToUpdate.IsEmpty)
        {
            Tuple <uint, Vector3Int, TileType, string, Matrix4x4, Color> tuple;
            while (tilesToUpdate.TryDequeue(out tuple))
            {
                UpdateTileMessage.Send(tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5, tuple.Item6);
            }
        }
    }
Esempio n. 6
0
 public static bool SentWith(this UpdateTileMessage message, ImageResult image)
 {
     return(message != null && message.Image == image);
 }