IsEmpty() public method

Returns true if the value of the NetworkInstanceId is zero.

public IsEmpty ( ) : bool
return bool
Esempio n. 1
0
        public NetworkIdentity ReadNetworkIdentity()
        {
            NetworkInstanceId netId = ReadNetworkId();

            if (netId.IsEmpty())
            {
                return(null);
            }
            GameObject go;

            if (NetworkServer.active)
            {
                go = NetworkServer.FindLocalObject(netId);
            }
            else
            {
                go = ClientScene.FindLocalObject(netId);
            }
            if (go == null)
            {
                if (LogFilter.logDebug)
                {
                    Debug.Log("ReadNetworkIdentity netId:" + netId + "go: null");
                }
                return(null);
            }

            return(go.GetComponent <NetworkIdentity>());
        }
Esempio n. 2
0
        public Transform ReadTransform()
        {
            NetworkInstanceId networkInstanceId = this.ReadNetworkId();
            Transform         result;

            if (networkInstanceId.IsEmpty())
            {
                result = null;
            }
            else
            {
                GameObject gameObject = ClientScene.FindLocalObject(networkInstanceId);
                if (gameObject == null)
                {
                    if (LogFilter.logDebug)
                    {
                        Debug.Log("ReadTransform netId:" + networkInstanceId);
                    }
                    result = null;
                }
                else
                {
                    result = gameObject.transform;
                }
            }
            return(result);
        }
Esempio n. 3
0
        public NetworkIdentity ReadNetworkIdentity()
        {
            NetworkInstanceId netId = this.ReadNetworkId();

            if (!netId.IsEmpty())
            {
                GameObject obj2;
                if (NetworkServer.active)
                {
                    obj2 = NetworkServer.FindLocalObject(netId);
                }
                else
                {
                    obj2 = ClientScene.FindLocalObject(netId);
                }
                if (obj2 != null)
                {
                    return(obj2.GetComponent <NetworkIdentity>());
                }
                if (LogFilter.logDebug)
                {
                    Debug.Log("ReadNetworkIdentity netId:" + netId + "go: null");
                }
            }
            return(null);
        }
Esempio n. 4
0
        public NetworkIdentity ReadNetworkIdentity()
        {
            NetworkInstanceId networkInstanceId = this.ReadNetworkId();
            NetworkIdentity   result;

            if (networkInstanceId.IsEmpty())
            {
                result = null;
            }
            else
            {
                GameObject gameObject;
                if (NetworkServer.active)
                {
                    gameObject = NetworkServer.FindLocalObject(networkInstanceId);
                }
                else
                {
                    gameObject = ClientScene.FindLocalObject(networkInstanceId);
                }
                if (gameObject == null)
                {
                    if (LogFilter.logDebug)
                    {
                        Debug.Log("ReadNetworkIdentity netId:" + networkInstanceId + "go: null");
                    }
                    result = null;
                }
                else
                {
                    result = gameObject.GetComponent <NetworkIdentity>();
                }
            }
            return(result);
        }
Esempio n. 5
0
 protected void SetSyncVarGameObject(GameObject newGameObject, ref GameObject gameObjectField, uint dirtyBit, ref NetworkInstanceId netIdField)
 {
     if (!this.m_SyncVarGuard)
     {
         NetworkInstanceId netId = new NetworkInstanceId();
         if (newGameObject != null)
         {
             NetworkIdentity component = newGameObject.GetComponent <NetworkIdentity>();
             if (component != null)
             {
                 netId = component.netId;
                 if (netId.IsEmpty() && LogFilter.logWarn)
                 {
                     Debug.LogWarning("SetSyncVarGameObject GameObject " + newGameObject + " has a zero netId. Maybe it is not spawned yet?");
                 }
             }
         }
         NetworkInstanceId id2 = new NetworkInstanceId();
         if (gameObjectField != null)
         {
             id2 = gameObjectField.GetComponent <NetworkIdentity>().netId;
         }
         if (netId != id2)
         {
             if (LogFilter.logDev)
             {
                 Debug.Log(string.Concat(new object[] { "SetSyncVar GameObject ", base.GetType().Name, " bit [", dirtyBit, "] netfieldId:", id2, "->", netId }));
             }
             this.SetDirtyBit(dirtyBit);
             gameObjectField = newGameObject;
             netIdField      = netId;
         }
     }
 }
    // Logs deaths in the scoreboard and kills where applicable
    public static void LogKill(NetworkInstanceId killerId, NetworkInstanceId victimId)
    {
        PlayerStats[victimId]["deaths"]++;

        // Not a suicide or environmental death, so log a kill
        if (!killerId.IsEmpty () && killerId != victimId) {
            PlayerStats[killerId]["kills"]++;
        }
    }
Esempio n. 7
0
        /// <summary>
        /// <para>Reads a reference to a Transform from the stream.</para>
        /// </summary>
        /// <returns>
        /// <para>The transform object read.</para>
        /// </returns>
        public Transform ReadTransform()
        {
            NetworkInstanceId netId = this.ReadNetworkId();

            if (netId.IsEmpty())
            {
                return(null);
            }
            GameObject obj2 = ClientScene.FindLocalObject(netId);

            return(obj2?.transform);
        }
