예제 #1
0
        /** Advances all objects by a certain time (in seconds). */
        public void tick()
        {
            int numObjects = mObjects.Count;
            //int currentIndex = 0;
            int i;

            mElapsedTime += Time.deltaTime;
            if (numObjects == 0)
            {
                return;
            }

            // there is a high probability that the "advanceTime" function modifies the list
            // of animatables. we must not process new objects right now (they will be processed
            // in the next frame), and we need to clean up any empty slots in the list.

            for (i = 0; i < numObjects; ++i)
            {
                ITickable obj = mObjects[i];
                if (obj != null)
                {
                    obj.tick();
                    //++currentIndex;
                }
            }
        }
예제 #2
0
        ///---------------------------------------------------------------------
        internal static void Register(ITickable tickable)
        {
            var aliveTickable = new AliveTickable(tickable);

            Instance.pendingRegistry.Add(aliveTickable);
            Instance.allTickables.Add(aliveTickable);
        }
예제 #3
0
        public void RemoveTask(ITickable task)
        {
            var info = _sortedTasks.Concat(_unsortedTasks).Where(x => x.Tickable == task).Single();

            Assert.That(!info.IsRemoved, "Tried to remove task twice, task = " + task.GetType().Name);
            info.IsRemoved = true;
        }
예제 #4
0
        static void Prefix(ref ITickable __state)
        {
            if (Multiplayer.Client == null)
            {
                return;
            }
            if (!WorldRendererUtility.WorldRenderedNow && Find.CurrentMap == null)
            {
                return;
            }

            ITickable tickable = Multiplayer.WorldComp;

            if (!WorldRendererUtility.WorldRenderedNow && Multiplayer.WorldComp.asyncTime)
            {
                tickable = Find.CurrentMap.AsyncTime();
            }

            TimeSpeed speed = tickable.TimeSpeed;

            if (Multiplayer.IsReplay)
            {
                speed = TickPatch.replayTimeSpeed;
            }

            savedSpeed = Find.TickManager.CurTimeSpeed;

            Find.TickManager.CurTimeSpeed = speed;
            prevSpeed  = speed;
            keyPressed = Event.current.isKey;
            __state    = tickable;
        }
예제 #5
0
        public static void Register(ITickable task, UpdateType updateType = UpdateType.normal)
        {
            // be assure instance exist
            Checkinstance();
            var ableTask = Tasks.Find(x => x.InstanceId() == task.InstanceId() && x.InstanceId() != 0);

            if (ableTask != null)
            {
                switch (ableTask)
                {
                case MoveTask move:
                    move.Join(((MoveTask)task).CurrentData); break;

                case DirectionTask drecTask:
                    drecTask.Join(((DirectionTask)task).CurrentData); break;

                case UpdateTask updateTask:
                    Debug2.Log("update task exist it will add in queue");
                    updateTask.Join(((UpdateTask)task).currentData); break;
                }
            }
            else
            {
                if (updateType == UpdateType.normal)
                {
                    Tasks.Add(task);
                }
                else if (updateType == UpdateType.fixedTime)
                {
                    FixedTasks.Add(task);
                }
            }
        }
예제 #6
0
        public void RemoveTask(ITickable task)
        {
            var info = _tasks.Where(i => ReferenceEquals(i.Tickable, task)).Single();

            Assert.That(!info.IsRemoved, "Tried to remove task twice, task = " + task.GetType().Name);
            info.IsRemoved = true;
        }
예제 #7
0
 void UpdateTickable(ITickable tickable)
 {
     //using (ProfileBlock.Start("{0}.Tick()".With(tickable.GetType().Name())))
     {
         tickable.Tick();
     }
 }
예제 #8
0
        public CameraManager(IResourcesManager resourcesManager, ITickable tickable)
        {
            _resourcesManager = resourcesManager;
#if UNITY_EDITOR
            tickable.SecondTick += OnTick;
#endif
        }
