public double ApplyCharges(VitalNameType vitalNameType, double discharge, bool allowOverload, bool propagate) { var vtype = vitalNameType.type; int vitalIdx; // Type None indicates no specific Vital, so this value should be applied to any complete stack. if (vtype == VitalType.None) { vitalIdx = vitalCount - 1; } else { vitalIdx = GetVitalIndex(vitalNameType); if (vitalIdx == -1) { return(0); } } double consumed = ApplyCharges(vitalIdx, discharge, allowOverload, propagate); CheckForDisrupt(consumed); return(consumed); }
private void PresetRechargeZone() { vitalNameType = new VitalNameType(VitalType.Health); allowOverload = true; dischargeOnEnter = 20; dischargePerSec = 20; dischargeOnExit = 20; dischargeOnScan = 20; useCharges = false; isPickup = false; consumeDespawn = Consumption.None; }
//public void SetTickInterval(float tickInterval) //{ // for (int i = 0; i < vitalCount; ++i) // vitalDefs[i].SetTickInterval(tickInterval); //} /// <summary> /// Do not use this in a hot path please. Cache the Vital this returns. /// </summary> public Vital GetVital(VitalNameType vitalNameType) { if (!initialized) { Initialize(); } Vital vital; vitalLookup.TryGetValue(vitalNameType.hash, out vital); return(vital); }
//public VitalDefinition() //{ // _fullValue = 100; // _maxValue = 125; // startValue = 100; // absorption = 1; // regenDelay = 1; // regenRate = 1; // decayDelay = 1; // decayRate = 1; // vitalName = new VitalNameType(VitalType.None); //} public VitalDefinition(double fullValue, uint maxValue, double startValue, double absorbtion, float regenDelay, double regenRate, float decayDelay, double decayRate, string name) { this._fullValue = fullValue; this._maxValue = maxValue; this.startValue = startValue; this.absorption = absorbtion; this.regenDelay = regenDelay; this.regenRate = regenRate; this.decayDelay = decayDelay; this.decayRate = decayRate; vitalName = new VitalNameType(name); }
private void PresetWeapon() { vitalNameType = new VitalNameType(VitalType.None); allowOverload = false; dischargeOnEnter = -20; dischargePerSec = -20; dischargeOnExit = -20; dischargeOnScan = -20; propagate = true; useCharges = false; isPickup = false; consumeDespawn = Consumption.None; }
public int GetVitalIndex(VitalNameType vitalNameType) { if (vitalDefs == null) { return(-1); } int hash = vitalNameType.hash; /// TODO: There should be a fast lookup array for targetVital for (int i = 0, cnt = vitalDefs.Count; i < cnt; ++i) { if (vitalDefs[i].VitalName.hash == hash) { return(i); } } return(-1); }