public void BreakLocationsCompareEqualityByValue() { var loc1 = new BreakLocation(42, 23); var loc2 = new BreakLocation(42, 23); var loc3 = new BreakLocation(17, 7); Assert.Equal(loc1, loc2); Assert.True(loc1 == loc2); Assert.True(loc2 != loc3); Assert.False(loc1 != loc2); Assert.False(loc2 == loc3); }
public void BreakLocationsWithSourceCompareEqualityByValue() { var loc1 = new BreakLocation("script1", 42, 23); var loc2 = new BreakLocation("script1", 42, 23); var loc3 = new BreakLocation("script2", 42, 23); Assert.Equal(loc1, loc2); Assert.True(loc1 == loc2); Assert.True(loc2 != loc3); Assert.False(loc1 != loc2); Assert.False(loc2 == loc3); }
public void SetStressLevel(float stressLevel, EmployeeState employeeState, BreakLocation assignedBreakLocation) { if (employeeState == EmployeeState.Break && assignedBreakLocation?.LocationName == "Toilet") { renderer.sprite = silly; } else { var sprite = GetSprite(stressLevel); renderer.sprite = sprite; } }
public void BreakLocationsOptionalSourceEqualityComparer() { var script1 = new BreakLocation("script1", 42, 23); var script2 = new BreakLocation("script2", 42, 23); var script2b = new BreakLocation("script2", 44, 23); var any = new BreakLocation(null, 42, 23); var comparer = new OptionalSourceBreakLocationEqualityComparer(); Assert.True(comparer.Equals(script1, any)); Assert.True(comparer.Equals(script2, any)); Assert.False(comparer.Equals(script1, script2)); Assert.False(comparer.Equals(script2, script2b)); Assert.Equal(comparer.GetHashCode(script1), comparer.GetHashCode(any)); Assert.Equal(comparer.GetHashCode(script1), comparer.GetHashCode(script2)); Assert.NotEqual(comparer.GetHashCode(script2), comparer.GetHashCode(script2b)); }
private void CheckBreakPointAndPause(BreakLocation breakLocation, Node node = null, Location?location = null, JsValue returnValue = null) { CurrentLocation = location ?? node?.Location; BreakPoint breakpoint = BreakPoints.FindMatch(this, breakLocation); bool isStepping = _engine.CallStack.Count <= _steppingDepth; if (breakpoint != null || isStepping) { // Even if we matched a breakpoint, if we're stepping, the reason we're pausing is the step. // Still, we need to include the breakpoint at this location, in case the debugger UI needs to update // e.g. a hit count. Pause(isStepping ? PauseType.Step : PauseType.Break, node, location, returnValue, breakpoint); } _paused = false; }
// Should be called externally - after giving a command to a group of employees public void AssignToBreakLocation(BreakLocation breakLocation, Action locationReached = null) { RemoveFromAssignedBreakLocation(); var slot = breakLocation.AssignEmployeeToFreeSlot(this); if (slot != null) { AssignedBreakLocation = breakLocation; SetState(EmployeeState.Walking); // TODO only move if the employee is not there already var movementTarget = slot.Target; movementController.SetMovementTarget(movementTarget, () => { SetState(EmployeeState.Break); locationReached?.Invoke(); }); } }
public BreakPoint(string?source, int line, int column, string?condition = null) { Location = new BreakLocation(source, line, column); Condition = condition; }
public void SendOnVacation(BreakLocation vacation) { AssignToBreakLocation(vacation, () => { StartCoroutine(DisappearForVacation()); }); }