예제 #9
0
        public void DeRegister(ITickable tickable)
        {
            Debug.Assert(tickable == null,
                         "Trying to deregister a tickable that is null!");

            toDeregister.Add(tickable);
        }
예제 #10
0
 /// <summary>
 /// Remove a previously added tickable (if you don't want to bother returning
 /// "true" when something is finished)
 /// </summary>
 /// <param name="tickable"></param>
 public static void RemoveTickable(ITickable tickable)
 {
     if (instance.yieldInstructions.Remove(tickable) == false)
     {
         throw new InvalidOperationException("Cannot remove something that was not added");
     }
 }
예제 #11
0
 public void Register(ITickable tickable)
 {
     if (!this.tickables.Contains(tickable))
     {
         this.tickables.Add(tickable);
     }
 }
예제 #12
0
 private void evalSubscribed()
 {
     for (int i = 0; i < subscribed.Count; i += 1)
     {
         ITickable subscriber = subscribed [i];
         subscriber.discreteUpdate();
     }
 }
예제 #13
0
 public static float TimePerTick(this ITickable tickable, TimeSpeed speed)
 {
     if (tickable.ActualRateMultiplier(speed) == 0f)
     {
         return(0f);
     }
     return(1f / tickable.ActualRateMultiplier(speed));
 }
예제 #14
0
 public void SetProperties(ITickable tickable, float tickTime)
 {
     this.tickable   = tickable;
     this.tickTime   = tickTime;
     this.ticks      = 0;
     this.infinite   = true;
     currentTickTime = 0;
 }
예제 #15
0
 public void RegisterTickable(ITickable tickable)
 {
     if (_tickables.Contains(tickable))
     {
         return;
     }
     _tickables.Add(tickable);
 }
예제 #16
0
 /// <summary>
 /// Removes this ITickable from TickableManager
 /// </summary>
 /// <param name="tickable">Tickable.</param>
 protected virtual void RemoveTickable(ITickable tickable)
 {
     _tManager.Remove(tickable);
     Publish(new Service.GlobalNetwork.Commands.RemoveTickableCommand()
     {
         tickable = this
     });
 }
예제 #17
0
 public void Start(ITickable handler)
 {
     for (int i = 0; i < 11; ++i)
     {
         handler.TimeChanged(i);
         System.Threading.Thread.Sleep(1000);
     }
 }
예제 #18
0
 public void SetProperties(ITickable tickable, float tickTime, int ticks)
 {
     this.tickable   = tickable;
     this.tickTime   = tickTime;
     this.ticks      = ticks;
     this.infinite   = false;
     currentTickTime = 0;
 }
예제 #19
0
 public static void Join(ITickable obj)
 {
     if (objectsToTick == null)
     {
         objectsToTick = new List <ITickable>();
     }
     objectsToTick.Add(obj);
 }
예제 #20
0
        void UpdateTickable(ITickable tickable)
        {
#if PROFILING_ENABLED
            using (ProfileBlock.Start("{0}.Tick()".Fmt(tickable.GetType().Name())))
#endif
            {
                tickable.Tick();
            }
        }
예제 #21
0
        //protected override void Dispose(bool disposing)
        //{
        //    if (isDisposed) return;
        //    if (disposing)
        //    {
        //    }
        //
        //    isDisposed = true;
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="totalTime"></param>
        /// <param name="elapsedTime"></param>
        /// <remarks>Do not access this Method directly. Only AetherEngine should call it during the game loop.</remarks>
        /// <permission cref=""></permission>
        public override void Tick(GameTime gameTime)
        {
            ITickable tickableRoot = Root as ITickable;

            if (tickableRoot != null)
            {
                tickableRoot.Tick(gameTime);
            }
        }
예제 #22
0
    public void Unregister(ITickable tickable)
    {
        List <ITickable> obj = this.tickables;

        lock (obj)
        {
            this.tickables.RemoveAll((ITickable match) => match == tickable);
        }
    }
