//only intended to be used by core if2 classes
    public static void SendTileApply(TileApply tileApply, InteractableTiles interactableTiles, TileInteraction tileInteraction, int tileInteractionIndex)
    {
        //if we are client and the interaction has client prediction, trigger it.
        //Note that client prediction is not triggered for server player.
        if (!CustomNetworkManager.IsServer)
        {
            Logger.LogTraceFormat("Predicting TileApply interaction {0}", Category.Interaction, tileApply);
            tileInteraction.ClientPredictInteraction(tileApply);
        }
        if (!tileApply.Performer.Equals(PlayerManager.LocalPlayer))
        {
            Logger.LogError("Client attempting to perform an interaction on behalf of another player." +
                            " This is not allowed. Client can only perform an interaction as themselves. Message" +
                            " will not be sent.", Category.NetMessage);
            return;
        }

        var msg = new RequestInteractMessage()
        {
            ComponentType        = typeof(InteractableTiles),
            InteractionType      = typeof(TileApply),
            ProcessorObject      = interactableTiles.GetComponent <NetworkIdentity>().netId,
            Intent               = tileApply.Intent,
            TargetVector         = tileApply.TargetVector,
            TileInteractionIndex = tileInteractionIndex
        };

        msg.Send();
    }
예제 #2
0
    public static void SendTileMouseDrop(TileMouseDrop mouseDrop, InteractableTiles interactableTiles)
    {
        if (!mouseDrop.Performer.Equals(PlayerManager.LocalPlayer))
        {
            Logger.LogError("Client attempting to perform an interaction on behalf of another player." +
                            " This is not allowed. Client can only perform an interaction as themselves. Message" +
                            " will not be sent.", Category.NetMessage);
            return;
        }

        var msg = new RequestInteractMessage()
        {
            ComponentType   = typeof(InteractableTiles),
            InteractionType = typeof(TileMouseDrop),
            ProcessorObject = interactableTiles.GetComponent <NetworkIdentity>().netId,
            Intent          = mouseDrop.Intent,
            UsedObject      = mouseDrop.UsedObject.NetId(),
            TargetVector    = mouseDrop.TargetVector
        };

        msg.Send();
    }