Esempio n. 8
0
        public GameObject ReadGameObject()
        {
            NetworkInstanceId networkInstanceId = ReadNetworkId();

            if (networkInstanceId.IsEmpty())
            {
                return(null);
            }
            GameObject gameObject = (!NetworkServer.active) ? ClientScene.FindLocalObject(networkInstanceId) : NetworkServer.FindLocalObject(networkInstanceId);

            if (gameObject == null && LogFilter.logDebug)
            {
                Debug.Log("ReadGameObject netId:" + networkInstanceId + "go: null");
            }
            return(gameObject);
        }
Esempio n. 9
0
        /// <summary>
        ///   <para>Reads a reference to a GameObject from the stream.</para>
        /// </summary>
        /// <returns>
        ///   <para>The GameObject referenced.</para>
        /// </returns>
        public GameObject ReadGameObject()
        {
            NetworkInstanceId netId = this.ReadNetworkId();

            if (netId.IsEmpty())
            {
                return((GameObject)null);
            }
            GameObject gameObject = !NetworkServer.active ? ClientScene.FindLocalObject(netId) : NetworkServer.FindLocalObject(netId);

            if ((UnityEngine.Object)gameObject == (UnityEngine.Object)null && LogFilter.logDebug)
            {
                Debug.Log((object)("ReadGameObject netId:" + (object)netId + "go: null"));
            }
            return(gameObject);
        }
