示例#1
0
 protected internal override void OnTick(float dt)
 {
     base.OnTick(dt);
     foreach (StandingPoint standingPoint in this.StandingPoints)
     {
         if (standingPoint.HasUser)
         {
             Agent            userAgent      = standingPoint.UserAgent;
             ActionIndexCache currentAction1 = userAgent.GetCurrentAction(0);
             ActionIndexCache currentAction2 = userAgent.GetCurrentAction(1);
             if (!(currentAction2 == ActionIndexCache.act_none) || !(currentAction1 == ExitDoor.act_pickup_middle_begin) && !(currentAction1 == ExitDoor.act_pickup_middle_begin_left_stance))
             {
                 if (currentAction2 == ActionIndexCache.act_none && (currentAction1 == ExitDoor.act_pickup_middle_end || currentAction1 == ExitDoor.act_pickup_middle_end_left_stance))
                 {
                     Mission.Current.EndMission();
                     userAgent.StopUsingGameObject();
                 }
                 else if (currentAction2 != ActionIndexCache.act_none || !userAgent.SetActionChannel(0, userAgent.GetIsLeftStance() ? ExitDoor.act_pickup_middle_begin_left_stance : ExitDoor.act_pickup_middle_begin))
                 {
                     userAgent.StopUsingGameObject();
                 }
             }
         }
     }
 }
示例#2
0
 public static void SetAgentActionChannel(
     this Skeleton skeleton,
     int actionChannelNo,
     ActionIndexCache actionIndex,
     float channelParameter    = 0.0f,
     float blendPeriodOverride = -0.2f)
 {
     MBAPI.IMBSkeletonExtensions.SetAgentActionChannel(skeleton.Pointer, actionChannelNo, actionIndex.Index, channelParameter, blendPeriodOverride);
 }
 protected override void RegisterAnimationParameters()
 {
     this.SkeletonOwnerObject                  = this.ballistaBody;
     this.skeletonName                         = "ballista_skeleton";
     this.fireAnimation                        = "ballista_fire";
     this.setUpAnimation                       = "ballista_set_up";
     this._idleAnimationActionIndex            = ActionIndexCache.Create(this.IdleActionName);
     this._reloadAnimationActionIndex          = ActionIndexCache.Create(this.ReloadActionName);
     this._placeAmmoStartAnimationActionIndex  = ActionIndexCache.Create(this.PlaceAmmoStartActionName);
     this._placeAmmoEndAnimationActionIndex    = ActionIndexCache.Create(this.PlaceAmmoEndActionName);
     this._pickUpAmmoStartAnimationActionIndex = ActionIndexCache.Create(this.PickUpAmmoStartActionName);
     this._pickUpAmmoEndAnimationActionIndex   = ActionIndexCache.Create(this.PickUpAmmoEndActionName);
 }
 protected internal override void OnTick(float dt)
 {
     base.OnTick(dt);
     if ((NativeObject)this._markerBeam != (NativeObject)null)
     {
         if ((double)Math.Abs(this._markerAlpha - this._targetMarkerAlpha) > (double)dt * (double)this._markerAlphaChangeAmount)
         {
             this._markerAlpha += dt * this._markerAlphaChangeAmount * (float)Math.Sign(this._targetMarkerAlpha - this._markerAlpha);
             this._markerBeam.GetChildren().First <GameEntity>().GetFirstMesh().SetVectorArgument(this._markerAlpha, 1f, 0.49f, 11.65f);
         }
         else
         {
             this._markerAlpha = this._targetMarkerAlpha;
             if ((double)this._targetMarkerAlpha == 0.0)
             {
                 this._markerBeam?.SetVisibilityExcludeParents(false);
             }
         }
     }
     foreach (StandingPoint standingPoint in this.StandingPoints)
     {
         if (standingPoint.HasUser)
         {
             Agent            userAgent      = standingPoint.UserAgent;
             ActionIndexCache currentAction1 = userAgent.GetCurrentAction(0);
             ActionIndexCache currentAction2 = userAgent.GetCurrentAction(1);
             if (!(currentAction2 == ActionIndexCache.act_none) || !(currentAction1 == TrainingIcon.act_pickup_middle_begin) && !(currentAction1 == TrainingIcon.act_pickup_middle_begin_left_stance))
             {
                 if (currentAction2 == ActionIndexCache.act_none && (currentAction1 == TrainingIcon.act_pickup_middle_end || currentAction1 == TrainingIcon.act_pickup_middle_end_left_stance))
                 {
                     this._activated = true;
                     userAgent.StopUsingGameObject();
                 }
                 else if (currentAction2 != ActionIndexCache.act_none || !userAgent.SetActionChannel(0, userAgent.GetIsLeftStance() ? TrainingIcon.act_pickup_middle_begin_left_stance : TrainingIcon.act_pickup_middle_begin))
                 {
                     userAgent.StopUsingGameObject();
                 }
             }
         }
     }
 }
 protected override void RegisterAnimationParameters()
 {
     this.SkeletonOwnerObjects               = new SynchedMissionObject[2];
     this.skeletonNames                      = new string[1];
     this.fireAnimations                     = new string[2];
     this.setUpAnimations                    = new string[2];
     this.SkeletonOwnerObjects[0]            = this._body;
     this.skeletonNames[0]                   = this.MangonelBodySkeleton;
     this.fireAnimations[0]                  = this.MangonelBodyFire;
     this.setUpAnimations[0]                 = this.MangonelBodyReload;
     this.SkeletonOwnerObjects[1]            = this._rope;
     this.fireAnimations[1]                  = this.MangonelRopeFire;
     this.setUpAnimations[1]                 = this.MangonelRopeReload;
     this.MissileBoneName                    = this.ProjectileBoneName;
     this._idleAnimationActionIndex          = ActionIndexCache.Create(this.IdleActionName);
     this._shootAnimationActionIndex         = ActionIndexCache.Create(this.ShootActionName);
     this._reload1AnimationActionIndex       = ActionIndexCache.Create(this.Reload1ActionName);
     this._reload2AnimationActionIndex       = ActionIndexCache.Create(this.Reload2ActionName);
     this._rotateLeftAnimationActionIndex    = ActionIndexCache.Create(this.RotateLeftActionName);
     this._rotateRightAnimationActionIndex   = ActionIndexCache.Create(this.RotateRightActionName);
     this._loadAmmoBeginAnimationActionIndex = ActionIndexCache.Create(this.LoadAmmoBeginActionName);
     this._loadAmmoEndAnimationActionIndex   = ActionIndexCache.Create(this.LoadAmmoEndActionName);
     this._reload2IdleActionIndex            = ActionIndexCache.Create(this.Reload2IdleActionName);
 }
