public string Format(string format, object arg, IFormatProvider formatProvider) { StringBuilder formattableString = new StringBuilder("{0"); if (!string.IsNullOrEmpty(format)) { formattableString.Append(":"); //formattableString.Append(format); var toto = format.Split(':'); formattableString.Append(toto[0]); ScalingFactor scale; if (Enum.TryParse <ScalingFactor>(toto[1], out scale)) { this._scalingFactor = scale; } } formattableString.Append("}"); return(string.Format( _underlyingCulture ?? CultureInfo.CurrentCulture, formattableString.ToString(), Scale(arg))); }
Dictionary <int, ScalingFactor> GetScalingParameters() { var res = new Dictionary <int, ScalingFactor>(); int index, index2; var thisSchema = Schema; var schema = _input.Schema; for (int i = 0; i < _args.columns.Length; ++i) { index = SchemaHelper.GetColumnIndex(schema, _args.columns[i].Source); string name = thisSchema[index].Name; var stats = _scalingStat[name]; if (_args.columns[i].Source == _args.columns[i].Name) { res[index] = new ScalingFactor(_host, index, _args.scaling, stats); } else { index2 = SchemaHelper.GetColumnIndex(Schema, _args.columns[i].Name); res[index2] = new ScalingFactor(_host, index, _args.scaling, stats); } } return(res); }
private void OnIncreaseSlotsNumberChange(BaseField field, Object obj) { TweakScale.TweakScale ts_part = this.part.Modules.GetModule <TweakScale.TweakScale>(); ScalingFactor current = ts_part.ScalingFactor; this.OnRescale(current); }
Dictionary <int, ScalingFactor> GetScalingParameters() { var res = new Dictionary <int, ScalingFactor>(); int index, index2; var thisSchema = Schema; var schema = _input.Schema; for (int i = 0; i < _args.columns.Length; ++i) { if (!schema.TryGetColumnIndex(_args.columns[i].Source, out index)) { throw _host.Except("Unable to find column '{0}'.", _args.columns[i].Source); } string name = thisSchema.GetColumnName(index); var stats = _scalingStat[name]; if (_args.columns[i].Source == _args.columns[i].Name) { res[index] = new ScalingFactor(_host, index, _args.scaling, stats); } else { if (!Schema.TryGetColumnIndex(_args.columns[i].Name, out index2)) { throw _host.Except("Unable to find column '{0}'.", _args.columns[i].Name); } res[index2] = new ScalingFactor(_host, index, _args.scaling, stats); } } return(res); }
public void OnRescale(ScalingFactor factor) { Module.ChangeVolume(Module.volume * factor.relative.cubic); foreach (PartResource f in Part.Resources) { f.amount /= factor.relative.cubic; f.maxAmount /= factor.relative.cubic; } }
public void OnRescale(ScalingFactor factor) { if (meshDataList == null) { return; } Rescale(factor.absolute.linear * Vector3.one); }
void IRescalable.OnRescale(ScalingFactor factor) { Log.dbg("OnRescale {0} to {1}", this.listener.GetName(), this.InstanceID, factor.absolute.linear); if (this.IsEnabled()) { this.listener.NotifyRestoreNeeded(); } }
public NumberScalingFormatter(System.Globalization.CultureInfo underlyingCulture) { if (underlyingCulture == null) { throw new ArgumentNullException(); } _scalingFactor = ScalingFactor.None; _underlyingCulture = underlyingCulture; }
public void OnRescale(ScalingFactor factor) { Module.ChangeVolumeRatio(factor.relative.cubic, false); // do not propagate since TS itself will. // hacky; will fix. /*foreach (PartResource f in Part.Resources) * { * f.amount /= factor.relative.cubic; * f.maxAmount /= factor.relative.cubic; * }*/ }
private void ScalingFactorChanged() { var format = "0."; for (int i = 0; i < Math.Max(1, ScalingFactor.ToString().Count(c => c == '0') + 1); i++) { format += "0"; } _graphContext.DisplayFormat = format; }
public Mem() { _type = MemoryType.Native; _segmentPrefix = SegmentPrefix.None; _base = RegIndex.Invalid; _index = RegIndex.Invalid; _scalingFactor = ScalingFactor.Times1; _target = IntPtr.Zero; _displacement = IntPtr.Zero; }
ValueGetter <VBuffer <float> > GetGetterVector(ScalingFactor scales) { var getter = _inputCursor.GetGetter <VBuffer <float> >(scales.columnId); return((ref VBuffer <float> dst) => { getter(ref dst); if (dst.Length != scales.mean.Length) { throw _parent._host.Except("Mismatch dimension {0} for destination != {1} for scaling vectors.", dst.Length, scales.mean.Length); } scales.Update(ref dst); }); }
void Notifier.Update() { ScalingFactor factor = this.tweakscale.ScalingFactor; Log.dbg("UpdateTarget {0} by {1}", this.InstanceID, factor.absolute.linear); if (null == this.targetPartModules) { return; } foreach (Data data in this.originalFx) { this.scale(data, factor); } }
internal void OnRescale(ScalingFactor factor) { Log.dbg("OnRescale {0}:{1:X} to {2}", this.name, this.part.GetInstanceID(), factor.ToString()); // Needed because I can't intialize this on OnAwake as this module can be awaken before FSbuoyancy, // and OnRescale can be fired before OnLoad. if (null == this.targetPartModule) { this.InitInternalData(); } this.RescaleMaxBuoyancy(); this.UpdateTarget(); this.RefreshUI(); }
public Mem(IntPtr target, IntPtr displacement, SegmentPrefix segmentPrefix, int size = 0) : base(size: size) { Contract.EndContractBlock(); _type = MemoryType.Absolute; _segmentPrefix = segmentPrefix; _base = RegIndex.Invalid; _index = RegIndex.Invalid; _scalingFactor = ScalingFactor.Times1; _target = target; _displacement = displacement; }
public virtual void OnRescale(ScalingFactor factor) { try { storedScalingfactor = (double)(decimal)factor.absolute.linear; storedMassMultiplier = Math.Pow(storedScalingfactor, massExponent); storedTargetMassMultiplier = Math.Pow(storedScalingfactor, massTargetExponent); initialMass = (double)(decimal)part.prefabMass * storedMassMultiplier; chargestatus = maxCharge; } catch (Exception e) { Debug.LogError("[KSPI]: AntimatterStorageTank.OnRescale " + e.Message); } }
public void OnRescale(ScalingFactor factor) { if (HighLogic.CurrentGame.file_version_minor < 11) { return; } Initialize(); if (_moduleInventoryPart == null) { return; } _moduleInventoryPart.InventorySlots = Math.Max(1, 3 * (int)(_inventorySlots * factor.absolute.linear / 3)); _moduleInventoryPartField?.SetValue((_packedVolumeLimit * factor.absolute.cubic), _moduleInventoryPart); _moduleInventoryPart.OnStart(HighLogic.LoadedSceneIsEditor ? StartState.Editor : _state); }
public Mem(GPReg @base, IntPtr displacement, int size = 0) : base(size: size) { if (@base == null) throw new ArgumentNullException("base"); Contract.EndContractBlock(); _type = MemoryType.Native; _segmentPrefix = SegmentPrefix.None; _sizePrefix = @base.Size != IntPtr.Size; _base = @base.RegisterIndex; _index = RegIndex.Invalid; _scalingFactor = ScalingFactor.Times1; _target = IntPtr.Zero; _displacement = displacement; }
/// <summary> /// Build a string representation of this unit of measure /// </summary> /// <returns>String value</returns> public override string ToString() { StringBuilder sb = new StringBuilder(); // type sb.Append(MeasurementSystem.UnitsManager.GetString("unit.type.text")).Append(' ').Append(UOMType.ToString()).Append(", "); // unit enumeration if (Enumeration.HasValue) { sb.Append(MeasurementSystem.UnitsManager.GetString("enum.text")).Append(' ').Append(Enumeration.ToString()).Append(", "); } // symbol sb.Append(MeasurementSystem.UnitsManager.GetString("symbol.text")).Append(' ').Append(Symbol); sb.Append(", ").Append(MeasurementSystem.UnitsManager.GetString("conversion.text")).Append(' '); // scaling factor if (ScalingFactor.CompareTo(1) != 0) { sb.Append(ScalingFactor.ToString()).Append(MULT); } // abscissa unit if (AbscissaUnit != null) { sb.Append(AbscissaUnit.Symbol); } // offset if (Offset.CompareTo(0d) != 0) { sb.Append(" + ").Append(Offset.ToString()); } sb.Append(", ").Append(MeasurementSystem.UnitsManager.GetString("base.text")).Append(' '); // base symbol sb.Append(GetBaseSymbol()); return(sb.ToString()); }
public virtual void OnRescale(ScalingFactor factor) { try { storedScalingfactor = factor.absolute.linear; storedResourceCostMultiplier = Math.Pow(storedScalingfactor, 3); storedMassMultiplier = Math.Pow(storedScalingfactor, massExponent); storedTargetMassMultiplier = Math.Pow(storedScalingfactor, massTargetExponent); storedInitialCostMultiplier = Math.Pow(storedScalingfactor, dryCostInitialExponent); storedTargetCostMultiplier = Math.Pow(storedScalingfactor, dryCostTargetExponent); initialMass = part.prefabMass * storedMassMultiplier; chargeStatus = maxCharge; } catch (Exception e) { Debug.LogError("[KSPI]: AntimatterStorageTank.OnRescale " + e.Message); } }
public virtual void OnRescale(ScalingFactor factor) { try { Debug.Log("BeamGenerator.OnRescale called with " + factor.absolute.linear); storedMassMultiplier = Math.Pow((double)(decimal)factor.absolute.linear, 3); initialMass = (double)(decimal)part.prefabMass * storedMassMultiplier; if (maximumPower > 0) { targetMass = maximumPower * powerMassFraction * 0.001; } else { targetMass = initialMass; } } catch (Exception e) { Debug.LogError("[KSPI]: BeamGenerator.OnRescale" + e.Message); } }
public void OnRescale(ScalingFactor factor) { bool change = true; if (Part != null) { for (int i = Part.Modules.Count - 1; i >= 0; --i) { PartModule m = Part.Modules[i]; if (m is ModuleEngineConfigs) { change = false; break; } } } if (change) { Module.SetScale(factor.absolute.quadratic); } }
/// <summary> /// Compare this unit of measure to another /// </summary> /// <param name="other">UnitOfMeasure</param> /// <returns>True if equal</returns> public override bool Equals(Object other) { if (other == null || GetType() != other.GetType()) { return(false); } UnitOfMeasure otherUnit = (UnitOfMeasure)other; // same enumerations Unit?thisEnumeration = Enumeration; Unit?otherEnumeration = otherUnit.Enumeration; if (thisEnumeration != null && otherEnumeration != null && !thisEnumeration.Equals(otherEnumeration)) { return(false); } // same abscissa unit symbols string thisSymbol = AbscissaUnit.Symbol; string otherSymbol = otherUnit.AbscissaUnit.Symbol; if (!thisSymbol.Equals(otherSymbol)) { return(false); } // same factors if (ScalingFactor.CompareTo(otherUnit.ScalingFactor) != 0) { return(false); } // same offsets if (Offset.CompareTo(otherUnit.Offset) != 0) { return(false); } return(true); }
internal void OnRescale(ScalingFactor factor) { Log.dbg("OnRescale {0}:{1:X} to {2}", this.name, this.part.GetInstanceID(), factor.ToString()); KISP.ModuleKISInventory prefab = this.part.partInfo.partPrefab.Modules.GetModule <KISP.ModuleKISInventory>(); KISP.ModuleKISInventory part = this.part.Modules.GetModule <KISP.ModuleKISInventory>(); TweakScale.TweakScale ts_prefab = this.part.partInfo.partPrefab.Modules.GetModule <TweakScale.TweakScale>(); TweakScale.TweakScale ts_part = this.part.Modules.GetModule <TweakScale.TweakScale>(); part.maxVolume = prefab.maxVolume * factor.absolute.cubic; ts_part.DryCost = (float)(ts_prefab.DryCost * factor.absolute.cubic); if (this.increaseSlotsNumber) { //part.slotSize = prefab.slotSize; part.slotsX = (int)Math.Floor(prefab.slotsX * factor.absolute.linear); part.slotsY = (int)Math.Floor(prefab.slotsY * factor.absolute.linear); int slotsCount = part.slotsX * part.slotsY; if (slotsCount > prefab.slotsX * prefab.slotsY) { Log.dbg("before {0} {1}", part.maxVolume, ts_part.DryCost); part.maxVolume -= (float)(slotsCount * (0.0005 * part.maxVolume)); // Reduce volume by 0.05% per slot ts_part.DryCost += (float)(slotsCount * (0.001 * ts_part.DryCost)); // Add 0.1% of cost penalty per slot Log.dbg("after {0} {1}", part.maxVolume, ts_part.DryCost); } } else { //part.slotSize = (int)Math.Floor(prefab.slotSize * factor.absolute.linear); part.slotsX = prefab.slotsX; part.slotsY = prefab.slotsY; } // FIXME: Resize the Inventory Window size! Log.dbg("Current size : {0} maxVolume, {1} slotsX, {2} slotsX, {3} dry cost; {4} currentScale; {5} defaultScale", part.maxVolume, part.slotsX, part.slotsY, ts_part.DryCost, ts_part.currentScale, ts_part.defaultScale); }
ValueGetter <VBuffer <float> > GetGetter(ScalingFactor scales) { var getter = _inputCursor.GetGetter <float>(scales.columnId); float value = 0f; return((ref VBuffer <float> dst) => { getter(ref value); if (1 != scales.mean.Length) { throw _parent._host.Except("Mismatch dimension {0} for destination != {1} for scaling vectors.", dst.Length, scales.mean.Length); } if (dst.Length != 1) { dst = new VBuffer <float>(1, new[] { value }); } else { dst.Values[0] = value; } scales.Update(ref dst); }); }
public void OnRescale(ScalingFactor factor) { storedAbsoluteFactor = (double)(decimal)factor.absolute.linear; ScaleParameters(); }
public void OnRescale(ScalingFactor factor) { _factor = factor; }
private static Mem MemPtrBuild(Label label, GPVar index, ScalingFactor scalingFactor, int displacement, Size size) { Contract.Requires(label != null); Contract.Requires(index != null); Contract.Requires(scalingFactor >= ScalingFactor.Times1 && scalingFactor <= ScalingFactor.Times8); Contract.Ensures(Contract.Result<Mem>() != null); return new Mem(label, index, scalingFactor, (IntPtr)displacement, (int)size); }
public ScalingStat(ScalingFactor scalingFactor) { m_ScalingFactor = scalingFactor; }
public static Mem sysint_ptr(GPReg @base, GPReg index, ScalingFactor scalingFactor, int displacement = 0) { Contract.Requires(@base != null); Contract.Requires(index != null); Contract.Requires(scalingFactor >= ScalingFactor.Times1 && scalingFactor <= ScalingFactor.Times8); Contract.Ensures(Contract.Result<Mem>() != null); return MemPtrBuild(@base, index, scalingFactor, displacement, (NAsmJit.Size)IntPtr.Size); }
public void OnRescale(ScalingFactor factor) { Module.scale = factor.absolute.quadratic; Module.SetConfiguration(); }
public void OnRescale(ScalingFactor factor) { this.pm.OnRescale(factor); }
public Mem(Label label, GPVar index, ScalingFactor scalingFactor, IntPtr displacement, int size = 0) : this(label, displacement, size) { if (index == null) throw new ArgumentNullException("index"); if (scalingFactor < ScalingFactor.Times1 || scalingFactor > ScalingFactor.Times8) throw new ArgumentOutOfRangeException("scalingFactor"); Contract.EndContractBlock(); _index = (RegIndex)index.Id; _scalingFactor = scalingFactor; }
public Mem(Label label, IntPtr displacement, int size = 0) : base(size: size) { if (label == null) throw new ArgumentNullException("label"); _type = MemoryType.Label; _label = label; _segmentPrefix = SegmentPrefix.None; _base = (RegIndex)label.Id; _index = RegIndex.Invalid; _scalingFactor = ScalingFactor.Times1; _target = IntPtr.Zero; _displacement = displacement; }
public Mem(GPVar @base, GPVar index, ScalingFactor scalingFactor, IntPtr displacement, int size = 0) : base(size: size) { if (@base == null) throw new ArgumentNullException("base"); if (index == null) throw new ArgumentNullException("index"); if (scalingFactor < ScalingFactor.Times1 || scalingFactor > ScalingFactor.Times8) throw new ArgumentOutOfRangeException("scalingFactor"); Contract.EndContractBlock(); _type = MemoryType.Native; _segmentPrefix = SegmentPrefix.None; _sizePrefix = @base.Size != IntPtr.Size || index.Size != IntPtr.Size; _base = (RegIndex)@base.Id; _index = (RegIndex)index.Id; _scalingFactor = scalingFactor; _target = IntPtr.Zero; _displacement = displacement; }
public NumberScalingFormatter() { _scalingFactor = ScalingFactor.None; }
public virtual void OnRescale(ScalingFactor factor) { Scale = factor.absolute.linear; // Debug.Log(fuelConfigurationName + " Rescaled to " + Scale); }
public static Mem word_ptr(IntPtr target, GPVar index, ScalingFactor scalingFactor, int displacement = 0, SegmentPrefix segmentPrefix = SegmentPrefix.None) { Contract.Requires(index != null); Contract.Ensures(Contract.Result<Mem>() != null); return MemPtrAbs(target, index, scalingFactor, displacement, segmentPrefix, NAsmJit.Size.WORD); }
public virtual void OnRescale(ScalingFactor factor) { Scale = factor.absolute.linear; }
public static Mem xmmword_ptr(GPVar @base, GPVar index, ScalingFactor scalingFactor, int displacement = 0) { Contract.Requires(@base != null); Contract.Requires(index != null); Contract.Requires(scalingFactor >= ScalingFactor.Times1 && scalingFactor <= ScalingFactor.Times8); Contract.Ensures(Contract.Result<Mem>() != null); return MemPtrBuild(@base, index, scalingFactor, displacement, NAsmJit.Size.DQWORD); }
public Mem(IntPtr target, GPVar index, ScalingFactor scalingFactor, IntPtr displacement, SegmentPrefix segmentPrefix, int size = 0) : base(size: size) { if (index == null) throw new ArgumentNullException("index"); if (scalingFactor < ScalingFactor.Times1 || scalingFactor > ScalingFactor.Times8) throw new ArgumentOutOfRangeException("scalingFactor"); Contract.EndContractBlock(); _type = MemoryType.Absolute; _segmentPrefix = segmentPrefix; _sizePrefix = index.Size != IntPtr.Size; _base = RegIndex.Invalid; _index = (RegIndex)index.Id; _scalingFactor = scalingFactor; _target = target; _displacement = displacement; }
private static Mem MemPtrAbs(IntPtr target, GPVar index, ScalingFactor scalingFactor, int displacement, SegmentPrefix segmentPrefix, Size size) { Contract.Requires(index != null); Contract.Requires(scalingFactor >= ScalingFactor.Times1 && scalingFactor <= ScalingFactor.Times8); return new Mem(target, index, scalingFactor, (IntPtr)displacement, segmentPrefix, (int)size); }