예제 #23
0
        public static float ActualRateMultiplier(this ITickable tickable, TimeSpeed speed)
        {
            if (Multiplayer.WorldComp.asyncTime)
            {
                return(tickable.TickRateMultiplier(speed));
            }

            return(Find.Maps.Select(m => (ITickable)m.AsyncTime()).Concat(Multiplayer.WorldComp).Select(t => t.TickRateMultiplier(speed)).Min());
        }
예제 #24
0
        public static int CreateStream(ITickable world)
        {
            Thread thread    = new Thread(new ParameterizedThreadStart(Tick));
            var    threadId  = thread.ManagedThreadId;
            var    container = new ThreadContainer(thread, world, true);

            IdOfThreads.TryAdd(threadId, container);//добавил в словарь
            thread.Start(container);
            return(threadId);
        }
예제 #25
0
        public void AddTask(ITickable task)
        {
            Assert.That(!_queuedTasks.Contains(task), "Duplicate task added to kernel with name '" + task.GetType().FullName + "'");
            Assert.That(!_tasks.Any(t => ReferenceEquals(t.Tickable, task)), "Duplicate task added to kernel with name '" + task.GetType().FullName + "'");

            // Wait until next frame to add the task, otherwise whether it gets updated
            // on the current frame depends on where in the update order it was added
            // from, so you might get off by one frame issues
            _queuedTasks.Add(task);
        }
예제 #26
0
        private void DestroyScene()
        {
            if (m_controller != null)
            {
                m_controller.Dispose();
                m_controller = null;
            }

            m_tickController = null;
        }
예제 #27
0
        static bool Prefix(ref float __result, ITickable tickable, TimeSpeed speed)
        {
            if (MultiplayerWorldComp.asyncTime)
            {
                __result = tickable.TickRateMultiplier(speed) / RefcellRespeedConfig.currentTimeMultiplier;
                return(false);
            }

            __result = Find.Maps.Select(m => (ITickable)m.AsyncTime()).Concat(Multiplayer.Client.Multiplayer.WorldComp).Select(t => t.TickRateMultiplier(speed)).Min() / RefcellRespeedConfig.currentTimeMultiplier;
            return(false);
        }
예제 #28
0
 private void Update()
 {
     using (List <ITickable> .Enumerator enumerator = this._ticked.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             ITickable current = enumerator.get_Current();
             current.Tick(Time.get_deltaTime());
         }
     }
 }
예제 #29
0
 public static void SendTimeChange(ITickable tickable, TimeSpeed newSpeed)
 {
     if (tickable is MultiplayerWorldComp)
     {
         Multiplayer.Client.SendCommand(CommandType.WorldTimeSpeed, ScheduledCommand.Global, (byte)newSpeed);
     }
     else if (tickable is MapAsyncTimeComp comp)
     {
         Multiplayer.Client.SendCommand(CommandType.MapTimeSpeed, comp.map.uniqueID, (byte)newSpeed);
     }
 }
예제 #30
0
        void AddTaskInternal(ITickable task, int?priority)
        {
            Assert.That(!AllTasks.Select(x => x.Tickable).Contains(task),
                        "Duplicate task added to kernel with name '" + task.GetType().FullName + "'");

            // Wait until next frame to add the task, otherwise whether it gets updated
            // on the current frame depends on where in the update order it was added
            // from, so you might get off by one frame issues
            _queuedTasks.Add(
                new TickableInfo(task, priority));
        }
 public void Remove(ITickable component)
 {
     if (_componentsList.Contains(component))
     {
         _componentsList[_componentsList.IndexOf(component)] = null;
     }
     else if (_addList.Contains(component))
     {
         _addList.Remove(component);
     }
     //_componentsList.Remove(component);  //This not allow use Remove on Tick
 }
