示例#1
0
 private bool IsThrowingPointAssignable(StonePile.ThrowingPoint throwingPoint, Agent agent = null)
 {
     if (throwingPoint == null || throwingPoint.StandingPoint.IsDeactivated || (throwingPoint.AmmoPickUpPoint != null || throwingPoint.StandingPoint.HasUser) || throwingPoint.StandingPoint.HasAIMovingTo)
     {
         return(false);
     }
     if (agent == null)
     {
         return(true);
     }
     return(StonePileAI.IsAgentAssignable(agent) && !throwingPoint.StandingPoint.IsDisabledForAgent(agent));
 }
示例#2
0
        protected internal override void OnInit()
        {
            base.OnInit();
            this._tickOccasionallyTimer = new Timer(MBCommon.GetTime(MBCommon.TimeType.Mission), (float)(0.5 + (double)MBRandom.RandomFloat * 0.5));
            this._givenItem             = Game.Current.ObjectManager.GetObject <ItemObject>(this.GivenItemID);
            List <VolumeBox> source = this.GameEntity.CollectObjects <VolumeBox>();

            this._throwingPoints      = new List <StonePile.ThrowingPoint>();
            this._volumeBoxTimerPairs = new List <StonePile.VolumeBoxTimerPair>();
            foreach (StandingPointWithWeaponRequirement weaponRequirement in this.StandingPoints.OfType <StandingPointWithWeaponRequirement>())
            {
                if (weaponRequirement.GameEntity.HasTag(this.AmmoPickUpTag))
                {
                    weaponRequirement.InitGivenWeapon(this._givenItem);
                    weaponRequirement.SetHasAlternative(true);
                }
                else if (weaponRequirement.GameEntity.HasTag(this.ThrowingPointTag))
                {
                    weaponRequirement.InitRequiredWeapon(this._givenItem);
                    StonePile.ThrowingPoint throwingPoint = new StonePile.ThrowingPoint();
                    throwingPoint.StandingPoint   = weaponRequirement as StandingPointWithVolumeBox;
                    throwingPoint.AmmoPickUpPoint = (StandingPointWithWeaponRequirement)null;
                    throwingPoint.AttackEntity    = (GameEntity)null;
                    bool flag = false;
                    for (int index = 0; index < this._volumeBoxTimerPairs.Count && !flag; ++index)
                    {
                        if (this._volumeBoxTimerPairs[index].VolumeBox.GameEntity.HasTag(throwingPoint.StandingPoint.VolumeBoxTag))
                        {
                            throwingPoint.EnemyInRangeTimer = this._volumeBoxTimerPairs[index].Timer;
                            flag = true;
                        }
                    }
                    if (!flag)
                    {
                        VolumeBox volumeBox = source.FirstOrDefault <VolumeBox>((Func <VolumeBox, bool>)(vb => vb.GameEntity.HasTag(throwingPoint.StandingPoint.VolumeBoxTag)));
                        StonePile.VolumeBoxTimerPair volumeBoxTimerPair = new StonePile.VolumeBoxTimerPair();
                        volumeBoxTimerPair.VolumeBox    = volumeBox;
                        volumeBoxTimerPair.Timer        = new Timer(-3.5f, 0.5f, false);
                        throwingPoint.EnemyInRangeTimer = volumeBoxTimerPair.Timer;
                        this._volumeBoxTimerPairs.Add(volumeBoxTimerPair);
                    }
                    this._throwingPoints.Add(throwingPoint);
                }
            }
            this.EnemyRangeToStopUsing = 5f;
            this.AmmoCount             = this.StartingAmmoCount;
            this.UpdateAmmoMesh();
            this.SetScriptComponentToTick(this.GetTickRequirement());
        }
示例#3
0
        protected override StandingPoint GetSuitableStandingPointFor(
            BattleSideEnum side,
            Agent agent = null,
            IEnumerable <Agent> agents = null,
            IEnumerable <AgentValuePair <float> > agentValuePairs = null)
        {
            List <Agent> agentList = new List <Agent>();

            if (agents == null)
            {
                if (agent != null)
                {
                    agentList.Add(agent);
                }
                else if (agentValuePairs != null)
                {
                    foreach (AgentValuePair <float> agentValuePair in agentValuePairs)
                    {
                        agentList.Add(agentValuePair.Agent);
                    }
                }
            }
            else
            {
                agentList = new List <Agent>(agents);
            }
            bool          flag1          = false;
            StandingPoint standingPoint1 = (StandingPoint)null;

            for (int index1 = 0; index1 < this._throwingPoints.Count && standingPoint1 == null; ++index1)
            {
                StonePile.ThrowingPoint throwingPoint = this._throwingPoints[index1];
                if (this.IsThrowingPointAssignable(throwingPoint))
                {
                    bool flag2 = agentList == null;
                    for (int index2 = 0; !flag2 && index2 < agentList.Count; ++index2)
                    {
                        flag2 = !throwingPoint.StandingPoint.IsDisabledForAgent(agentList[index2]);
                    }
                    if (flag2)
                    {
                        if (standingPoint1 == null)
                        {
                            standingPoint1 = (StandingPoint)throwingPoint.StandingPoint;
                        }
                    }
                    else
                    {
                        flag1 = true;
                    }
                }
            }
            for (int index1 = 0; index1 < this.StandingPoints.Count && standingPoint1 == null; ++index1)
            {
                StandingPoint standingPoint2 = this.StandingPoints[index1];
                if (!standingPoint2.IsDeactivated && (standingPoint2.IsInstantUse || !standingPoint2.HasUser && !standingPoint2.HasAIMovingTo) && (!standingPoint2.GameEntity.HasTag(this.ThrowingPointTag) && (flag1 || !standingPoint2.GameEntity.HasTag(this.AmmoPickUpTag))))
                {
                    for (int index2 = 0; index2 < agentList.Count && standingPoint1 == null; ++index2)
                    {
                        if (!standingPoint2.IsDisabledForAgent(agentList[index2]))
                        {
                            standingPoint1 = standingPoint2;
                        }
                    }
                    if (agentList.Count == 0)
                    {
                        standingPoint1 = standingPoint2;
                    }
                }
            }
            return(standingPoint1);
        }