Exemplo n.º 1
0
            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);
                    }
                }
            }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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();
 }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
 public override void Reset(ExplosionModule module, Grenade grenade)
 {
     if (coro != null)
     {
         MelonLoader.MelonCoroutines.Stop(coro);
         coro = null;
     }
 }
Exemplo n.º 7
0
            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;
            }
Exemplo n.º 8
0
            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;
                }
            }
Exemplo n.º 9
0
            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);
                }
            }
Exemplo n.º 10
0
            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;
            }
Exemplo n.º 11
0
            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;
            }
Exemplo n.º 12
0
            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;
                }
            }
Exemplo n.º 13
0
 public abstract void Run(ExplosionModule module, Grenade grenade);
Exemplo n.º 14
0
 public override void Run(ExplosionModule module, Grenade grenade)
 {
     grenade.gameObject.SetActive(false);
 }
Exemplo n.º 15
0
 public Despawn(XElement xml, ExplosionModule module) : base(xml, module)
 {
 }
Exemplo n.º 16
0
 public virtual void Reset(ExplosionModule module, Grenade grenade)
 {
 }
Exemplo n.º 17
0
 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;
 }
Exemplo n.º 18
0
 public override void Run(ExplosionModule module, Grenade grenade)
 {
     PoolSpawner.SpawnBlaster(this.type, grenade.transform.position, Quaternion.identity, Vector3.one * this.scale);
 }
Exemplo n.º 19
0
 public ExplosionAction(XElement xml, ExplosionModule module)
 {
     this.delay = (float?)xml.Attribute("delay") ?? 0f;
 }