public static void Unregister(this IStepableEvent stepEvent, IStepable stepable) { stepEvent.PreStep -= stepable.PreStep; stepEvent.PostStep -= stepable.PostStep; stepEvent.Step -= stepable.Step; stepEvent.PhysicsStep -= stepable.PhysicsStep; }
/// <summary> /// perform enqueued task (i.e. calculating image) /// </summary> public void DoWork() { models.Progress.IsProcessing = true; Debug.Assert(currentWork != null); // advance the first stepable if (currentWork.HasStep()) { currentWork.NextStep(); } if (!currentWork.HasStep()) { // remove this element currentWork = null; if (!HasWork()) { models.Progress.IsProcessing = false; } } else { // report progress models.Progress.What = currentWork.GetDescription(); models.Progress.Progress = (float)currentWork.CurrentStep() / currentWork.GetNumSteps(); } }
public void StepGround(IStepable stepable) { GravityValue = 0; RectTransform pt = gameObject.transform as RectTransform; Vector2 stepPosition = stepable.CalcStepPoint(pt as RectTransform); pt.position = stepPosition; MoveVector = stepable.CalcMoveVector(pt, MaxSpeed); }
/// <summary> /// true if DoWork should be called to perform some work /// </summary> /// <returns></returns> public bool HasWork() { if (currentWork != null) { return(true); } // check if the other controllers have something foreach (var ctrl in imageController) { currentWork = ctrl.GetWork(); if (currentWork != null) { return(true); } } return(false); }
public void RemoveSteppable(IStepable steppable) => this.Unregister(steppable);
public void AddSteppable(IStepable steppable) => this.Register(steppable);
/// <summary> /// Удалить обьект из мира. /// </summary> /// <param name="obj">Удаляемый обьект.</param> public void RemoveObject(IStepable obj) { currentWorld.Remove(obj); }
/// <summary> /// Добавить новый обьект в текущий мир. /// </summary> /// <param name="obj">Добавляемый обьект.</param> public void AddObject(IStepable obj) { currentWorld.Add(obj); }
public static void Unregister(this IStepable stepable, IStepableEvent stepEvent) => stepEvent.Unregister(stepable);