示例#6
0
 protected internal override void OnTick(float dt)
 {
     if (!this._isVisible)
     {
         return;
     }
     base.OnTick(dt);
     if (GameNetwork.IsClientOrReplay)
     {
         return;
     }
     foreach (StandingPoint standingPoint in this.StandingPoints)
     {
         if (standingPoint.HasUser)
         {
             Agent            userAgent      = standingPoint.UserAgent;
             ActionIndexCache currentAction1 = userAgent.GetCurrentAction(0);
             ActionIndexCache currentAction2 = userAgent.GetCurrentAction(1);
             if (!(currentAction2 == ActionIndexCache.act_none) || !(currentAction1 == ArrowBarrel.act_pickup_down_begin) && !(currentAction1 == ArrowBarrel.act_pickup_down_begin_left_stance))
             {
                 if (currentAction2 == ActionIndexCache.act_none && (currentAction1 == ArrowBarrel.act_pickup_down_end || currentAction1 == ArrowBarrel.act_pickup_down_end_left_stance))
                 {
                     for (EquipmentIndex index = EquipmentIndex.WeaponItemBeginSlot; index < EquipmentIndex.NumAllWeaponSlots; ++index)
                     {
                         MissionWeapon missionWeapon = userAgent.Equipment[index];
                         if (!missionWeapon.IsEmpty)
                         {
                             missionWeapon = userAgent.Equipment[index];
                             if (missionWeapon.CurrentUsageItem.WeaponClass != WeaponClass.Arrow)
                             {
                                 missionWeapon = userAgent.Equipment[index];
                                 if (missionWeapon.CurrentUsageItem.WeaponClass != WeaponClass.Bolt)
                                 {
                                     continue;
                                 }
                             }
                             missionWeapon = userAgent.Equipment[index];
                             int amount = (int)missionWeapon.Amount;
                             missionWeapon = userAgent.Equipment[index];
                             int modifiedMaxAmount1 = (int)missionWeapon.ModifiedMaxAmount;
                             if (amount < modifiedMaxAmount1)
                             {
                                 Agent agent = userAgent;
                                 int   num   = (int)index;
                                 missionWeapon = userAgent.Equipment[index];
                                 int modifiedMaxAmount2 = (int)missionWeapon.ModifiedMaxAmount;
                                 agent.SetWeaponAmountInSlot((EquipmentIndex)num, (short)modifiedMaxAmount2, true);
                                 Mission.Current.MakeSoundOnlyOnRelatedPeer(ArrowBarrel._pickupArrowSoundFromBarrelCache, userAgent.Position, userAgent.Index);
                             }
                         }
                     }
                     userAgent.StopUsingGameObject();
                 }
                 else if (currentAction2 != ActionIndexCache.act_none || !userAgent.SetActionChannel(0, userAgent.GetIsLeftStance() ? ArrowBarrel.act_pickup_down_begin_left_stance : ArrowBarrel.act_pickup_down_begin))
                 {
                     userAgent.StopUsingGameObject();
                 }
             }
         }
     }
 }
 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 AgentVisualsData ActionCode(ActionIndexCache actionCode)
 {
     this.ActionCodeData = actionCode;
     return(this);
 }
        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;
                }
            }
        }
