public void CanConstructFromBool() { bool b = true; BooleanValue bv = new BooleanValue(b); Assert.AreEqual(b, bv.Value); Assert.IsTrue(b == bv); Assert.IsFalse(b == !bv); Assert.IsFalse(b != bv); Assert.IsFalse(!b == bv); }
public void CanAddAsString() { bool b = true; string string1 = "foo"; var str1 = new StringValue(string1); var bv = new BooleanValue(b); var strResult = str1 + bv; string stringResult = string1 + b.ToString(); Assert.AreEqual(stringResult, (string)strResult); }
private void SetCaseSensitivity(BooleanValue value) { bool newCase = value.Value; if (newCase == caseSensitive) { return; } caseSensitive = newCase; internalDictionary = newCase ? new Dictionary <Structure, Structure>() : new Dictionary <Structure, Structure>(new LexiconComparer <Structure>()); }
public void CanCompareToScalar() { BooleanValue bv = new BooleanValue(true); ScalarValue sv = ScalarValue.Create(1); Assert.IsTrue(bv == sv); Assert.IsFalse(bv != sv); Assert.IsTrue(sv == bv); Assert.IsFalse(sv != bv); sv = ScalarValue.Create(0); Assert.IsTrue(bv != sv); Assert.IsFalse(bv == sv); Assert.IsTrue(sv != bv); Assert.IsFalse(sv == bv); sv = ScalarValue.Create(3.1415926535897932384626433832795); Assert.IsTrue(bv == sv); Assert.IsFalse(bv != sv); Assert.IsTrue(sv == bv); Assert.IsFalse(sv != bv); sv = ScalarValue.Create(0.0d); Assert.IsTrue(bv != sv); Assert.IsFalse(bv == sv); Assert.IsTrue(sv != bv); Assert.IsFalse(sv == bv); bv = new BooleanValue(false); sv = ScalarValue.Create(1); Assert.IsTrue(bv != sv); Assert.IsFalse(bv == sv); Assert.IsTrue(sv != bv); Assert.IsFalse(sv == bv); sv = ScalarValue.Create(0); Assert.IsTrue(bv == sv); Assert.IsFalse(bv != sv); Assert.IsTrue(sv == bv); Assert.IsFalse(sv != bv); sv = ScalarValue.Create(3.1415926535897932384626433832795); Assert.IsTrue(bv != sv); Assert.IsFalse(bv == sv); Assert.IsTrue(sv != bv); Assert.IsFalse(sv == bv); Assert.IsFalse(bv.Equals(sv)); sv = ScalarValue.Create(0.0d); Assert.IsTrue(bv == sv); Assert.IsFalse(bv != sv); Assert.IsTrue(sv == bv); Assert.IsFalse(sv != bv); Assert.IsFalse(bv.Equals(sv)); }
private void SetCaseSensitivity(BooleanValue value) { bool newCase = value.Value; if (newCase == caseSensitive) { return; } caseSensitive = newCase; internalDictionary = newCase ? new Dictionary <Structure, Structure>() : new Dictionary <Structure, Structure>(new LexiconComparer <Structure>()); // Regardless of whether or not the lexicon itself is case sensitive, // the key Suffixes have to be IN-sensitive because they are getting // values who's case got squashed by the compiler. This needs to // be documented well in the user docs (i.e. using the suffix syntax // cannot detect the difference between keys that differ only in case). keySuffixes = new Dictionary <Structure, SetSuffix <Structure> >(new LexiconComparer <Structure>()); }
/// <summary> /// Trigger whatever action the PartModule has attached to this Action, given the kOS name for the action. /// Warning - it probably triggers the entire action group that is attached to this action if there is one, /// not just the action on this one part. /// <br/><br/> /// NOTE: After kOS 0.15.5, this ability is limited by career progress of the VAB/SPH. /// </summary> /// <param name="suffixName"></param> /// <param name="param">true = activate, false = de-activate</param> private void CallKSPAction(StringValue suffixName, BooleanValue param) { ThrowIfNotCPUVessel(); BaseAction act = GetAction(suffixName); if (act == null) throw new KOSLookupFailException("ACTION", suffixName, this); string careerReason; if (!Career.CanDoActions(out careerReason)) throw new KOSLowTechException("use :DOACTION", careerReason); act.Invoke(new KSPActionParam(act.actionGroup, (param ? KSPActionType.Activate : KSPActionType.Deactivate))); }
public void SetRunningPrimary(BooleanValue prim) { ThrowIfNotCPUVessel(); if (!MultiMode) throw new KOSException("Attempted to set the PRIMARYMODE suffix on a non-multi mode engine."); // If runningPrimary does not match prim, call ToggleMode if (prim != MMengine.runningPrimary) ToggleMode(); }
public void SetAutoswitch(BooleanValue auto) { ThrowIfNotCPUVessel(); if (!MultiMode) throw new KOSException("Attempted to set the AUTOSWITCH suffix on a non-multi mode engine."); // if autoSwitch doesn't equal auto, use invoke to call the autoswitch method because the method is private if (MMengine.autoSwitch != auto) { if (auto) MMengine.Events.First(kspEvent => kspEvent.name == "EnableAutoSwitch").Invoke(); else MMengine.Events.First(kspEvent => kspEvent.name == "DisableAutoSwitch").Invoke(); } }
public void SetShow(BooleanValue newShowVal) { if (newShowVal) { if (line == null || hat == null) { lineObj = new GameObject("vecdrawLine"); hatObj = new GameObject("vecdrawHat"); labelObj = new GameObject("vecdrawLabel", typeof(GUIText)); line = lineObj.AddComponent<LineRenderer>(); hat = hatObj.AddComponent<LineRenderer>(); //TODO: 1.1 TODO label = labelObj.GetComponent<GUIText>(); line.useWorldSpace = false; hat.useWorldSpace = false; GetShipCenterCoords(); line.material = new Material(Shader.Find("Particles/Additive")); hat.material = new Material(Shader.Find("Particles/Additive")); // This is how font loading would work if other fonts were available in KSP: // Font lblFont = (Font)Resources.Load( "Arial", typeof(Font) ); // SafeHouse.Logger.Log( "lblFont is " + (lblFont == null ? "null" : "not null") ); // _label.font = lblFont; label.text = labelStr; label.anchor = TextAnchor.MiddleCenter; PutAtShipRelativeCoords(); RenderValues(); } updateHandler.AddObserver(this); line.enabled = true; hat.enabled = true; label.enabled = true; } else { updateHandler.RemoveObserver(this); if (label != null) { label.enabled = false; label = null; } if (hat != null) { hat.enabled = false; hat = null; } if (line != null) { line.enabled = false; line = null; } labelObj = null; hatObj = null; lineObj = null; } enable = newShowVal; }
public void CanImplicitlyConvertToBool() { bool b = true; BooleanValue bv = new BooleanValue(b); bool b2 = bv; Assert.AreEqual(b, b2); Assert.IsTrue(b == bv); Assert.IsFalse(b != bv); }
public void CanNullCheck() { BooleanValue bv = null; Assert.IsTrue(bv == null); Assert.IsFalse(bv != null); Assert.IsTrue(null == bv); Assert.IsFalse(null != bv); bv = new BooleanValue(true); Assert.IsTrue(bv != null); Assert.IsFalse(bv == null); Assert.IsTrue(null != bv); Assert.IsFalse(null == bv); bv = new BooleanValue(false); Assert.IsTrue(bv != null); Assert.IsFalse(bv == null); Assert.IsTrue(null != bv); Assert.IsFalse(null == bv); bv = new BooleanValue(true); Assert.IsTrue(bv != null); Assert.IsFalse(bv == null); Assert.IsTrue(null != bv); Assert.IsFalse(null == bv); bv = new BooleanValue(false); Assert.IsTrue(bv != null); Assert.IsFalse(bv == null); Assert.IsTrue(null != bv); Assert.IsFalse(null == bv); }