コード例 #1
0
        private void UpdateWorldObjectState(StatefulWorldObject statefulWorldObject)
        {
            if (statefulWorldObject == null || !gameObjectIdToTransformMap.ContainsKey(statefulWorldObject.Id.Id))
            {
                return;
            }
            Transform transform = gameObjectIdToTransformMap[statefulWorldObject.Id.Id];

            if (!(transform != null))
            {
                return;
            }
            switch (statefulWorldObject.State)
            {
            case ScheduledWorldObjectState.Active:
            {
                StatefulWorldObjectMonobehaviour statefulWorldObjectMonobehaviour = transform.gameObject.GetComponent <StatefulWorldObjectMonobehaviour>();
                if (statefulWorldObjectMonobehaviour == null)
                {
                    statefulWorldObjectMonobehaviour = transform.gameObject.AddComponent <StatefulWorldObjectMonobehaviour>();
                }
                statefulWorldObjectMonobehaviour.StatefulWorldObject = statefulWorldObject;
                transform.gameObject.SetActive(value: true);
                break;
            }

            case ScheduledWorldObjectState.Inactive:
                transform.gameObject.SetActive(value: false);
                break;
            }
        }
コード例 #2
0
 public override void OnEnter()
 {
     if (base.Owner != null)
     {
         StatefulWorldObjectMonobehaviour component = base.Owner.GetComponent <StatefulWorldObjectMonobehaviour>();
         long gameTimeMilliseconds = Service.Get <INetworkServicesManager>().GameTimeMilliseconds;
         if (gameTimeMilliseconds != 0 && component != null && component.StatefulWorldObject != null && component.StatefulWorldObject.Timestamp != 0)
         {
             DateTime dateTime = gameTimeMilliseconds.MsToDateTime();
             TimeSpan timeSpan = dateTime - component.StatefulWorldObject.DateTime;
             time.Value -= (float)(timeSpan.TotalMilliseconds / 1000.0);
             if (time.Value < 0f)
             {
                 Abandon();
             }
             else
             {
                 base.OnEnter();
             }
         }
         else
         {
             Abandon();
         }
     }
     else
     {
         Abandon();
     }
 }