Esempio n. 10
0
        public Transform ReadTransform()
        {
            NetworkInstanceId netId = this.ReadNetworkId();

            if (!netId.IsEmpty())
            {
                GameObject obj2 = ClientScene.FindLocalObject(netId);
                if (obj2 != null)
                {
                    return(obj2.transform);
                }
                if (LogFilter.logDebug)
                {
                    Debug.Log("ReadTransform netId:" + netId);
                }
            }
            return(null);
        }
        protected void SetSyncVarGameObject(GameObject newGameObject, ref GameObject gameObjectField, ulong dirtyBit, ref NetworkInstanceId netIdField)
        {
            if (m_SyncVarGuard)
            {
                return;
            }

            NetworkInstanceId newGameObjectNetId = new NetworkInstanceId();

            if (newGameObject != null)
            {
                var uv = newGameObject.GetComponent <NetworkIdentity>();
                if (uv != null)
                {
                    newGameObjectNetId = uv.netId;
                    if (newGameObjectNetId.IsEmpty())
                    {
                        if (LogFilter.logWarn)
                        {
                            Debug.LogWarning("SetSyncVarGameObject GameObject " + newGameObject + " has a zero netId. Maybe it is not spawned yet?");
                        }
                    }
                }
            }

            NetworkInstanceId oldGameObjectNetId = new NetworkInstanceId();

            if (gameObjectField != null)
            {
                oldGameObjectNetId = gameObjectField.GetComponent <NetworkIdentity>().netId;
            }

            if (newGameObjectNetId != oldGameObjectNetId)
            {
                if (LogFilter.logDev)
                {
                    Debug.Log("SetSyncVar GameObject " + GetType().Name + " bit [" + dirtyBit + "] netfieldId:" + oldGameObjectNetId + "->" + newGameObjectNetId);
                }
                SetDirtyBit(dirtyBit);
                gameObjectField = newGameObject;
                netIdField      = newGameObjectNetId;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// <para>Reads a reference to a NetworkIdentity from the stream.</para>
        /// </summary>
        /// <returns>
        /// <para>The NetworkIdentity object read.</para>
        /// </returns>
        public NetworkIdentity ReadNetworkIdentity()
        {
            GameObject        obj2;
            NetworkInstanceId netId = this.ReadNetworkId();

            if (netId.IsEmpty())
            {
                return(null);
            }
            if (NetworkServer.active)
            {
                obj2 = NetworkServer.FindLocalObject(netId);
            }
            else
            {
                obj2 = ClientScene.FindLocalObject(netId);
            }
            return(obj2?.GetComponent <NetworkIdentity>());
        }
Esempio n. 13
0
        public Transform ReadTransform()
        {
            NetworkInstanceId networkInstanceId = ReadNetworkId();

            if (networkInstanceId.IsEmpty())
            {
                return(null);
            }
            GameObject gameObject = ClientScene.FindLocalObject(networkInstanceId);

            if (gameObject == null)
            {
                if (LogFilter.logDebug)
                {
                    Debug.Log("ReadTransform netId:" + networkInstanceId);
                }
                return(null);
            }
            return(gameObject.transform);
        }
Esempio n. 14
0
        /// <summary>
        ///   <para>Reads a reference to a NetworkIdentity from the stream.</para>
        /// </summary>
        /// <returns>
        ///   <para>The NetworkIdentity object read.</para>
        /// </returns>
        public NetworkIdentity ReadNetworkIdentity()
        {
            NetworkInstanceId netId = this.ReadNetworkId();

            if (netId.IsEmpty())
            {
                return((NetworkIdentity)null);
            }
            GameObject gameObject = !NetworkServer.active ? ClientScene.FindLocalObject(netId) : NetworkServer.FindLocalObject(netId);

            if (!((UnityEngine.Object)gameObject == (UnityEngine.Object)null))
            {
                return(gameObject.GetComponent <NetworkIdentity>());
            }
            if (LogFilter.logDebug)
            {
                Debug.Log((object)("ReadNetworkIdentity netId:" + (object)netId + "go: null"));
            }
            return((NetworkIdentity)null);
        }
Esempio n. 15
0
        /// <summary>
        ///   <para>Reads a reference to a Transform from the stream.</para>
        /// </summary>
        /// <returns>
        ///   <para>The transform object read.</para>
        /// </returns>
        public Transform ReadTransform()
        {
            NetworkInstanceId netId = this.ReadNetworkId();

            if (netId.IsEmpty())
            {
                return((Transform)null);
            }
            GameObject localObject = ClientScene.FindLocalObject(netId);

            if (!((UnityEngine.Object)localObject == (UnityEngine.Object)null))
            {
                return(localObject.transform);
            }
            if (LogFilter.logDebug)
            {
                Debug.Log((object)("ReadTransform netId:" + (object)netId));
            }
            return((Transform)null);
        }
Esempio n. 16
0
        protected void SetSyncVarGameObject(GameObject newGameObject, ref GameObject gameObjectField, uint dirtyBit, ref NetworkInstanceId netIdField)
        {
            if (this.m_SyncVarGuard)
            {
                return;
            }
            NetworkInstanceId networkInstanceId1 = new NetworkInstanceId();

            if ((UnityEngine.Object)newGameObject != (UnityEngine.Object)null)
            {
                NetworkIdentity component = newGameObject.GetComponent <NetworkIdentity>();
                if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                {
                    networkInstanceId1 = component.netId;
                    if (networkInstanceId1.IsEmpty() && LogFilter.logWarn)
                    {
                        Debug.LogWarning((object)("SetSyncVarGameObject GameObject " + (object)newGameObject + " has a zero netId. Maybe it is not spawned yet?"));
                    }
                }
            }
            NetworkInstanceId networkInstanceId2 = new NetworkInstanceId();

            if ((UnityEngine.Object)gameObjectField != (UnityEngine.Object)null)
            {
                networkInstanceId2 = gameObjectField.GetComponent <NetworkIdentity>().netId;
            }
            if (!(networkInstanceId1 != networkInstanceId2))
            {
                return;
            }
            if (LogFilter.logDev)
            {
                Debug.Log((object)("SetSyncVar GameObject " + this.GetType().Name + " bit [" + (object)dirtyBit + "] netfieldId:" + (object)networkInstanceId2 + "->" + (object)networkInstanceId1));
            }
            this.SetDirtyBit(dirtyBit);
            gameObjectField = newGameObject;
            netIdField      = networkInstanceId1;
        }
Esempio n. 17
0
        public GameObject ReadGameObject()
        {
            GameObject        obj2;
            NetworkInstanceId netId = this.ReadNetworkId();

            if (netId.IsEmpty())
            {
                return(null);
            }
            if (NetworkServer.active)
            {
                obj2 = NetworkServer.FindLocalObject(netId);
            }
            else
            {
                obj2 = ClientScene.FindLocalObject(netId);
            }
            if ((obj2 == null) && LogFilter.logDebug)
            {
                Debug.Log("ReadGameObject netId:" + netId + "go: null");
            }
            return(obj2);
        }
Esempio n. 18
0
        protected void SetSyncVarGameObject(GameObject newGameObject, ref GameObject gameObjectField, uint dirtyBit, ref NetworkInstanceId netIdField)
        {
            if (m_SyncVarGuard)
            {
                return;
            }
            NetworkInstanceId networkInstanceId = default(NetworkInstanceId);

            if (newGameObject != null)
            {
                NetworkIdentity component = newGameObject.GetComponent <NetworkIdentity>();
                if (component != null)
                {
                    networkInstanceId = component.netId;
                    if (networkInstanceId.IsEmpty() && LogFilter.logWarn)
                    {
                        Debug.LogWarning("SetSyncVarGameObject GameObject " + newGameObject + " has a zero netId. Maybe it is not spawned yet?");
                    }
                }
            }
            NetworkInstanceId networkInstanceId2 = default(NetworkInstanceId);

            if (gameObjectField != null)
            {
                networkInstanceId2 = gameObjectField.GetComponent <NetworkIdentity>().netId;
            }
            if (networkInstanceId != networkInstanceId2)
            {
                if (LogFilter.logDev)
                {
                    Debug.Log("SetSyncVar GameObject " + GetType().Name + " bit [" + dirtyBit + "] netfieldId:" + networkInstanceId2 + "->" + networkInstanceId);
                }
                SetDirtyBit(dirtyBit);
                gameObjectField = newGameObject;
                netIdField      = networkInstanceId;
            }
        }