public Substate Update(DateTime timestamp, int[] sliders) { Substate updated = Substate.None; if (_position.Count != sliders.Length) { _position = new List <int>(sliders); updated = Substate.Sliders; } else { for (int i = 0; i < sliders.Length; i++) { if (_position[i] != sliders[i]) { _position[i] = sliders[i]; updated = Substate.Sliders; } } } if (updated != Substate.None) { _timeStamp = timestamp; } return(updated); }
public virtual void SetRestingState(Substate newState) { // 1. Lock transitions. canTransition = false; // 2. Cleanup all the active Substates for (int i = pushdownStates.Count - 1; i >= 0; i--) { // Make sure exit state is called if (!pushdownStates[i].Interruptable) { pushdownStates[i].OnStateExit(this); } pushdownStates.RemoveAt(i); pushdownExpirationTimes.RemoveAt(i); } // 3. Set the resting state restingState = newState; // 4. Set the current finite state if (finiteState != null) { finiteState.OnStateExit(this); } finiteState = restingState; finiteState.OnStateEnter(this); transitionTime = SetTimer(finiteState); // 5. Unlock transitions canTransition = true; }
public Substate Update(DateTime timestamp, int[] povHats) { Substate updated = Substate.None; if (_direction.Count != povHats.Length) { _direction = new List <int>(povHats); updated = Substate.PovHats; } else { for (int i = 0; i < povHats.Length; i++) { if (_direction[i] != povHats[i]) { _direction[i] = povHats[i]; updated = Substate.PovHats; } } } if (updated != Substate.None) { _timeStamp = timestamp; } return(updated); }
/// <summary> /// Initializes a new instance of the <see cref="ActiveSubstateChangingEventArgs"/> class. /// </summary> /// <param name="substate">The substate.</param> /// <param name="newActiveStatusValue">New value of active status for the substate.</param> public ActiveSubstateChangingEventArgs(Substate substate, bool newActiveStatusValue) { Diagnostics.Assert.IsNotNull(substate, "substate"); this.substate = substate; this.newActiveStatusValue = newActiveStatusValue; }
internal void SetInitializedSubstate(ActivityExecutor executor) { this.substate = Substate.Initialized; if (executor.ShouldTrackActivityStateRecordsExecutingState && executor.ShouldTrackActivity(this.Activity.DisplayName)) { executor.AddTrackingRecord(new ActivityStateRecord(executor.WorkflowInstanceId, this, this.state)); } if ((this.Activity.RuntimeArguments.Count > 0) && TD.InArgumentBoundIsEnabled()) { for (int i = 0; i < this.Activity.RuntimeArguments.Count; i++) { Location location; RuntimeArgument argument = this.Activity.RuntimeArguments[i]; if (ArgumentDirectionHelper.IsIn(argument.Direction) && this.environment.TryGetLocation(argument.Id, this.Activity, out location)) { string str = null; if (location.Value == null) { str = "<Null>"; } else { str = "'" + location.Value.ToString() + "'"; } TD.InArgumentBound(argument.Name, this.Activity.GetType().ToString(), this.Activity.DisplayName, this.Id, str); } } } }
public void update(float deltaTime) { switch (m_substate) { case Substate.Static: break; case Substate.Moving: { m_previousPosition = transform.position; m_speed = m_speed * friction; Vector3 simulatedNextPosition = transform.position + m_speed * deltaTime; Vector3 error = m_wantedPosition - simulatedNextPosition; Vector3 acceleration = K * error / deltaTime; Vector3 nextSpeed = m_speed + acceleration; m_speed.x = Mathf.Clamp(nextSpeed.x, -m_maxSpeed, m_maxSpeed); m_speed.y = Mathf.Clamp(nextSpeed.y, -m_maxSpeed, m_maxSpeed); transform.position = transform.position + m_speed * deltaTime; } break; } m_substate = checkChangeState(); }
/// <summary> /// Processes the order. /// </summary> /// <param name="order">The order.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result.</returns> public override string ProcessOrder([NotNull] Order order, IDictionary <string, object> parameters) { Assert.IsNotNull(this.OrderManager, "OrderManager"); Assert.IsNotNullOrEmpty(this.OrderLineState, "OrderLineState"); Assert.ArgumentNotNull(order, "order"); Assert.IsTrue(order.State.Code == "In Process", "Unable to process order which is not in \"In Process\" state."); Assert.IsFalse(order.State.Substates.Single(substate => substate.Code == string.Format("{0} In Full", this.OrderLineState)).Active, string.Format("Unable to process order which is already in \"{0} In Full\" state.", this.OrderLineState)); Substate partialSubstate = order.State.Substates.SingleOrDefault(substate => substate.Code == string.Format("{0} Partially", this.OrderLineState)); if (partialSubstate != null) { partialSubstate.Active = false; } order.State.Substates.Single(substate => substate.Code == string.Format("{0} In Full", this.OrderLineState)).Active = true; foreach (OrderLine orderLine in order.OrderLines) { orderLine.LineItem.LineStatusCode = this.OrderLineState; } this.OrderManager.Save(order); this.StartOrderPackedPipeline(order); return(SuccessfulResult); }
public Substate Update(DateTime timestamp, bool[] buttons) { Substate updated = Substate.None; if (_pressed.Count != buttons.Length) { _pressed = new List <bool>(buttons); updated = Substate.Buttons; } else { for (int i = 0; i < buttons.Length; i++) { if (_pressed[i] != buttons[i]) { _pressed[i] = buttons[i]; updated = Substate.Buttons; } } } if (updated != Substate.None) { _timeStamp = timestamp; } return(updated); }
public void update(IScene scene,double dtArg) { DateTime now = DateTime.UtcNow; TimeSpan difference = now.Subtract(lastUpdate); double dt = difference.Milliseconds/1000.0; lastUpdate = now; IGameObject p; switch (topstate) { case TopState.NoTarget: p = scene.getObjectByTag (Protagonist.tag); if (null != p) { PointD target = ((Protagonist)p).getAchillesHeel (); model.hasTarget = true; model.target = target; topstate = TopState.HasTarget; substate = Substate.Init; handleHasTarget (dt); break; } handleNoTarget (dt); break; case TopState.HasTarget: handleHasTarget (dt); break; default: break; } }
public override void UpdateMovement() { if(!controller.isKnockbackActive) { if((controller.slots.input != null && controller.slots.input.isJumpButtonDown && !hasReleasedButtonSinceJump) || (currentJumpFrame < minFrames && isJumpActive)) { if(currentJumpFrame == 0) { jumpStartY = transform.position.y; //Just used for debugging } if(isJumpActive) //Continue a jump { currentJumpFrame ++; int totalJumpFrames = maxFrames; if(currentJumpFrame >= totalJumpFrames || controller.slots.physicsObject.DidHitCeilingThisFrame()) //The jump ends because we hit the max number of frames we allowed it { substate = Substate.Cresting; isJumpActive = false; if(!controller.slots.actor.IsAttacking() && controller.StateID() == id) { PlaySecondaryAnimation(animations.crestingJump); } controller.slots.actor.NotifyOfControllerJumpCresting(); float jumpHeight = Mathf.Abs(transform.position.y - jumpStartY); //Debug.Log("Position is: " + transform.position.y + " Jump height: " + jumpHeight); } else { controller.slots.physicsObject.AddVelocityForSingleFrame(new Vector2(0.0f, speed * controller.GravityScaleMultiplier())); } } } else //The jump ends because the input requesting the jump ended { if(isJumpActive) { substate = Substate.Cresting; isJumpActive = false; if(!controller.slots.actor.IsAttacking() && controller.StateID() == id) { PlaySecondaryAnimation(animations.crestingJump); } controller.slots.actor.NotifyOfControllerJumpCresting(); } } } else { currentJumpFrame = 0; isJumpActive = false; } }
/// <summary> /// Clones the specified substate. /// </summary> /// <param name="substate">The substate.</param> /// <returns>The cloned substate.</returns> public static Substate Clone(this Substate substate) { Diagnostics.Assert.IsNotNull(substate, "substate"); return(new Substate { Code = substate.Code, Name = substate.Name, Active = substate.Active, Abbreviation = substate.Abbreviation }); }
/// <summary> /// Initializes a new instance of the <see cref="SubstateControlDataBoundEventArgs"/> class. /// </summary> /// <param name="control">The control.</param> /// <param name="substate">The substate.</param> public SubstateControlDataBoundEventArgs(Control control, Substate substate) { Diagnostics.Assert.IsNotNull(control, "control"); Diagnostics.Assert.IsNotNull(substate, "substate"); this.control = control; this.substate = substate; }
public override void OnEnded() { substate = Substate.Stopped; controller.aerialPeak = transform.position.y; isClimbing = false; willAllowDirectionChange = true; controller.SetStateToDefault(); }
public override void OnEnter() { playerList = new List <NetworkIdentity>(); playerAcknowledgements = 0; substate = Substate.INITIALIZE; hasSentConfirmation = false; GameUtils.GetCardSelector().HideSelections(); }
internal bool ResolveArguments(ActivityExecutor executor, IDictionary <string, object> argumentValueOverrides, Location resultLocation, int startIndex = 0) { bool flag = true; if (this.Activity.SkipArgumentResolution) { using (ActivityContext context = executor.GetResolutionContext(this)) { RuntimeArgument resultRuntimeArgument = ((ActivityWithResult)this.Activity).ResultRuntimeArgument; if (!resultRuntimeArgument.TryPopulateValue(this.environment, this, context, null, resultLocation, false)) { flag = false; Location specificLocation = this.environment.GetSpecificLocation(resultRuntimeArgument.Id); executor.ScheduleExpression(resultRuntimeArgument.BoundArgument.Expression, this, context.Environment, specificLocation.CreateReference(true)); } goto Label_0166; } } IList <RuntimeArgument> runtimeArguments = this.Activity.RuntimeArguments; int count = runtimeArguments.Count; if (count > 0) { using (ActivityContext context2 = executor.GetResolutionContext(this)) { for (int i = startIndex; i < count; i++) { RuntimeArgument argument2 = runtimeArguments[i]; object obj2 = null; if (argumentValueOverrides != null) { argumentValueOverrides.TryGetValue(argument2.Name, out obj2); } if (!argument2.TryPopulateValue(this.environment, this, context2, obj2, resultLocation, false)) { flag = false; int nextArgumentIndex = i + 1; if (nextArgumentIndex < runtimeArguments.Count) { ResolveNextArgumentWorkItem workItem = executor.ResolveNextArgumentWorkItemPool.Acquire(); workItem.Initialize(this, nextArgumentIndex, argumentValueOverrides, resultLocation); executor.ScheduleItem(workItem); } Location location2 = this.environment.GetSpecificLocation(argument2.Id); executor.ScheduleExpression(argument2.BoundArgument.Expression, this, context2.Environment, location2.CreateReference(true)); goto Label_0166; } } } } Label_0166: if (flag && (startIndex == 0)) { this.substate = Substate.ResolvingVariables; } return(flag); }
/// <summary> /// Maps the specified source. /// </summary> /// <param name="source">The source.</param> /// <param name="destination">The destination.</param> private void Map([NotNull] Sitecore.Data.Items.Item source, [NotNull] Substate destination) { Debug.ArgumentNotNull(source, "source"); Debug.ArgumentNotNull(destination, "destination"); destination.Code = source.Fields[CodeFieldName].Value; destination.Name = source.Fields[NameFieldName].Value; destination.Abbreviation = source.Fields[AbbreviationFieldName].Value; }
// Transition from the current finite state to a new one, calling OnStateEnter protected void TransitionState(Substate newState) { // 1. Call exit function of current state finiteState.OnStateExit(this); // 2. Set the new current state. finiteState = Instantiate(newState); finiteState.OnStateEnter(this); transitionTime = SetTimer(newState); }
/// <summary> /// Initializes a new instance of the <see cref="OrderStateListViewSubstateCreatedEventArgs"/> class. /// </summary> /// <param name="state">The state.</param> /// <param name="substate">The substate.</param> public OrderStateListViewSubstateCreatedEventArgs([NotNull] State state, [NotNull] Substate substate) { Assert.ArgumentNotNull(state, "state"); Assert.ArgumentNotNull(substate, "substate"); this.state = state; this.substate = substate; this.Enabled = true; }
/// <summary> /// Reverts the order states. /// </summary> /// <param name="order">The order.</param> protected virtual void RevertOrderStates([NotNull] Order order) { Assert.ArgumentNotNull(order, "order"); Assert.IsNotNull(order.State, "order.State cannot be null."); Assert.IsTrue(order.State.Code == InProcessStateCode, "Unable to revert order which is not in \"In Process\" state."); Substate capturedInFullSubstate = order.State.Substates.Single(substate => substate.Code == CapturedInFullSubstateCode); capturedInFullSubstate.Active = false; }
public override void UpdateMovement() { if (isClimbing) { controller.slots.physicsObject.FreezeGravityForSingleFrame(); controller.slots.physicsObject.SetVelocityX(0.0f); controller.slots.physicsObject.FreezeXMovementForSingleFrame(); } if (isTouching) { if (isClimbing) { controller.slots.actor.SetPosition(new Vector2(activeLadderXPosition, transform.position.y)); controller.slots.physicsObject.SetVelocityY(climbSpeed * (int)controller.axis.y * controller.GravityScaleMultiplier()); bool isAtLadderCrest = (controller.GravityScaleMultiplier() > 0.0f) ? transform.position.y >= activeLadderTopCrestPosition : transform.position.y <= activeLadderBottomCrestPosition; if (isAtLadderCrest) { if (substate != Substate.Cresting && !controller.slots.actor.currentAttack) { PlaySecondaryAnimation(animations.cresting); } substate = Substate.Cresting; } else if ((int)controller.axis.y != 0.0f) { if (substate != Substate.Moving && !controller.slots.actor.currentAttack) { PlaySecondaryAnimation(animations.moving); } substate = Substate.Moving; } else { if (substate != Substate.Stopped && !controller.slots.actor.currentAttack) { PlayAnimation(); } substate = Substate.Stopped; } if (controller.slots.actor.currentAttack) { substate = Substate.Attacking; } } } }
void Update() { if (!IsFrozen() && isEnabled && controller.isEnabled) { if (controller.axis.y == -1.0f) { if (controller.slots.physicsObject.IsOnSurface() && controller.StateID() != LadderState.idString && controller.StateID() != JumpState.idString && controller.StateID() != KnockbackState.idString) { Begin(); } } else if (controller.currentState == this) { if (CanExitCrouch()) { if (willRiseWithButtonRelease) { ExitCrouch(); } else if (controller.axis.y == 1.0f) { ExitCrouch(); } } } if (controller.currentState == this) { if (canMove && Mathf.Abs(controller.slots.physicsObject.properties.velocity.x) > 0.0f) { if (substate != Substate.Moving) { substate = Substate.Moving; PlaySecondaryAnimation(movingAnimation); } } else { if (substate != Substate.Stopped) { substate = Substate.Stopped; PlayAnimation(); } } if (controller.axis.x == 0.0f) { hasPlayerReleasedHorizontal = true; } } } }
/// <summary> /// Handles the OnDataBinding event of the Substate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void Substate_OnDataBinding(object sender, System.EventArgs e) { System.Web.UI.WebControls.CheckBox substateCheckBox = (System.Web.UI.WebControls.CheckBox)sender; Substate dataItem = (Substate)this.Page.GetDataItem(); substateCheckBox.ID = dataItem.Code; substateCheckBox.Checked = dataItem.Active; substateCheckBox.Text = dataItem.Name; this.RegisterSubstateUpdateDependency(substateCheckBox); this.OnSubstateControlDataBound(new SubstateControlDataBoundEventArgs(substateCheckBox, dataItem)); }
void Start() { startTime = Time.time; loadScene(); initScene(); _substate = Substate.WaitForStart; PauseCanvas.enabled = false; PersistentData.nbPlayer = 2; }
public Substate Update(DateTime timestamp, input.JoystickState state) { _timeStamp = timestamp; Substate updated = Substate.None; updated |= _axes.Update(timestamp, state); updated |= _buttons.Update(timestamp, state.Buttons); updated |= _sliders.Update(timestamp, state.Sliders); updated |= _povHats.Update(timestamp, state.PovHats); return(updated); }
private void StateChanged() { _lastState = _menuState; _selector.Position = new Vector2(2, 34 + (int)_menuState * 16); _substate = _menuState switch { MenuState.Save1 => files[0], MenuState.Save2 => files[1], MenuState.Save3 => files[2], MenuState.Settings => new ConfigSubstate(true), _ => new Substate(), }; }
// Reset the time to live of the given state. Does NOT call OnStateEnter, as the state is already present. protected void RefreshState(Substate newState) { if (newState.IsFinite) { transitionTime = SetTimer(newState); } else { int stateIndex = pushdownStates.FindIndex(newState.Equals); // Debug.Log(newState + " found at index " + stateIndex); pushdownExpirationTimes[stateIndex] = SetTimer(newState); } }
public virtual void AddSubstate(Substate newState) { // Add the new state if it's not in the list if (!pushdownStates.Contains(newState)) { pushdownStates.Add(newState); pushdownExpirationTimes.Add(SetTimer(newState)); newState.OnStateEnter(this); } else { // Refresh the state if it's found in the list. RefreshState(newState); } }
/// <summary> /// Sets the order states. /// </summary> /// <param name="order">The order.</param> protected virtual void SetOrderStates([NotNull] Order order) { Assert.IsNotNull(order, "order"); Assert.IsNotNull(order.State, "order.State cannot be null."); Assert.IsTrue(order.State.Code == InProcessStateCode, "Unable to capture order which is not in \"In Process\" state."); Substate capturedInFullSubstate = order.State.Substates.Single(substate => substate.Code == CapturedInFullSubstateCode); capturedInFullSubstate.Active = true; foreach (OrderLine orderLine in order.OrderLines) { orderLine.LineItem.LineStatusCode = CapturedCode; } }
void SetSubstate(Substate newSubstate) { currentTimer = 0; substate = newSubstate; switch (substate) { case Substate.idle: break; case Substate.walkingToTarget: break; case Substate.waitingAtNode: break; } }
void Start() { startTime = Time.time; nbWaves = 0; loadScene(); initScene(); _substate = Substate.WaitForStart; timeAttack = Time.time; timeBeforeNextAttack = 10.0f; PauseCanvas.enabled = false; PersistentData.nbPlayer = 1; }
public void SetSubstate(Substate newSubstate) { substate = newSubstate; currentTimer = 0; switch (substate) { case Substate.chasing: agent.navAgent.SetTarget(agent.target, chaseSpeed, shootingRange); break; case Substate.preparingFire: break; case Substate.fireDelay: break; } }
void handleHasTarget(double dt) { double dv; Point target; Point direction; double temp; switch (substate){ case Substate.Init: if (Math.Abs (ang_v) < ang_v_max) { ang_v = ang_v - dt * ang_a; } dv = dt * ang_v; rotate (dv); Tuple<PointD,PointD,PointD,PointD> points = model.getSharpestPointAndAssociatedMidpointAndDullestPoints (); PointD sharpest = points.Item1; PointD mid = points.Item2; const double tolArea = 300; target = model.target; double area = Math.Abs(Geometry.ComputationalGeometry.Area2 (mid, sharpest, target)); if (area < tolArea) { PointD dull1 = points.Item3; PointD dull2 = points.Item4; double sharpDist = PointUtils.SquaredDistance (sharpest,target); if ((sharpDist < PointUtils.SquaredDistance (dull1, target)) && (sharpDist < PointUtils.SquaredDistance (dull2, target))) { substate = Substate.Dec; decDistance = 0; } } break; case Substate.Dec: if (Math.Abs(decDistance) >= maxDecDistance) { substate = Substate.Acc; break; } const double v = 35; target = model.target; direction = PointUtils.GetNormalizedDirectionVector (model.tri.avgPoint (), target); double d = v * dt; decDistance += d; PointUtils.ScalePointIP (ref direction, -1*d); model.tri.Translate (direction); break; case Substate.Acc: const double tolDist = 10; // Check if happened to bump into protagonist IGameObject go = scene.getObjectByTag (Protagonist.tag); if (null != go) { Protagonist p = (Protagonist)go; if (PointUtils.Distance (p.position, model.tri.avgPoint()) < tolDist) { p.hit (); substate = Substate.Die; break; } } // Check if reached target target = model.target; Point tripos = model.tri.avgPoint (); if (PointUtils.Distance(target,tripos) <= tolDist) { substate = Substate.Die; break; } // Speed along const double v2 = 350; direction = PointUtils.GetNormalizedDirectionVector (tripos, target); temp = v2 * dt; PointUtils.ScalePointIP (ref direction, temp); model.tri.Translate (direction); break; case Substate.Die: scene.removeGameObject (model); break; default: Logger.Log ("default case reached"); break; } }
void handleNoTarget(double dt) { double dv; switch (substate){ case Substate.Dec: ang_v = ang_v - dt * ang_a; if (ang_v <= -1*ang_v_max) { substate = Substate.Acc; } else { dv = dt * ang_v; rotate (dv); } break; case Substate.Acc: ang_v = ang_v + dt * ang_a; if (ang_v >= ang_v_max) { substate = Substate.Dec; } else { dv = dt * ang_v; rotate (dv); } break; default: Logger.Log ("default case reached"); break; } }
/// <summary> /// Initializes a new instance of the <see cref="ActiveSubstateChangedEventArgs"/> class. /// </summary> /// <param name="substate">The substate.</param> public ActiveSubstateChangedEventArgs(Substate substate) { Diagnostics.Assert.IsNotNull(substate, "substate"); this.substate = substate; }
/// <summary> /// Equalses the specified substate1. /// </summary> /// <param name="substate1">The substate1.</param> /// <param name="substate2">The substate2.</param> /// <returns>The boolean.</returns> public static bool EqualsTo(this Substate substate1, Substate substate2) { if (ReferenceEquals(substate1, substate2)) { return true; } if ((substate1 == null) ^ (substate2 == null)) { return false; } if (substate1.Code != substate2.Code) { return false; } if (substate1.Active != substate2.Active) { return false; } return true; }
public static Substate CreateSubstate(global::System.Collections.ObjectModel.ObservableCollection<VMRoleMessage> vMRoleMessages) { Substate substate = new Substate(); if ((vMRoleMessages == null)) { throw new global::System.ArgumentNullException("vMRoleMessages"); } substate.VMRoleMessages = vMRoleMessages; return substate; }
/// <summary> /// Maps the specified source. /// </summary> /// <param name="source">The source.</param> /// <param name="destination">The destination.</param> private void Map([NotNull] Sitecore.Data.Items.Item source, [NotNull] State destination) { Debug.ArgumentNotNull(source, "source"); Debug.ArgumentNotNull(destination, "destination"); destination.Code = source.Fields[CodeFieldName].Value; destination.Name = source.Fields[NameFieldName].Value; destination.Substates.Clear(); Sitecore.Data.Items.Item[] substateItems = source.Axes.SelectItems(string.Format("./{0}/*", SubstateContainerName)); if (substateItems != null) { foreach (Sitecore.Data.Items.Item item in substateItems) { Substate substate = new Substate(); this.Map(item, substate); destination.Substates.Add(substate); } } }
partial void OnSubstateChanging(Substate value);