using System.Globalization; using System.Xml.Linq; using UnityEngine.Scripting; [Preserve] public class MinEventActionModifyConstantRebirth : MinEventActionTargetedBase { public string cvarName { get; private set; } public override void Execute(MinEventParams _params) { if (_params.Self.isEntityRemote && !_params.IsLocal) { return; } for (int i = 0; i < this.targets.Count; i++) { float num = RebirthVariables.localConstants[this.cvarName]; switch (this.operation) { case MinEventActionModifyConstantRebirth.OperationTypes.set: case MinEventActionModifyConstantRebirth.OperationTypes.setvalue: num = this.value; break; case MinEventActionModifyConstantRebirth.OperationTypes.add: num += this.value; break; case MinEventActionModifyConstantRebirth.OperationTypes.subtract: num -= this.value; break; case MinEventActionModifyConstantRebirth.OperationTypes.multiply: num *= this.value; break; case MinEventActionModifyConstantRebirth.OperationTypes.divide: num /= ((this.value == 0f) ? 0.0001f : this.value); break; } RebirthVariables.localConstants[this.cvarName] = num; } } public override bool ParseXmlAttribute(XAttribute _attribute) { bool flag = base.ParseXmlAttribute(_attribute); if (!flag) { string localName = _attribute.Name.LocalName; if (localName == "cvar") { this.cvarName = _attribute.Value; return true; } if (localName == "operation") { this.operation = EnumUtils.Parse(_attribute.Value, true); return true; } if (localName == "value") { this.rollType = MinEventActionModifyConstantRebirth.RandomRollTypes.none; this.cvarRef = false; if (_attribute.Value.StartsWith("randomint", StringComparison.OrdinalIgnoreCase)) { Vector2 vector = StringParsers.ParseVector2(_attribute.Value.Substring(_attribute.Value.IndexOf('(') + 1, _attribute.Value.IndexOf(')') - (_attribute.Value.IndexOf('(') + 1))); this.minValue = (float)((int)vector.x); this.maxValue = (float)((int)vector.y); this.rollType = MinEventActionModifyConstantRebirth.RandomRollTypes.randomInt; } else if (_attribute.Value.StartsWith("randomfloat", StringComparison.OrdinalIgnoreCase)) { Vector2 vector2 = StringParsers.ParseVector2(_attribute.Value.Substring(_attribute.Value.IndexOf('(') + 1, _attribute.Value.IndexOf(')') - (_attribute.Value.IndexOf('(') + 1))); this.minValue = vector2.x; this.maxValue = vector2.y; this.rollType = MinEventActionModifyConstantRebirth.RandomRollTypes.randomFloat; } else if (_attribute.Value.StartsWith("@")) { this.cvarRef = true; this.refCvarName = _attribute.Value.Substring(1); } else { this.value = StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any); } return true; } if (localName == "seed_type") { this.seedType = EnumUtils.Parse(_attribute.Value, true); return true; } } return flag; } private MinEventActionModifyConstantRebirth.SeedType seedType; private MinEventActionModifyConstantRebirth.OperationTypes operation; private float value; private float minValue; private float maxValue; private bool cvarRef; private string refCvarName = string.Empty; private MinEventActionModifyConstantRebirth.RandomRollTypes rollType; private enum OperationTypes { set, setvalue, add, subtract, multiply, divide } private enum SeedType { Item, Player, Random } private enum RandomRollTypes : byte { none, randomInt, randomFloat } }