Esempio n. 1
0
    /// <summary>
    /// Removes Net data, and destroys object
    /// </summary>
    /// <param name="netId"></param>
    public static void DestroyNetGameObject(long netId)
    {
        GameObjectData goData_C0;

        if (singleton._netIdToGameObjectData.TryGetValue(netId, out goData_C0))
        {
            GameObjectData goData_C1;
            if (singleton._netIdToGameObjectData.TryGetValue(goData_C0.gameObjectInstanceId, out goData_C1))
            {
                if (goData_C0.Equals(goData_C1) == false) // should be the same
                {
                    Debug.LogError("ERROR, GameObjectData is messed up!");
                }

                // if we own the object, we can destroy it accross call clients
                if (FFSystem.OwnGameObject(goData_C0.gameObject))
                {
                    //Debug.Log("Sent NetObjectDestroyedEvent");//debug
                    NetObjectDestroyedEvent e;
                    e.destructiontime = FFSystem.time;
                    e.gameObjectNetId = goData_C1.gameObjectNetId;
                    FFMessage <NetObjectDestroyedEvent> .SendToNet(e, true);
                }

                singleton._netIdToGameObjectData.Remove(goData_C1.gameObjectNetId);
                singleton._localIdToGameObjectData.Remove(goData_C1.gameObjectInstanceId);
            }
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Removes Local Data go, DOES NOT destroy object
    /// </summary>
    /// <param name="go"></param>
    public static void UnRegisterNetGameObject(GameObject go, bool destroyGameObject = true)
    {
        int            id = go.GetInstanceID();
        GameObjectData goData_C0;

        if (singleton._localIdToGameObjectData.TryGetValue(id, out goData_C0))
        {
            GameObjectData goData_C1;
            if (singleton._netIdToGameObjectData.TryGetValue(goData_C0.gameObjectNetId, out goData_C1))
            {
                if (goData_C0.Equals(goData_C1) == false) // should be the same
                {
                    Debug.LogError("ERROR, GameObjectData is messed up!");
                }


                if (destroyGameObject)
                {
                    // if we own the object or are the server, we can destroy
                    // it accross all other clients
                    // We own the object
                    if (goData_C0.ownerClientId == FFClient.clientId ||
                        FFServer.isLocal)
                    {
                        //Debug.Log("Sent NetObjectDestroyedEvent");//debug
                        NetObjectDestroyedEvent e;
                        e.destructiontime = FFSystem.time;
                        e.gameObjectNetId = goData_C1.gameObjectNetId;
                        FFMessage <NetObjectDestroyedEvent> .SendToNet(e, true);
                    }
                }

                singleton._netIdToGameObjectData.Remove(goData_C1.gameObjectNetId);
                singleton._localIdToGameObjectData.Remove(goData_C1.gameObjectInstanceId);
            }
        }

        if (destroyGameObject)
        {
            GameObject.Destroy(go);
        }
    }
Esempio n. 3
0
 // Not sure how useful this is, TODO remove?
 public override void SendToNet(object message)
 {
     FFMessage <EventType> .SendToNet((EventType)message);
 }