public void CanReadUninitializedStringArrayVariable() { var variable = new Variable("A$", new short[] { 5, 5 }); var sut = new VariableReference(variable, new short[] { 3, 3 }); Assert.AreEqual(string.Empty, sut.GetValue().ValueAsString()); }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (variables.This is Mover target) { if (Target.GetValue(variables).TryGetObject(out Mover toward)) { var dir = toward.CurrentGridPosition - target.CurrentGridPosition; var direction = Direction.GetDirection(dir.x, dir.y); target.FaceDirection(direction); } else { Debug.LogWarningFormat(this, _moverTowardNotFoundWarning, Name, Target); } } else { Debug.LogWarningFormat(this, _moverNotFoundWarning, Name); } graph.GoTo(Next, variables.This, nameof(Next)); yield break; }
public void CanWriteAndReadToShortArrayVariable() { var variable = new Variable("A%", new short[] { 6, 6 }); var sut = new VariableReference(variable, new short[] { 2, 2 }); sut.SetValue(new Accumulator(-3000.0)); Assert.AreEqual(-3000, sut.GetValue().ValueAsShort()); Assert.IsFalse(sut.IsString); }
public void CanWriteAndReadToDoubleArrayVariable() { var variable = new Variable("A", new short[] { 7, 7 }); var sut = new VariableReference(variable, new short[] { 4, 4 }); sut.SetValue(new Accumulator(40000.25)); Assert.AreEqual(40000.25, sut.GetValue().ValueAsDouble()); Assert.IsFalse(sut.IsString); }
public void CanWriteAndReadToStringVariable() { var variable = new Variable("A$", new short[] { }); var sut = new VariableReference(variable, new short[] { }); sut.SetValue(new Accumulator("HELLO")); Assert.AreEqual("HELLO", sut.GetValue().ValueAsString()); Assert.IsTrue(sut.IsString); }
private bool AddWatch(string variable) { var reference = new VariableReference { Variable = variable }; foreach (var instruction in CompositionManager.TrackingState) { var value = reference.GetValue(instruction.Key.Variables); if (!value.IsEmpty) { if (value.HasStore) { AddWatch(variable, value.Store); return(true); } else { Debug.LogWarningFormat(_invalidWatchWarning, variable, value.Type); return(false); } } } if (CompositionManager.Exists) { var value = reference.GetValue(CompositionManager.Instance.DefaultStore); if (value.HasStore) { AddWatch(variable, value.Store); return(true); } else { Debug.LogWarningFormat(_invalidWatchWarning, variable, value.Type); return(false); } } Debug.LogWarningFormat(_missingWatchWarning, variable); return(false); }
public void LetAssignsExpressionToVariable() { SetupSut(); _runEnvironment.CurrentLine = new ProgramLine( 10, new List <IToken> { new Token("=", TokenClass.Seperator, TokenType.Equal) }); _sut.Execute(); Assert.AreEqual(3.0, _variableReference.GetValue().ValueAsDouble()); }
protected override Vector2Int GetTargetPosition(InstructionStore variables) { if (Target.GetValue(variables).TryGetObject(out Mover toward)) { return(toward.CurrentGridPosition); } else { Debug.LogWarningFormat(this, _moverNotFoundWarning, Name, Target); } return(Vector2Int.zero); }
protected CreatureDisplay GetDisplay(IVariableStore variables) { var battle = InterfaceManager.Instance.GetInterface <BattleInterface>(InterfaceName); if (battle != null) { if (IndexVariable.GetValue(variables).TryGetInteger(out var index)) { return(battle.GetCreatureDisplay(index)); } else { Debug.LogWarningFormat(this, _noIndexWarning, Name); } } else { Debug.LogWarningFormat(this, _noInterfaceWarning, Name, InterfaceName); } return(null); }