示例#10
0
        protected internal override void OnTick(float dt)
        {
            base.OnTick(dt);
            if (!GameNetwork.IsClientOrReplay && this._tickOccasionallyTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission)))
            {
                this.TickOccasionally();
            }
            if (GameNetwork.IsClientOrReplay)
            {
                return;
            }
            List <StandingPoint> standingPointList = (List <StandingPoint>)null;
            List <Agent>         agentList         = (List <Agent>)null;

            foreach (StandingPoint ammoPickUpPoint in this.AmmoPickUpPoints)
            {
                if (ammoPickUpPoint.HasUser)
                {
                    ActionIndexCache currentAction = ammoPickUpPoint.UserAgent.GetCurrentAction(1);
                    if (!(currentAction == StonePile.act_pickup_boulder_begin))
                    {
                        if (currentAction == StonePile.act_pickup_boulder_end)
                        {
                            MissionWeapon weapon    = new MissionWeapon(this._givenItem, (ItemModifier)null, (Banner)null, (short)1);
                            Agent         userAgent = ammoPickUpPoint.UserAgent;
                            userAgent.EquipWeaponToExtraSlotAndWield(ref weapon);
                            userAgent.StopUsingGameObject();
                            this.ConsumeAmmo();
                            if (userAgent.IsAIControlled)
                            {
                                if (agentList == null)
                                {
                                    agentList = new List <Agent>();
                                }
                                agentList.Add(userAgent);
                            }
                        }
                        else if (!ammoPickUpPoint.UserAgent.SetActionChannel(1, StonePile.act_pickup_boulder_begin))
                        {
                            ammoPickUpPoint.UserAgent.StopUsingGameObject();
                        }
                    }
                }
                if (ammoPickUpPoint.HasAIUser || ammoPickUpPoint.HasAIMovingTo)
                {
                    if (standingPointList == null)
                    {
                        standingPointList = new List <StandingPoint>();
                    }
                    standingPointList.Add(ammoPickUpPoint);
                }
            }
            List <StonePile.ThrowingPoint> throwingPointList = (List <StonePile.ThrowingPoint>)null;

            foreach (StonePile.ThrowingPoint throwingPoint in this._throwingPoints)
            {
                throwingPoint.AmmoPickUpPoint = (StandingPointWithWeaponRequirement)null;
                if ((NativeObject)throwingPoint.AttackEntity != (NativeObject)null || throwingPoint.EnemyInRangeTimer.Check(Mission.Current.Time) && (double)throwingPoint.EnemyInRangeTimer.ElapsedTime() < 3.5)
                {
                    throwingPoint.StandingPoint.IsDeactivated = false;
                    MissionWeapon missionWeapon;
                    if (throwingPoint.StandingPoint.HasAIMovingTo)
                    {
                        Dictionary <Agent, UsableMissionObject.MoveInfo> .Enumerator enumerator = throwingPoint.StandingPoint.MovingAgents.GetEnumerator();
                        enumerator.MoveNext();
                        Agent          key = enumerator.Current.Key;
                        EquipmentIndex wieldedItemIndex = key.GetWieldedItemIndex(Agent.HandIndex.MainHand);
                        if (wieldedItemIndex != EquipmentIndex.None)
                        {
                            missionWeapon = key.Equipment[wieldedItemIndex];
                            if (missionWeapon.Item == this._givenItem)
                            {
                                continue;
                            }
                        }
                        key.StopUsingGameObject();
                    }
                    else if (throwingPoint.StandingPoint.HasUser)
                    {
                        Agent          userAgent        = throwingPoint.StandingPoint.UserAgent;
                        EquipmentIndex wieldedItemIndex = userAgent.GetWieldedItemIndex(Agent.HandIndex.MainHand);
                        if (wieldedItemIndex != EquipmentIndex.None)
                        {
                            missionWeapon = userAgent.Equipment[wieldedItemIndex];
                            if (missionWeapon.Item == this._givenItem)
                            {
                                if (userAgent.Controller == Agent.ControllerType.AI && (NativeObject)throwingPoint.AttackEntity != (NativeObject)null)
                                {
                                    userAgent.DisableScriptedCombatMovement();
                                    userAgent.SetScriptedTargetEntityAndPosition(throwingPoint.AttackEntity, new WorldPosition(throwingPoint.AttackEntity.Scene, UIntPtr.Zero, throwingPoint.AttackEntity.GlobalPosition, false));
                                    continue;
                                }
                                continue;
                            }
                        }
                        userAgent.StopUsingGameObject();
                        if (userAgent.Controller == Agent.ControllerType.AI)
                        {
                            userAgent.DisableScriptedCombatMovement();
                        }
                    }
                    else
                    {
                        if (throwingPointList == null)
                        {
                            throwingPointList = new List <StonePile.ThrowingPoint>();
                        }
                        throwingPointList.Add(throwingPoint);
                    }
                }
                else
                {
                    throwingPoint.StandingPoint.IsDeactivated = true;
                }
            }
            if (standingPointList != null)
            {
                for (int index = 0; index < standingPointList.Count; ++index)
                {
                    if (throwingPointList != null && throwingPointList.Count > index)
                    {
                        throwingPointList[index].AmmoPickUpPoint = standingPointList[index] as StandingPointWithWeaponRequirement;
                    }
                    else
                    {
                        standingPointList[index].UserAgent?.StopUsingGameObject();
                        if (standingPointList[index].HasAIMovingTo)
                        {
                            foreach (KeyValuePair <Agent, UsableMissionObject.MoveInfo> keyValuePair in standingPointList[index].MovingAgents.ToList <KeyValuePair <Agent, UsableMissionObject.MoveInfo> >())
                            {
                                keyValuePair.Key.StopUsingGameObject();
                            }
                            standingPointList[index].MovingAgents.Clear();
                        }
                    }
                }
            }
            if (agentList == null)
            {
                return;
            }
            foreach (Agent agent in agentList)
            {
                this.AssignAgentToStandingPoint(this.GetSuitableStandingPointFor(this.Side, agent, (IEnumerable <Agent>)null, (IEnumerable <AgentValuePair <float> >)null), agent);
            }
        }
