void ChangeValue(float change) { // This gets a bit complicated because we want to deal with both ints and floats float newDictVal = 0; float newFieldVal = 0; // Do the actual alteration if (dict) { newDictVal = dict.GetFloat(key) + change; } if (field.member != "") { newFieldVal = field.GetFloat() + change; } if (loopMaxAndMin) { if (((newDictVal > maximum && increasePerSecond > 0) || (newDictVal < minimum && increasePerSecond < 0)) || ((newFieldVal > maximum && increasePerSecond > 0) || (newFieldVal < minimum && increasePerSecond < 0))) { increasePerSecond = -increasePerSecond; } print(newFieldVal + " " + change); } else if (limitToMaxAndMin) { newDictVal = newDictVal.LimitToRange(minimum, maximum); newFieldVal = newFieldVal.LimitToRange(minimum, maximum); } // Set the values, making sure we use correct type if (dict) { if (dict.Get(key) is int) { dict.Set(key, (int)newDictVal); } else { dict.Set(key, newDictVal); } } if (field.member != "") { if (field.GetObject() is int) { field.SetValue((int)newFieldVal); } else { field.SetValue(newFieldVal); } } }
void Alter() { if (!enabled) { return; } // This gets a bit complicated because we want to deal with both ints and floats float newDictVal = 0; float newFieldVal = 0; // Do the actual alteration switch (operation) { case OperationEnum.Add: if (dict) { newDictVal = dict.GetFloat(key) + value; } if (field.member != "") { newFieldVal = field.GetFloat() + value; } break; case OperationEnum.SetTo: if (dict) { newDictVal = value; } if (field.member != "") { newFieldVal = value; } break; case OperationEnum.Multiply: if (dict) { newDictVal = dict.GetFloat(key) * value; } if (field.member != "") { newFieldVal = field.GetFloat() * value; } break; } // Set the values, making sure we use correct type if (dict) { if (dict.Get(key) is int) { dict.Set(key, (int)newDictVal); } else { dict.Set(key, newDictVal); } } if (field.member != "") { if (field.GetObject() is int) { field.SetValue((int)newFieldVal); } else { field.SetValue(newFieldVal); } } }