using System.Globalization; using System.Xml.Linq; /// /// Action to add force to the entity rigidbody component by calling the game's DoRagdoll method /// public class MinEventActionAddForceRebirth : MinEventActionTargetedBase { float _initialForceStrength = 250f; Vector2Int _XZMultiplier = new Vector2Int(4, 10); // side to side range - x and z coord Vector2Int _heightMultiplier = new Vector2Int(6, 12); // y coord public override void Execute(MinEventParams _params) { // This should provide a nice random distribution of flying zombies EntityAlive entityAlive = _params.Self; int xSign = UnityEngine.Random.Range(0, 2) * 2 - 1; // randomly go in the negative direction int zSign = UnityEngine.Random.Range(0, 2) * 2 - 1; int xStr = UnityEngine.Random.Range(_XZMultiplier.x, _XZMultiplier.y) * xSign; int yStr = UnityEngine.Random.Range(_heightMultiplier.x, _heightMultiplier.y); int zStr = UnityEngine.Random.Range(_XZMultiplier.x, _XZMultiplier.y) * zSign; Vector3 force = new Vector3(_initialForceStrength * xStr, _initialForceStrength * yStr, _initialForceStrength * zStr); //Log.Out($"Execute AddForce v3 force: {force}, x: {xStr}, y: {yStr}, z: {zStr}, xSign: {xSign}, zSign: {zSign}"); entityAlive.emodel.DoRagdoll(1f, EnumBodyPartHit.LowerLegs, force, Vector3.zero, entityAlive.isEntityRemote); } public override bool ParseXmlAttribute(XAttribute _attribute) { bool flag = base.ParseXmlAttribute(_attribute); if (!flag) { string localName = _attribute.Name.LocalName; if (localName == "force") { _initialForceStrength = StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any); return true; } } return flag; } }