コード例 #1
0
 public override void InitializeAgentStats(
     Agent agent,
     Equipment spawnEquipment,
     AgentDrivenProperties agentDrivenProperties,
     AgentBuildData agentBuildData)
 {
     agentDrivenProperties.ArmorEncumbrance = spawnEquipment.GetTotalWeightOfArmor(agent.IsHuman);
     if (!agent.IsHuman)
     {
         MultiplayerAgentStatCalculateModel.InitializeHorseAgentStats(agent, spawnEquipment, agentDrivenProperties);
     }
     else
     {
         agentDrivenProperties = this.InitializeHumanAgentStats(agent, agentDrivenProperties, agentBuildData);
     }
     foreach (DrivenPropertyBonusAgentComponent bonusAgentComponent in agent.Components.OfType <DrivenPropertyBonusAgentComponent>())
     {
         if (MBMath.IsBetween((int)bonusAgentComponent.DrivenProperty, 0, 56))
         {
             float num = agentDrivenProperties.GetStat(bonusAgentComponent.DrivenProperty) + bonusAgentComponent.DrivenPropertyBonus;
             agentDrivenProperties.SetStat(bonusAgentComponent.DrivenProperty, num);
         }
     }
 }
コード例 #2
0
        private void UpdateHumanAgentStats(Agent agent, AgentDrivenProperties agentDrivenProperties)
        {
            MPPerkObject.MPPerkHandler perkHandler = MPPerkObject.GetPerkHandler(agent);
            BasicCharacterObject       character   = agent.Character;
            MissionEquipment           equipment   = agent.Equipment;
            float          num1 = equipment.GetTotalWeightOfWeapons() * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetEncumbrance(true) : 0.0));
            EquipmentIndex wieldedItemIndex1 = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand);
            EquipmentIndex wieldedItemIndex2 = agent.GetWieldedItemIndex(Agent.HandIndex.OffHand);

            if (wieldedItemIndex1 != EquipmentIndex.None)
            {
                ItemObject      itemObject       = equipment[wieldedItemIndex1].Item;
                WeaponComponent weaponComponent  = itemObject.WeaponComponent;
                float           realWeaponLength = weaponComponent.PrimaryWeapon.GetRealWeaponLength();
                float           num2             = (weaponComponent.GetItemType() == ItemObject.ItemTypeEnum.Bow ? 4f : 1.5f) * itemObject.Weight * MathF.Sqrt(realWeaponLength) * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetEncumbrance(false) : 0.0));
                num1 += num2;
            }
            if (wieldedItemIndex2 != EquipmentIndex.None)
            {
                float num2 = 1.5f * equipment[wieldedItemIndex2].Item.Weight * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetEncumbrance(false) : 0.0));
                num1 += num2;
            }
            agentDrivenProperties.WeaponsEncumbrance = num1;
            EquipmentIndex      wieldedItemIndex3   = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand);
            WeaponComponentData weaponComponentData = wieldedItemIndex3 != EquipmentIndex.None ? equipment[wieldedItemIndex3].CurrentUsageItem : (WeaponComponentData)null;
            ItemObject          primaryItem         = wieldedItemIndex3 != EquipmentIndex.None ? equipment[wieldedItemIndex3].Item : (ItemObject)null;
            EquipmentIndex      wieldedItemIndex4   = agent.GetWieldedItemIndex(Agent.HandIndex.OffHand);
            WeaponComponentData secondaryItem       = wieldedItemIndex4 != EquipmentIndex.None ? equipment[wieldedItemIndex4].CurrentUsageItem : (WeaponComponentData)null;
            float inaccuracy;

            agentDrivenProperties.LongestRangedWeaponSlotIndex       = (float)equipment.GetLongestRangedWeaponWithAimingError(out inaccuracy, agent);
            agentDrivenProperties.LongestRangedWeaponInaccuracy      = inaccuracy;
            agentDrivenProperties.SwingSpeedMultiplier               = (float)(0.930000007152557 + 0.000699999975040555 * (double)this.GetSkillValueForItem(character, primaryItem));
            agentDrivenProperties.ThrustOrRangedReadySpeedMultiplier = agentDrivenProperties.SwingSpeedMultiplier;
            agentDrivenProperties.HandlingMultiplier = 1f;
            agentDrivenProperties.ShieldBashStunDurationMultiplier = 1f;
            agentDrivenProperties.KickStunDurationMultiplier       = 1f;
            agentDrivenProperties.ReloadSpeed = (float)(0.930000007152557 + 0.000699999975040555 * (double)this.GetSkillValueForItem(character, primaryItem));
            agentDrivenProperties.ReloadMovementPenaltyFactor = 1f;
            agentDrivenProperties.WeaponInaccuracy            = 0.0f;
            MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(agent.Character);
            agentDrivenProperties.MaxSpeedMultiplier = (float)(1.04999995231628 * ((double)classForCharacter.MovementSpeedMultiplier * (100.0 / (100.0 + (double)num1))));
            int  skillValue = character.GetSkillValue(DefaultSkills.Riding);
            bool flag1      = false;
            bool flag2      = false;

            if (weaponComponentData != null)
            {
                int weaponSkill = character.GetSkillValue(weaponComponentData.RelevantSkill);
                if (weaponSkill > 0 && weaponComponentData.IsRangedWeapon && perkHandler != null)
                {
                    weaponSkill = MathF.Ceiling((float)weaponSkill * (perkHandler.GetRangedAccuracy() + 1f));
                }
                int thrustSpeed = weaponComponentData.ThrustSpeed;
                agentDrivenProperties.WeaponInaccuracy = this.GetWeaponInaccuracy(agent, weaponComponentData, weaponSkill);
                if (weaponComponentData.IsRangedWeapon)
                {
                    agentDrivenProperties.WeaponMaxMovementAccuracyPenalty = (float)(500 - weaponSkill) * 0.00025f;
                    agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty = (float)(500 - weaponSkill) * 0.0002f;
                    if (agent.HasMount)
                    {
                        agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= Math.Max(1f, (float)(700 - weaponSkill - skillValue) * (3f / 1000f));
                        agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= Math.Max(1f, (float)(700 - weaponSkill - skillValue) * 0.0033f);
                    }
                    else if (weaponComponentData.RelevantSkill == DefaultSkills.Bow)
                    {
                        agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 4.5f / MBMath.Lerp(0.75f, 2f, (float)(((double)thrustSpeed - 60.0) / 75.0));
                        agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= 6f;
                    }
                    else if (weaponComponentData.RelevantSkill == DefaultSkills.Crossbow)
                    {
                        agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 1.2f;
                        agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= 2.5f;
                    }
                    else if (weaponComponentData.RelevantSkill == DefaultSkills.Throwing)
                    {
                        agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 3.5f * MBMath.Lerp(1.5f, 0.8f, (float)(((double)thrustSpeed - 89.0) / 13.0));
                    }
                    if (weaponComponentData.WeaponClass == WeaponClass.Bow)
                    {
                        flag1 = true;
                        agentDrivenProperties.WeaponBestAccuracyWaitTime = (float)(0.300000011920929 + (95.75 - (double)thrustSpeed) * 0.00499999988824129);
                        agentDrivenProperties.WeaponUnsteadyBeginTime    = (float)(0.100000001490116 + (double)weaponSkill * 0.00999999977648258 * (double)MBMath.Lerp(1f, 2f, (float)(((double)thrustSpeed - 60.0) / 75.0)));
                        if (agent.IsAIControlled)
                        {
                            agentDrivenProperties.WeaponUnsteadyBeginTime *= 4f;
                        }
                        agentDrivenProperties.WeaponUnsteadyEndTime = 2f + agentDrivenProperties.WeaponUnsteadyBeginTime;
                        agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.1f;
                    }
                    else if (weaponComponentData.WeaponClass == WeaponClass.Javelin || weaponComponentData.WeaponClass == WeaponClass.ThrowingAxe || weaponComponentData.WeaponClass == WeaponClass.ThrowingKnife)
                    {
                        agentDrivenProperties.WeaponBestAccuracyWaitTime = (float)(0.400000005960464 + (89.0 - (double)thrustSpeed) * 0.0299999993294477);
                        agentDrivenProperties.WeaponUnsteadyBeginTime    = (float)(2.5 + (double)weaponSkill * 0.00999999977648258);
                        agentDrivenProperties.WeaponUnsteadyEndTime      = 10f + agentDrivenProperties.WeaponUnsteadyBeginTime;
                        agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.025f;
                    }
                    else
                    {
                        agentDrivenProperties.WeaponBestAccuracyWaitTime = 0.1f;
                        agentDrivenProperties.WeaponUnsteadyBeginTime    = 0.0f;
                        agentDrivenProperties.WeaponUnsteadyEndTime      = 0.0f;
                        agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.1f;
                    }
                }
                else if (weaponComponentData.WeaponFlags.HasAllFlags <WeaponFlags>(WeaponFlags.WideGrip))
                {
                    flag2 = true;
                    agentDrivenProperties.WeaponUnsteadyBeginTime = (float)(1.0 + (double)weaponSkill * 0.00499999988824129);
                    agentDrivenProperties.WeaponUnsteadyEndTime   = (float)(3.0 + (double)weaponSkill * 0.00999999977648258);
                }
            }
            agentDrivenProperties.AttributeShieldMissileCollisionBodySizeAdder = 0.3f;
            Agent mountAgent = agent.MountAgent;
            float num3       = mountAgent != null?mountAgent.GetAgentDrivenPropertyValue(DrivenProperty.AttributeRiding) : 1f;

            agentDrivenProperties.AttributeRiding                    = (float)skillValue * num3;
            agentDrivenProperties.AttributeHorseArchery              = Game.Current.BasicModels.StrikeMagnitudeModel.CalculateHorseArcheryFactor(character);
            agentDrivenProperties.BipedalRangedReadySpeedMultiplier  = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalRangedReadySpeedMultiplier);
            agentDrivenProperties.BipedalRangedReloadSpeedMultiplier = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalRangedReloadSpeedMultiplier);
            foreach (DrivenPropertyBonusAgentComponent bonusAgentComponent in agent.Components.OfType <DrivenPropertyBonusAgentComponent>())
            {
                if (!MBMath.IsBetween((int)bonusAgentComponent.DrivenProperty, 0, 56))
                {
                    float num2 = agentDrivenProperties.GetStat(bonusAgentComponent.DrivenProperty) + bonusAgentComponent.DrivenPropertyBonus;
                    agentDrivenProperties.SetStat(bonusAgentComponent.DrivenProperty, num2);
                }
            }
            if (perkHandler != null)
            {
                for (int index = 56; index < 85; ++index)
                {
                    DrivenProperty drivenProperty = (DrivenProperty)index;
                    if (((drivenProperty == DrivenProperty.WeaponUnsteadyBeginTime ? 0 : (drivenProperty != DrivenProperty.WeaponUnsteadyEndTime ? 1 : 0)) | (flag1 ? 1 : 0) | (flag2 ? 1 : 0)) != 0 && drivenProperty != DrivenProperty.WeaponRotationalAccuracyPenaltyInRadians | flag1)
                    {
                        float stat = agentDrivenProperties.GetStat(drivenProperty);
                        agentDrivenProperties.SetStat(drivenProperty, stat + perkHandler.GetDrivenPropertyBonus(drivenProperty, stat));
                    }
                }
            }
            this.SetAiRelatedProperties(agent, agentDrivenProperties, weaponComponentData, secondaryItem);
        }
