Beispiel #1
0
    /// <summary>
    /// Stops listening to Local and Networed message on this GameObject's box for this board type. This
    /// can be done at any time and is useful for 1-off listeners or other time sensative listeners.
    /// </summary>
    public static void Disconnect(FFMessageBox <EventType> .EventListener function, GameObject go)
    {
        string id = BaseMessageBoard.LocalIdEntry(go.GetInstanceID());
        FFMessageBox <EventType> box;

        if (messageBoard.TryGetValue(id, out box))
        {
            box.Disconnect(function);
        }
    }
Beispiel #2
0
    // Note: In order for the GameObject Interface to work
    // Any object which want to recieve events from the net
    // much call the FFSystem.RegisterNetGameObject(gameObject)
    // in order for their object to recieve events from other clients.
    // RegisterNetGameObject cannot be called in: non-main Thread,
    // Component Constructor, Awake (maybe, TODO test) TODO Make this actually work

    /// <summary>
    /// Send the message locally (to this Unity Instance) to the go (GameObject)
    /// </summary>
    public static bool SendToLocal(EventType message, GameObject go)
    {
        string boxEntry = BaseMessageBoard.LocalIdEntry(go.GetInstanceID());
        FFMessageBox <EventType> box;

        if (messageBoard.TryGetValue(boxEntry, out box))
        {
            return(box.SendToLocal(message));
        }
        else
        {
            return(false);
        }
    }
Beispiel #3
0
    public static FFMessageBox <EventType> Box(GameObject go)
    {
        string boxEntry = BaseMessageBoard.LocalIdEntry(go.GetInstanceID());
        FFMessageBox <EventType> box;

        if (messageBoard.TryGetValue(boxEntry, out box))
        {
            return(box);
        }
        else
        {
            return(null);
        }
    }
Beispiel #4
0
    /// <summary>
    /// Connect to Local and Networked message on this GameObject's box for this board type. Connecting
    /// will make this function called when it is sent a message directly or indirectly
    /// (via SendToLocal/Up/Down/ToAllConnected or by another client calling SendToNet/Up/Down/ToAllConnected)
    /// </summary>
    public static void Connect(FFMessageBox <EventType> .EventListener function, GameObject go)
    {
        GetReady();
        string id = BaseMessageBoard.LocalIdEntry(go.GetInstanceID());
        FFMessageBox <EventType> box;

        if (messageBoard.TryGetValue(id, out box))
        {
            box.Connect(function);
        }
        else
        {
            box = new FFMessageBox <EventType>(messageBoardSystem, id);
            box.Connect(function);
            messageBoard.Add(id, box);
        }
    }
    // Note: In order for the GameObject Interface to work
    // Any object which want to recieve events from the net
    // much call the FFSystem.RegisterNetGameObject(gameObject)
    // in order for their object to recieve events from other clients.
    // RegisterNetGameObject cannot be called in: non-main Thread,
    // Component Constructor, Awake (maybe, TODO test) TODO Make this actually work

    /// <summary>
    /// Send the message locally (to this Unity Instance) to the go (GameObject)
    /// </summary>
    public static int Send(EventType message, GameObject go, int consumeQuantity = 1)
    {
        if (consumeQuantity <= 0)
        {
            return(consumeQuantity);
        }

        string boxEntry = BaseMessageBoard.LocalIdEntry(go.GetInstanceID());
        FFMessageBox <EventType> box;

        if (messageBoard.TryGetValue(boxEntry, out box))
        {
            return(box.SendToLocal(message, consumeQuantity));
        }
        else
        {
            return(consumeQuantity);
        }
        // @TODO @NET if a networked object, we should send the message to the net as well...
        //FFMessageSystem.SendMessageToNet<EventType>(message, go.GetInstanceID(),
        //    FFPacketInstructionFlags.MessageBoardGameObjectSend, varifiedPacket);
    }
Beispiel #6
0
    /// <summary>
    /// Disbatch a message to a game object with instructions on locality of the disbatch
    /// </summary>
    public static void DisbatchMessage <EventType>(EventType message, FFPacketInstructionFlags instructions, GameObject go)
    {
        instructions |= FFPacketInstructionFlags.MessageBoardGameObjectSend;
        var packet = new FFPacket <EventType>(instructions, typeof(EventType).Name, message, BaseMessageBoard.LocalIdEntry(go.GetInstanceID()));

        DisbatchPacket(packet);
    }