示例#11
0
        public void SpawnAgentVisualsForPeer(
            MissionPeer missionPeer,
            AgentBuildData buildData,
            int selectedEquipmentSetIndex = -1,
            bool isBot          = false,
            int totalTroopCount = 0)
        {
            NetworkCommunicator myPeer = GameNetwork.MyPeer;

            if (myPeer != null)
            {
                myPeer.GetComponent <MissionPeer>();
            }
            if (buildData.AgentVisualsIndex == 0)
            {
                missionPeer.ClearAllVisuals();
            }
            missionPeer.ClearVisuals(buildData.AgentVisualsIndex);
            Equipment        overridenSpawnEquipment = buildData.AgentOverridenSpawnEquipment;
            ItemObject       mountItem           = overridenSpawnEquipment[10].Item;
            MatrixFrame      pointFrameForPlayer = this._spawnFrameSelectionHelper.GetSpawnPointFrameForPlayer(missionPeer.Peer, missionPeer.Team.Side, buildData.AgentVisualsIndex, totalTroopCount, mountItem != null);
            ActionIndexCache actionIndexCache1   = mountItem == null ? SpawningBehaviourBase.PoseActionInfantry : SpawningBehaviourBase.PoseActionCavalry;

            MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(buildData.AgentCharacter);
            IReadOnlyList <MPPerkObject>          selectedPerks     = missionPeer.SelectedPerks;
            float        parameter    = (float)(0.100000001490116 + (double)MBRandom.RandomFloat * 0.800000011920929);
            IAgentVisual mountVisuals = (IAgentVisual)null;

            if (mountItem != null)
            {
                Monster          monster = mountItem.HorseComponent.Monster;
                AgentVisualsData data    = new AgentVisualsData().Equipment(overridenSpawnEquipment).Scale(mountItem.ScaleFactor).Frame(MatrixFrame.Identity).ActionSet(MBGlobals.GetActionSet(monster.ActionSetCode)).Scene(Mission.Current.Scene).Monster(monster).PrepareImmediately(false).MountCreationKey(MountCreationKey.GetRandomMountKey(mountItem, MBRandom.RandomInt()));
                mountVisuals = Mission.Current.AgentVisualCreator.Create(data, "Agent " + buildData.AgentCharacter.StringId + " mount", true);
                MatrixFrame frame = pointFrameForPlayer;
                frame.rotation.ApplyScaleLocal(data.ScaleData);
                ActionIndexCache actionName = ActionIndexCache.act_none;
                foreach (MPPerkObject mpPerkObject in (IEnumerable <MPPerkObject>)selectedPerks)
                {
                    if (!isBot && mpPerkObject.HeroMountIdleAnimOverride != null)
                    {
                        actionName = ActionIndexCache.Create(mpPerkObject.HeroMountIdleAnimOverride);
                        break;
                    }
                    if (isBot && mpPerkObject.TroopMountIdleAnimOverride != null)
                    {
                        actionName = ActionIndexCache.Create(mpPerkObject.TroopMountIdleAnimOverride);
                        break;
                    }
                }
                if (actionName == ActionIndexCache.act_none)
                {
                    if (mountItem.StringId == "mp_aserai_camel")
                    {
                        Debug.Print("Client is spawning a camel for without mountCustomAction from the perk.", debugFilter: 17179869184UL);
                        actionName = isBot ? ActionIndexCache.Create("act_camel_idle_1") : ActionIndexCache.Create("act_hero_mount_idle_camel");
                    }
                    else
                    {
                        if (!isBot && !string.IsNullOrEmpty(classForCharacter.HeroMountIdleAnim))
                        {
                            actionName = ActionIndexCache.Create(classForCharacter.HeroMountIdleAnim);
                        }
                        if (isBot && !string.IsNullOrEmpty(classForCharacter.TroopMountIdleAnim))
                        {
                            actionName = ActionIndexCache.Create(classForCharacter.TroopMountIdleAnim);
                        }
                    }
                }
                if (actionName != ActionIndexCache.act_none)
                {
                    mountVisuals.SetAction(actionName);
                    mountVisuals.GetVisuals().GetSkeleton().SetAnimationParameterAtChannel(0, parameter);
                    mountVisuals.GetVisuals().GetSkeleton().TickAnimationsAndForceUpdate(0.1f, frame, true);
                }
                mountVisuals.GetVisuals().GetEntity().SetFrame(ref frame);
            }
            ActionIndexCache actionIndexCache2 = actionIndexCache1;

            if (mountVisuals != null)
            {
                actionIndexCache2 = mountVisuals.GetVisuals().GetSkeleton().GetActionAtChannel(0);
            }
            else
            {
                foreach (MPPerkObject mpPerkObject in (IEnumerable <MPPerkObject>)selectedPerks)
                {
                    if (!isBot && mpPerkObject.HeroIdleAnimOverride != null)
                    {
                        actionIndexCache2 = ActionIndexCache.Create(mpPerkObject.HeroIdleAnimOverride);
                        break;
                    }
                    if (isBot && mpPerkObject.TroopIdleAnimOverride != null)
                    {
                        actionIndexCache2 = ActionIndexCache.Create(mpPerkObject.TroopIdleAnimOverride);
                        break;
                    }
                }
                if (actionIndexCache2 == actionIndexCache1)
                {
                    if (!isBot && !string.IsNullOrEmpty(classForCharacter.HeroIdleAnim))
                    {
                        actionIndexCache2 = ActionIndexCache.Create(classForCharacter.HeroIdleAnim);
                    }
                    if (isBot && !string.IsNullOrEmpty(classForCharacter.TroopIdleAnim))
                    {
                        actionIndexCache2 = ActionIndexCache.Create(classForCharacter.TroopIdleAnim);
                    }
                }
            }
            IAgentVisual agentVisuals = Mission.Current.AgentVisualCreator.Create(new AgentVisualsData().Equipment(overridenSpawnEquipment).BodyProperties(buildData.AgentBodyProperties).Frame(pointFrameForPlayer).ActionSet(MBGlobals.PlayerMaleActionSet).Scene(Mission.Current.Scene).Monster(Game.Current.HumanMonster).PrepareImmediately(false).UseMorphAnims(true).SkeletonType(buildData.AgentIsFemale ? SkeletonType.Female : SkeletonType.Male).ClothColor1(buildData.AgentClothingColor1).ClothColor2(buildData.AgentClothingColor2).AddColorRandomness((uint)buildData.AgentVisualsIndex > 0U).ActionCode(actionIndexCache2), "Mission::SpawnAgentVisuals", true);

            agentVisuals.SetAction(actionIndexCache2);
            agentVisuals.GetVisuals().GetSkeleton().SetAnimationParameterAtChannel(0, parameter);
            agentVisuals.GetVisuals().GetSkeleton().TickAnimationsAndForceUpdate(0.1f, pointFrameForPlayer, true);
            agentVisuals.GetVisuals().SetFrame(ref pointFrameForPlayer);
            agentVisuals.SetCharacterObjectID(buildData.AgentCharacter.StringId);
            EquipmentIndex mainHandWeaponIndex;
            EquipmentIndex offHandWeaponIndex;
            bool           isMainHandNotUsableWithOneHand;

            overridenSpawnEquipment.GetInitialWeaponIndicesToEquip(out mainHandWeaponIndex, out offHandWeaponIndex, out isMainHandNotUsableWithOneHand);
            if (isMainHandNotUsableWithOneHand)
            {
                offHandWeaponIndex = EquipmentIndex.None;
            }
            agentVisuals.GetVisuals().SetWieldedWeaponIndices((int)mainHandWeaponIndex, (int)offHandWeaponIndex);
            PeerVisualsHolder visualsHolder = new PeerVisualsHolder(missionPeer, buildData.AgentVisualsIndex, agentVisuals, mountVisuals);

            missionPeer.OnVisualsSpawned(visualsHolder, visualsHolder.VisualsIndex);
            if (buildData.AgentVisualsIndex == 0)
            {
                missionPeer.HasSpawnedAgentVisuals   = true;
                missionPeer.EquipmentUpdatingExpired = false;
            }
            if (!missionPeer.IsMine || buildData.AgentVisualsIndex != 0)
            {
                return;
            }
            Action agentVisualSpawned = this.OnMyAgentVisualSpawned;

            if (agentVisualSpawned == null)
            {
                return;
            }
            agentVisualSpawned();
        }
示例#12
0
 public void SetAction(ActionIndexCache actionName, float startProgress = 0.0f)
 {
 }