コード例 #3
0
        protected internal override void OnTick(float dt)
        {
            base.OnTick(dt);
            if (!this.GameEntity.IsVisibleIncludeParents())
            {
                return;
            }
            if (this.State == RangedSiegeWeapon.WeaponState.WaitingBeforeProjectileLeaving)
            {
                this.UpdateProjectilePosition();
            }
            if ((NativeObject)this._verticalAdjuster.Skeleton != (NativeObject)null)
            {
                this._verticalAdjuster.Skeleton.SetAnimationParameterAtChannel(0, (float)(((double)this.currentReleaseAngle - (double)this.BottomReleaseAngleRestriction) / ((double)this.TopReleaseAngleRestriction - (double)this.BottomReleaseAngleRestriction)));
            }
            MatrixFrame parent = this.SkeletonOwnerObjects[0].GameEntity.GetBoneEntitialFrameWithIndex((byte)0).TransformToParent(this._verticalAdjusterStartingLocalFrame);

            this._verticalAdjuster.SetFrame(ref parent);
            MatrixFrame globalFrame = this._body.GameEntity.GetGlobalFrame();

            for (int index = 0; index < this.StandingPoints.Count; ++index)
            {
                if (this.StandingPoints[index].HasUser)
                {
                    if (MBMath.IsBetween((int)this.StandingPoints[index].UserAgent.GetCurrentActionType(0), 44, 48))
                    {
                        this.StandingPoints[index].UserAgent.ClearHandInverseKinematics();
                    }
                    else if (this.StandingPoints[index] != this.PilotStandingPoint)
                    {
                        if (this.StandingPoints[index].UserAgent.GetCurrentAction(1) != this._reload2IdleActionIndex)
                        {
                            this.StandingPoints[index].UserAgent.SetHandInverseKinematicsFrameFromActionChannel(1, this._standingPointLocalIKFrames[index], globalFrame);
                        }
                        else
                        {
                            this.StandingPoints[index].UserAgent.ClearHandInverseKinematics();
                        }
                    }
                    else
                    {
                        this.StandingPoints[index].UserAgent.SetHandInverseKinematicsFrameFromActionChannel(1, this._standingPointLocalIKFrames[index], globalFrame);
                    }
                }
            }
            if (!GameNetwork.IsClientOrReplay)
            {
                for (int index = 0; index < this._rotateStandingPoints.Count; ++index)
                {
                    StandingPoint rotateStandingPoint = this._rotateStandingPoints[index];
                    if (rotateStandingPoint.HasUser && !rotateStandingPoint.UserAgent.SetActionChannel(1, index == 0 ? this._rotateLeftAnimationActionIndex : this._rotateRightAnimationActionIndex))
                    {
                        rotateStandingPoint.UserAgent.StopUsingGameObject();
                    }
                }
                if (this.PilotAgent != null)
                {
                    ActionIndexCache currentAction = this.PilotAgent.GetCurrentAction(1);
                    if (this.State == RangedSiegeWeapon.WeaponState.WaitingBeforeProjectileLeaving)
                    {
                        if (MBMath.IsBetween((int)this.PilotAgent.GetCurrentActionType(0), 44, 48))
                        {
                            if (this.PilotAgent.GetCurrentAction(0) != Mangonel.act_strike_bent_over)
                            {
                                this.PilotAgent.SetActionChannel(0, Mangonel.act_strike_bent_over);
                            }
                        }
                        else if (!this.PilotAgent.SetActionChannel(1, this._shootAnimationActionIndex))
                        {
                            this.PilotAgent.StopUsingGameObject();
                        }
                    }
                    else if (!this.PilotAgent.SetActionChannel(1, this._idleAnimationActionIndex) && currentAction != this._reload1AnimationActionIndex && currentAction != this._shootAnimationActionIndex)
                    {
                        this.PilotAgent.StopUsingGameObject();
                    }
                }
                if (this._reloadWithoutPilot.HasUser)
                {
                    Agent userAgent = this._reloadWithoutPilot.UserAgent;
                    if (!userAgent.SetActionChannel(1, this._reload2IdleActionIndex) && userAgent.GetCurrentAction(1) != this._reload2AnimationActionIndex)
                    {
                        userAgent.StopUsingGameObject();
                    }
                }
                foreach (StandingPointWithWeaponRequirement pickUpStandingPoint in this.AmmoPickUpStandingPoints)
                {
                    if (pickUpStandingPoint.HasUser)
                    {
                        Agent            userAgent     = pickUpStandingPoint.UserAgent;
                        ActionIndexCache currentAction = userAgent.GetCurrentAction(1);
                        if (!(currentAction == Mangonel.act_pickup_boulder_begin))
                        {
                            if (currentAction == Mangonel.act_pickup_boulder_end)
                            {
                                MissionWeapon weapon = new MissionWeapon(this.OriginalMissileItem, (ItemModifier)null, (Banner)null, (short)1);
                                userAgent.EquipWeaponToExtraSlotAndWield(ref weapon);
                                userAgent.StopUsingGameObject();
                                this.ConsumeAmmo();
                                if (!this.IsDeactivated && !this.LoadAmmoStandingPoint.HasUser && (!this.LoadAmmoStandingPoint.HasAIMovingTo && this.HasAIPickingUpAmmo) && this.CurrentlyUsedAmmoPickUpPoint == pickUpStandingPoint)
                                {
                                    this.LoadAmmoStandingPoint.SetIsDeactivatedSynched(false);
                                    if (userAgent.IsAIControlled)
                                    {
                                        StandingPoint standingPointFor = this.GetSuitableStandingPointFor(this.Side, userAgent);
                                        if (standingPointFor != null)
                                        {
                                            ((IDetachment)this).AddAgent(userAgent);
                                            if (userAgent.Formation != null)
                                            {
                                                userAgent.Formation.DetachUnit(userAgent, this.IsLoose);
                                                userAgent.Detachment       = (IDetachment)this;
                                                userAgent.DetachmentWeight = this.GetWeightOfStandingPoint(standingPointFor);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (!userAgent.SetActionChannel(1, Mangonel.act_pickup_boulder_begin))
                            {
                                userAgent.StopUsingGameObject();
                            }
                        }
                    }
                }
            }
            switch (this.State)
            {
            case RangedSiegeWeapon.WeaponState.LoadingAmmo:
                if (GameNetwork.IsClientOrReplay || !this.LoadAmmoStandingPoint.HasUser)
                {
                    break;
                }
                Agent userAgent1 = this.LoadAmmoStandingPoint.UserAgent;
                if (userAgent1.GetCurrentAction(1) == this._loadAmmoEndAnimationActionIndex)
                {
                    EquipmentIndex wieldedItemIndex = userAgent1.GetWieldedItemIndex(Agent.HandIndex.MainHand);
                    if (wieldedItemIndex != EquipmentIndex.None && userAgent1.Equipment[wieldedItemIndex].CurrentUsageItem.WeaponClass == this.OriginalMissileItem.PrimaryWeapon.WeaponClass)
                    {
                        this.ChangeProjectileEntityServer(userAgent1, userAgent1.Equipment[wieldedItemIndex].Item.StringId);
                        userAgent1.RemoveEquippedWeapon(wieldedItemIndex);
                        this._timeElapsedAfterLoading = 0.0f;
                        this.Projectile.SetVisibleSynched(true);
                        this.State = RangedSiegeWeapon.WeaponState.WaitingBeforeIdle;
                        break;
                    }
                    this.LoadAmmoStandingPoint.UserAgent.StopUsingGameObject();
                    break;
                }
                if (!(userAgent1.GetCurrentAction(1) != this._loadAmmoBeginAnimationActionIndex) || this.LoadAmmoStandingPoint.UserAgent.SetActionChannel(1, this._loadAmmoBeginAnimationActionIndex))
                {
                    break;
                }
                for (EquipmentIndex equipmentIndex = EquipmentIndex.WeaponItemBeginSlot; equipmentIndex < EquipmentIndex.NumAllWeaponSlots; ++equipmentIndex)
                {
                    if (!userAgent1.Equipment[equipmentIndex].IsEmpty && userAgent1.Equipment[equipmentIndex].CurrentUsageItem.WeaponClass == this.OriginalMissileItem.PrimaryWeapon.WeaponClass)
                    {
                        userAgent1.RemoveEquippedWeapon(equipmentIndex);
                    }
                }
                this.LoadAmmoStandingPoint.UserAgent.StopUsingGameObject();
                break;

            case RangedSiegeWeapon.WeaponState.WaitingBeforeIdle:
                this._timeElapsedAfterLoading += dt;
                if ((double)this._timeElapsedAfterLoading <= 1.0)
                {
                    break;
                }
                this.State = RangedSiegeWeapon.WeaponState.Idle;
                break;

            case RangedSiegeWeapon.WeaponState.Reloading:
                using (List <StandingPoint> .Enumerator enumerator = this.ReloadStandingPoints.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        StandingPoint current = enumerator.Current;
                        if (current.HasUser)
                        {
                            ActionIndexCache currentAction = current.UserAgent.GetCurrentAction(1);
                            if (currentAction == this._reload1AnimationActionIndex || currentAction == this._reload2AnimationActionIndex)
                            {
                                current.UserAgent.SetCurrentActionProgress(1, this._body.GameEntity.Skeleton.GetAnimationParameterAtChannel(0));
                            }
                            else if (!GameNetwork.IsClientOrReplay)
                            {
                                ActionIndexCache actionIndexCache = current == this.PilotStandingPoint ? this._reload1AnimationActionIndex : this._reload2AnimationActionIndex;
                                if (!current.UserAgent.SetActionChannel(1, actionIndexCache, startProgress: this._body.GameEntity.Skeleton.GetAnimationParameterAtChannel(0)))
                                {
                                    current.UserAgent.StopUsingGameObject();
                                }
                            }
                        }
                    }
                    break;
                }
            }
        }
コード例 #4
0
 protected internal override void OnTick(float dt)
 {
     base.OnTick(dt);
     if (!this.GameEntity.IsVisibleIncludeParents())
     {
         return;
     }
     if (this.PilotAgent != null)
     {
         this.PilotAgent.SetHandInverseKinematicsFrameFromActionChannel(1, this._pilotInitialLocalIKFrame, this.ballistaBody.GameEntity.GetGlobalFrame(), this.AnimationHeightDifference);
         ActionIndexCache currentAction = this.PilotAgent.GetCurrentAction(1);
         if (currentAction == this._pickUpAmmoEndAnimationActionIndex || currentAction == this._placeAmmoStartAnimationActionIndex)
         {
             MatrixFrame boneEntitialFrame = this.PilotAgent.AgentVisuals.GetSkeleton().GetBoneEntitialFrame((int)this.PilotAgent.Monster.MainHandItemBoneIndex);
             this.Projectile.GameEntity.SetGlobalFrame(this.PilotAgent.AgentVisuals.GetGlobalFrame().TransformToParent(boneEntitialFrame));
         }
         else
         {
             this.Projectile.GameEntity.SetFrame(ref this._missileInitialLocalFrame);
         }
     }
     if (GameNetwork.IsClientOrReplay)
     {
         return;
     }
     if (this.State == RangedSiegeWeapon.WeaponState.Reloading)
     {
         if (this.PilotAgent == null || this.PilotAgent.SetActionChannel(1, this._reloadAnimationActionIndex))
         {
             return;
         }
         this.PilotAgent.StopUsingGameObject();
     }
     else if (this.State == RangedSiegeWeapon.WeaponState.LoadingAmmo)
     {
         bool flag = false;
         if (this.PilotAgent != null)
         {
             ActionIndexCache currentAction = this.PilotAgent.GetCurrentAction(1);
             if (currentAction != this._pickUpAmmoStartAnimationActionIndex && currentAction != this._pickUpAmmoEndAnimationActionIndex && (currentAction != this._placeAmmoStartAnimationActionIndex && currentAction != this._placeAmmoEndAnimationActionIndex) && !this.PilotAgent.SetActionChannel(1, this._pickUpAmmoStartAnimationActionIndex))
             {
                 this.PilotAgent.StopUsingGameObject();
             }
             else if (currentAction == this._pickUpAmmoEndAnimationActionIndex || currentAction == this._placeAmmoStartAnimationActionIndex)
             {
                 flag = true;
             }
             else if (currentAction == this._placeAmmoEndAnimationActionIndex)
             {
                 flag       = true;
                 this.State = RangedSiegeWeapon.WeaponState.WaitingBeforeIdle;
             }
         }
         this.Projectile.SetVisibleSynched(flag);
     }
     else if (this.State == RangedSiegeWeapon.WeaponState.WaitingBeforeIdle)
     {
         if (this.PilotAgent == null)
         {
             this.State = RangedSiegeWeapon.WeaponState.Idle;
         }
         else
         {
             ActionIndexCache currentAction         = this.PilotAgent.GetCurrentAction(1);
             float            currentActionProgress = this.PilotAgent.GetCurrentActionProgress(1);
             ActionIndexCache animationActionIndex  = this._placeAmmoEndAnimationActionIndex;
             if (currentAction != animationActionIndex)
             {
                 this.PilotAgent.StopUsingGameObject();
             }
             else
             {
                 if ((double)currentActionProgress <= 0.999899983406067)
                 {
                     return;
                 }
                 this.State = RangedSiegeWeapon.WeaponState.Idle;
                 if (this.PilotAgent == null || this.PilotAgent.SetActionChannel(1, this._idleAnimationActionIndex))
                 {
                     return;
                 }
                 this.PilotAgent.StopUsingGameObject();
             }
         }
     }
     else
     {
         if (this.PilotAgent == null)
         {
             return;
         }
         if (MBMath.IsBetween((int)this.PilotAgent.GetCurrentActionType(0), 44, 48))
         {
             if (!(this.PilotAgent.GetCurrentAction(0) != Ballista.act_strike_bent_over))
             {
                 return;
             }
             this.PilotAgent.SetActionChannel(0, Ballista.act_strike_bent_over);
         }
         else
         {
             if (this.PilotAgent.SetActionChannel(1, this._idleAnimationActionIndex))
             {
                 return;
             }
             this.PilotAgent.StopUsingGameObject();
         }
     }
 }
 public override void InitializeAgentStats(
     Agent agent,
     Equipment spawnEquipment,
     AgentDrivenProperties agentDrivenProperties,
     AgentBuildData agentBuildData)
 {
     agentDrivenProperties.ArmorEncumbrance = spawnEquipment.GetTotalWeightOfArmor(agent.IsHuman);
     if (!agent.IsHuman)
     {
         AgentDrivenProperties drivenProperties1 = agentDrivenProperties;
         EquipmentElement      equipmentElement1 = spawnEquipment[EquipmentIndex.ArmorItemEndSlot];
         int internalValue = (int)equipmentElement1.Item.Id.InternalValue;
         drivenProperties1.AiSpeciesIndex = internalValue;
         AgentDrivenProperties drivenProperties2 = agentDrivenProperties;
         equipmentElement1 = spawnEquipment[EquipmentIndex.HorseHarness];
         double num1 = 0.800000011920929 + (equipmentElement1.Item != null ? 0.200000002980232 : 0.0);
         drivenProperties2.AttributeRiding = (float)num1;
         float num2 = 0.0f;
         for (int index = 1; index < 12; ++index)
         {
             equipmentElement1 = spawnEquipment[index];
             if (equipmentElement1.Item != null)
             {
                 double num3 = (double)num2;
                 equipmentElement1 = spawnEquipment[index];
                 double modifiedMountBodyArmor = (double)equipmentElement1.GetModifiedMountBodyArmor();
                 num2 = (float)(num3 + modifiedMountBodyArmor);
             }
         }
         agentDrivenProperties.ArmorTorso = num2;
         equipmentElement1 = spawnEquipment[EquipmentIndex.ArmorItemEndSlot];
         ItemObject itemObject = equipmentElement1.Item;
         if (itemObject != null)
         {
             float num3 = 1f;
             if (!agent.Mission.Scene.IsAtmosphereIndoor)
             {
                 if ((double)agent.Mission.Scene.GetRainDensity() > 0.0)
                 {
                     num3 *= 0.9f;
                 }
                 if (!MBMath.IsBetween(agent.Mission.Scene.TimeOfDay, 4f, 20.01f))
                 {
                     num3 *= 0.9f;
                 }
             }
             HorseComponent   horseComponent    = itemObject.HorseComponent;
             EquipmentElement mountElement      = spawnEquipment[EquipmentIndex.ArmorItemEndSlot];
             EquipmentElement equipmentElement2 = spawnEquipment[EquipmentIndex.HorseHarness];
             agentDrivenProperties.MountManeuver     = (float)mountElement.GetModifiedMountManeuver(in equipmentElement2);
             agentDrivenProperties.MountSpeed        = (float)((double)num3 * (double)(mountElement.GetModifiedMountSpeed(in equipmentElement2) + 1) * 0.219999998807907);
             agentDrivenProperties.MountChargeDamage = (float)mountElement.GetModifiedMountCharge(in equipmentElement2) * 0.01f;
             agentDrivenProperties.MountDifficulty   = (float)mountElement.Item.Difficulty;
             int effectiveSkill = this.GetEffectiveSkill(agent.RiderAgent.Character, agent.RiderAgent.Origin, agent.RiderAgent.Formation, DefaultSkills.Riding);
             agentDrivenProperties.TopSpeedReachDuration = Game.Current.BasicModels.RidingModel.CalculateAcceleration(in mountElement, in equipmentElement2, effectiveSkill);
             if (agent.RiderAgent != null)
             {
                 agentDrivenProperties.MountSpeed    *= (float)(1.0 + (double)effectiveSkill * (1.0 / 1000.0));
                 agentDrivenProperties.MountManeuver *= (float)(1.0 + (double)effectiveSkill * 0.00039999998989515);
             }
         }
     }
     else
     {
         agentDrivenProperties.ArmorHead  = spawnEquipment.GetHeadArmorSum();
         agentDrivenProperties.ArmorTorso = spawnEquipment.GetHumanBodyArmorSum();
         agentDrivenProperties.ArmorLegs  = spawnEquipment.GetLegArmorSum();
         agentDrivenProperties.ArmorArms  = spawnEquipment.GetArmArmorSum();
     }
     foreach (DrivenPropertyBonusAgentComponent bonusAgentComponent in agent.Components.OfType <DrivenPropertyBonusAgentComponent>())
     {
         if (MBMath.IsBetween((int)bonusAgentComponent.DrivenProperty, 0, 56))
         {
             float num = agentDrivenProperties.GetStat(bonusAgentComponent.DrivenProperty) + bonusAgentComponent.DrivenPropertyBonus;
             agentDrivenProperties.SetStat(bonusAgentComponent.DrivenProperty, num);
         }
     }
 }