예제 #32
0
        public static bool AddAntTick(ITickable ticker, UpdateType type = UpdateType.Update)
        {
            if (ticker == null)
            {
                return(false);
            }

            bool b = Add(ticker.tick, type);

            ticker.tick(0);
            return(b);
        }
예제 #33
0
        void AddTaskInternal(ITickable task, int? priority)
        {
            Assert.That(!AllTasks.Select(x => x.Tickable).Contains(task),
                "Duplicate task added to kernel with name '" + task.GetType().FullName + "'");

            // Wait until next frame to add the task, otherwise whether it gets updated
            // on the current frame depends on where in the update order it was added
            // from, so you might get off by one frame issues
            _queuedTasks.Add(
                new TickableInfo(task, priority));
        }
예제 #34
0
 public TickableInfo(ITickable tickable, int? priority)
 {
     Tickable = tickable;
     Priority = priority;
 }
예제 #35
0
 public TickableInfo(ITickable tickable)
     : this(tickable, null)
 {
 }
예제 #36
0
 /// <summary>
 /// Convienance function to add an ITickable object into the tick
 /// manager.
 /// </summary>
 public void Add(ITickable tickable)
 {
     TickEvent += new TickHandler(tickable.OnTick);
 }
예제 #37
0
 public void Add(ITickable tickable, int priority)
 {
     _updater.AddTask(tickable, priority);
 }
예제 #38
0
        void InsertTaskSorted(ITickable task)
        {
            var newInfo = new TickableInfo(task);

            for (var current = _tasks.First; current != null; current = current.Next)
            {
                if (current.Value.Tickable.TickPriority > task.TickPriority)
                {
                    _tasks.AddBefore(current, newInfo);
                    return;
                }
            }

            _tasks.AddLast(newInfo);
        }
예제 #39
0
 public void AddTask(ITickable task)
 {
     _impl.AddTask(task);
 }
예제 #40
0
 public void Remove(ITickable tickable)
 {
     _updater.RemoveTask(tickable);
 }
예제 #41
0
        public void RemoveTask(ITickable task)
        {
            var info = _sortedTasks.Concat(_unsortedTasks).Where(x => x.Tickable == task).Single();

            Assert.That(!info.IsRemoved, "Tried to remove task twice, task = " + task.GetType().Name);
            info.IsRemoved = true;
        }
예제 #42
0
 internal void Add(ITickable tickable)
 {
     _ticked.Add(tickable);
 }
예제 #43
0
 void UpdateTickable(ITickable tickable)
 {
     #if PROFILING_ENABLED
     using (ProfileBlock.Start("{0}.Tick()".Fmt(tickable.GetType().Name())))
     #endif
     {
         tickable.Tick();
     }
 }
예제 #44
0
 internal void Remove(ITickable tickable)
 {
     _ticked.Remove(tickable);
 }
예제 #45
0
파일: Loop.cs 프로젝트: CedricHanebaum/Dame
 public void addToUpdateList(ITickable t)
 {
     updateList.Add(t);
 }
예제 #46
0
 public void AddTask(ITickable task)
 {
     AddTaskInternal(task, null);
 }
예제 #47
0
 public void Add(ITickable tickable)
 {
     Add(tickable, 0);
 }
예제 #48
0
 void UpdateTickable(ITickable tickable)
 {
     using (ProfileBlock.Start("{0}.Tick()".Fmt(tickable.GetType().Name())))
     {
         tickable.Tick();
     }
 }
	public void Add(ITickable tickable)
	{
		_ticker.Add(tickable);
	}
예제 #50
0
 public void AddTask(ITickable task, int priority)
 {
     AddTaskInternal(task, priority);
 }
예제 #51
0
 public void RemoveTask(ITickable task)
 {
     _impl.RemoveTask(task);
 }
예제 #52
0
 public TickableInfo(ITickable tickable)
 {
     Tickable = tickable;
 }