public override void Run(ExplosionModule module, Grenade grenade) { List <Rigidbody> bodies = new List <Rigidbody>(); foreach (var col in Physics.OverlapSphere(grenade.transform.position, this.radius)) { if (col.attachedRigidbody != null && !col.attachedRigidbody.isKinematic && !bodies.Contains(col.attachedRigidbody)) { bodies.Add(col.attachedRigidbody); } } if (duration > 0f) { coro = RunCoro(grenade, bodies); MelonLoader.MelonCoroutines.Start(coro); } else { foreach (var body in bodies) { body?.AddExplosionForce(this.force, grenade.transform.position, this.radius, 1f, ForceMode.Impulse); } } }
public override void Run(ExplosionModule module, Grenade grenade) { for (int i = 0; i < this.count; i++) { PoolSpawner.SpawnProjectile(grenade.transform.position, UnityEngine.Random.rotation, this.projectile, grenade.name, null); } }
public Force(XElement xml, ExplosionModule module) : base(xml, module) { this.radius = (float?)xml.Attribute("radius") ?? 5f; this.force = (float?)xml.Attribute("force") ?? 15f; this.upwardsModifier = (float?)xml.Attribute("upwardsModifier") ?? 1f; this.duration = (float?)xml.Attribute("duration") ?? 0f; }
public override void Run(ExplosionModule module, Grenade grenade) { source.transform.parent = null; source.transform.position = grenade.transform.position; source.outputAudioMixerGroup = BoneworksModdingToolkit.Audio.sfxMixer; source.Play(); }
internal void Init(XElement xml) { fuseTime = (float?)xml.Attribute("fuse") ?? 5f; XElement el = xml.Element("Explode"); if (el != null) { this.explosion = new ExplosionModule(); this.explosion.Init(el, this); } el = xml.Element("Handle"); if (el != null) { this.handle = gameObject.AddComponent <HandleScript>(); this.handle.Init(el, this); } el = xml.Element("Pin"); if (el != null) { var obj = this.transform.Find((string)el.Attribute("grip") ?? "PinGrip"); if (obj != null) { this.pin = obj.gameObject.AddComponent <PinScript>(); this.pin.Init(el, this); } } init = true; }
public override void Reset(ExplosionModule module, Grenade grenade) { if (coro != null) { MelonLoader.MelonCoroutines.Stop(coro); coro = null; } }
public Effect(XElement xml, ExplosionModule module) : base(xml, module) { if (!Enum.TryParse((string)xml.Attribute("type") ?? "", true, out this.type)) { this.type = PoolSpawner.BlasterType.Dust; } this.scale = (float?)xml.Attribute("scale") ?? 1f; }
public override void Reset(ExplosionModule module, Grenade grenade) { if (this.coro != null) { MelonLoader.MelonCoroutines.Stop(this.coro); this.coro = null; } if (this.transform != null) { this.transform.localPosition = this.originalPos; this.transform.localRotation = this.originalRot; this.transform.localScale = this.originalScale; } }
private IEnumerator RunCoro(ExplosionModule module, Grenade grenade) { float timer = 0f; while (timer < this.duration) { timer += Time.deltaTime; float t = timer / this.duration; this.transform.localPosition = Vector3.Lerp(this.startPos, this.position, t); this.transform.localRotation = Quaternion.Lerp(this.startRot, this.rotation, t); this.transform.localScale = Vector3.Lerp(this.startScale, this.scale, t); yield return(null); } }
public Transformation(XElement xml, ExplosionModule module) : base(xml, module) { this.transform = module.grenade.transform.Find((string)xml.Attribute("path") ?? ""); if (this.transform == null) { return; } this.position = GrenadesMod.ParseV3((string)xml.Attribute("position")) ?? transform.localPosition; this.rotation = Quaternion.Euler(GrenadesMod.ParseV3((string)xml.Attribute("rotation")) ?? transform.localEulerAngles); this.scale = GrenadesMod.ParseV3((string)xml.Attribute("scale")) ?? transform.localScale; this.duration = (float?)xml.Attribute("duration") ?? 0f; this.originalPos = this.transform.localPosition; this.originalRot = this.transform.localRotation; this.originalScale = this.transform.localScale; }
public Shrapnel(XElement xml, ExplosionModule module) : base(xml, module) { this.projectile = ScriptableObject.CreateInstance <BulletObject>(); if (!Enum.TryParse((string)xml.Attribute("cartType") ?? "", true, out Cart cart)) { cart = Cart.Cal_45; } var vars = new AmmoVariables() { AttackDamage = (float?)xml.Attribute("damage") ?? 20f, AttackType = AttackType.Piercing, cartridgeType = cart, ExitVelocity = (float?)xml.Attribute("velocity") ?? 50f, ProjectileMass = (float?)xml.Attribute("mass") ?? 0.2f, Tracer = (bool?)xml.Attribute("tracer") ?? false }; this.projectile.ammoVariables = vars; this.count = (int?)xml.Attribute("count") ?? 100; }
public override void Run(ExplosionModule module, Grenade grenade) { if (this.transform == null) { return; } if (this.duration > 0f) { this.startPos = this.transform.localPosition; this.startRot = this.transform.localRotation; this.startScale = this.transform.localScale; this.coro = this.RunCoro(module, grenade); MelonLoader.MelonCoroutines.Start(this.coro); } else { this.transform.localPosition = this.position; this.transform.localRotation = this.rotation; this.transform.localScale = this.scale; } }
public abstract void Run(ExplosionModule module, Grenade grenade);
public override void Run(ExplosionModule module, Grenade grenade) { grenade.gameObject.SetActive(false); }
public Despawn(XElement xml, ExplosionModule module) : base(xml, module) { }
public virtual void Reset(ExplosionModule module, Grenade grenade) { }
public Audio(XElement xml, ExplosionModule module) : base(xml, module) { source = module.grenade.transform.Find((string)xml.Attribute("path") ?? "Audio")?.GetComponent <AudioSource>(); source.playOnAwake = false; original = source.transform.parent; }
public override void Run(ExplosionModule module, Grenade grenade) { PoolSpawner.SpawnBlaster(this.type, grenade.transform.position, Quaternion.identity, Vector3.one * this.scale); }
public ExplosionAction(XElement xml, ExplosionModule module) { this.delay = (float?)xml.Attribute("delay") ?? 0f; }