Exemplo n.º 1
0
        /// <summary>
        /// Setup object.
        /// </summary>
        /// <param name="type">Object type.</param>
        /// <param name="objectID">Object ID to assign.</param>
        /// <returns>Assigned Object ID</returns>
        public int Setup(ObjectSyncManager.ObjectTypes type, int objectID)
        {
            if (!NetWorld.Instance.playerIsLoading)
            {
                if (!NetManager.Instance.IsHost && objectID == ObjectSyncManager.AUTOMATIC_ID)
                {
                    Logger.Debug("Ignoring spawned object as client is not host!");
                    GameObject.Destroy(gameObject);
                    return(-1);
                }
            }
            IsSetup     = false;
            SyncEnabled = false;
            Owner       = null;
            ObjectType  = type;
            ObjectID    = objectID;

            // Assign object's ID.
            ObjectID = ObjectSyncManager.Instance.AddNewObject(this, ObjectID);

            if (!NetWorld.Instance.playerIsLoading && !IsSetup)
            {
                CreateObjectSubtype();
            }

            return(ObjectID);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Setup object.
        /// </summary>
        public void Setup(ObjectSyncManager.ObjectTypes type, int objectID)
        {
            if (!NetWorld.Instance.playerIsLoading)
            {
                if (!NetManager.Instance.IsHost && objectID == ObjectSyncManager.AUTOMATIC_ID)
                {
                    Logger.Debug("Ignoring spawned object as client is not host!");
                    GameObject.Destroy(gameObject);
                    return;
                }
            }
            Logger.Debug($"Sync component added to: {this.transform.name}");
            ObjectType = type;
            ObjectID   = objectID;

            // Assign object's ID.
            ObjectID = ObjectSyncManager.Instance.AddNewObject(this, ObjectID);

            if (!NetWorld.Instance.playerIsLoading && !isSetup)
            {
                CreateObjectSubtype();
            }
        }