예제 #1
0
    void FixedUpdate()
    {
        if (m_attackTowerTarget)
        {
            if (Time.time > m_attackNext)
            {
                AttackTarget(m_attackTowerTarget);
            }

            TurretBody turret = m_attackTowerTarget.GetComponent <TurretBody>();

            if (turret && turret.IsDead())
            {
                m_attackTowerTarget = null;
                m_Action            = Action.Walking;
            }
        }
        else
        {
            m_Action = Action.Walking;
        }
    }
        protected override void OverrideGameValues()
        {
            var gaussTurretBody = BodyCatalog.FindBodyPrefab("EngiTurretBody")?.GetComponent <CharacterBody>();

            TurretBody.Apply(gaussTurretBody);

            IL.EntityStates.EngiTurret.EngiTurretWeapon.FireGauss.OnEnter += il =>
            {
                var c = new ILCursor(il);
                c.GotoNext(i => i.Match(OpCodes.Ldc_I4_1));
                c.Remove();
                c.Emit(OpCodes.Ldarg_0);
                c.EmitDelegate <Func <BulletAttack, uint> >(attack =>
                {
                    if (GaussTurretBulletCount.IsNotDefault())
                    {
                        return((uint)GaussTurretBulletCount.Value);
                    }

                    return(1u);
                });
            };

            GaussTurretBulletCount.UpdateDescription(1);
            TurretMaxDeployCount.UpdateDescription(2);
            ShieldMaxDeployCount.UpdateDescription(1);

            On.RoR2.CharacterMaster.GetDeployableSameSlotLimit += (orig, self, slot) =>
            {
                if (TurretMaxDeployCount.IsNotDefault() && slot == DeployableSlot.EngiTurret)
                {
                    return(TurretMaxDeployCount.Value);
                }
                if (ShieldMaxDeployCount.IsNotDefault() && slot == DeployableSlot.EngiBubbleShield)
                {
                    return(ShieldMaxDeployCount.Value);
                }
                return(orig(self, slot));
            };


            // Workaround for more than 8 max grenades
            if (_chargeGrenadesFields.GetValueByFieldName <int>("minGrenadeCount") >= 8 ||
                _chargeGrenadesFields.GetValueByFieldName <int>("maxGrenadeCount") >= 8)
            {
                On.EntityStates.Engi.EngiWeapon.FireGrenades.OnEnter += (orig, self) =>
                {
                    var fireGrenades =
                        self.GetType().Assembly.GetClass("EntityStates.Engi.EngiWeapon", "FireGrenades");

                    orig(self);
                    self.SetFieldValue("duration",
                                       fireGrenades.GetFieldValue <float>("baseDuration")
                                       * self.GetFieldValue <int>("grenadeCountMax") / 8f
                                       / self.GetFieldValue <float>("attackSpeedStat")
                                       );
                };
            }


            var shieldDeployed = typeof(EntityStates.Engi.EngiBubbleShield.Deployed);

            _shieldDeployedFields.Apply(shieldDeployed);

            if (ShieldEndlessDuration.Value)
            {
                EntityStates.Engi.EngiBubbleShield.Deployed.lifetime = float.PositiveInfinity;
            }

            var chargeGrenades = SurvivorDef.GetType().Assembly
                                 .GetClass("EntityStates.Engi.EngiWeapon", "ChargeGrenades");

            _chargeGrenadesFields.Apply(chargeGrenades);

            if (GrenadeSetChargeCountToFireAmount.Value &&
                _chargeGrenadesFields.GetWrapperByFieldName <int>("maxGrenadeCount").IsNotDefault())
            {
                chargeGrenades.SetFieldValue("maxCharges",
                                             _chargeGrenadesFields.GetValueByFieldName <int>("maxGrenadeCount"));
            }
        }