public bool Get(out float destination, RPMVesselComputer comp, PersistenceAccessor persistence) { if (stateFunction != null) { bool state = stateFunction(); destination = state.GetHashCode(); return(true); } if (value != null) { destination = value.Value; return(true); } destination = comp.ProcessVariable(variableName, persistence).MassageToFloat(); if (float.IsNaN(destination) || float.IsInfinity(destination)) { if (!warningMade) { JUtil.LogMessage(this, "Warning: {0} can fail to produce a usable number.", variableName); warningMade = true; return(false); } } return(true); }
public bool Get(out float destination) { if (value != null) { destination = value.Value; return(true); } destination = comp.ProcessVariable(variableName).MassageToFloat(); if (float.IsNaN(destination) || float.IsInfinity(destination)) { if (!warningMade) { JUtil.LogMessage(owner, "Warning, {0} can fail to produce a usable number.", variableName); warningMade = true; return(false); } } return(true); }
/// <summary> /// Provides a simple boolean true/false for whether the named /// variable is in range. /// </summary> /// <param name="comp"></param> /// <param name="persistence"></param> /// <returns></returns> public bool IsInRange(RPMVesselComputer comp, PersistenceAccessor persistence) { float value; float low, high; if (stateFunction != null) { bool state = stateFunction(); value = state.GetHashCode(); } else if (!string.IsNullOrEmpty(sourceValueName)) { value = comp.ProcessVariable(sourceValueName, persistence).MassageToFloat(); } else { value = sourceValue; } if (float.IsNaN(value) || float.IsInfinity(value)) { if (!warningMade) { JUtil.LogMessage(this, "Warning: {0} can fail to produce a usable number.", sourceValueName); warningMade = true; } return(false); } if (!string.IsNullOrEmpty(lowerBoundName)) { low = comp.ProcessVariable(lowerBoundName, persistence).MassageToFloat(); if (float.IsNaN(low) || float.IsInfinity(low)) { if (!warningMade) { JUtil.LogMessage(this, "Warning: {0} can fail to produce a usable number.", lowerBoundName); warningMade = true; } return(false); } } else { low = lowerBound; } if (!string.IsNullOrEmpty(upperBoundName)) { high = comp.ProcessVariable(upperBoundName, persistence).MassageToFloat(); if (float.IsNaN(high) || float.IsInfinity(high)) { if (!warningMade) { JUtil.LogMessage(this, "Warning: {0} can fail to produce a usable number.", upperBoundName); warningMade = true; } return(false); } } else { high = upperBound; } if (high < low) { return(value >= high && value <= low); } else { return(value >= low && value <= high); } }
public void Start() { JUtil.LogMessage(this, "I am in prop named {0} and it has prop ID {1}", internalProp.name, internalProp.propID); // And just in case the user forgets. Destroy(this); }
public void LateUpdate() { JUtil.LogMessage(this, "Attempting vessel recovery"); GameEvents.OnVesselRecoveryRequested.Fire(VesselToRecover); GameObject.Destroy(this.gameObject); }