示例#1
0
 private void HoldPsionic()
 {
     if (this.m_Ship == null || this.m_HoldPsionic == null)
     {
         return;
     }
     if (this.m_Ship.Target == null)
     {
         this.ClearHoldPsionic();
     }
     else if (this.m_HoldPsionic.IsActive)
     {
         if ((double)this.m_HoldPsionic.PercentConsumed > 0.949999988079071)
         {
             this.ClearHoldPsionic();
         }
         else if (this.m_HoldPsionic is PsiDrain && this.m_Ship.CurrentPsiPower >= this.m_Ship.MaxPsiPower)
         {
             this.ClearHoldPsionic();
         }
     }
     else
     {
         this.ClearHoldPsionic();
     }
     if (this.m_HoldPsionic != null)
     {
         return;
     }
     this.m_State = PsionicControlState.Think;
 }
示例#2
0
 public ShipPsionicControl(App game, CombatAI commanderAI, Ship ship)
 {
     this.m_Game               = game;
     this.m_CommanderAI        = commanderAI;
     this.m_Ship               = ship;
     this.m_HoldPsionic        = (Psionic)null;
     this.m_MinFrames          = ship.IsSuulka ? ShipPsionicControl.kSuulkaMinThinkDelay : ShipPsionicControl.kMinThinkDelay;
     this.m_MaxFrames          = ship.IsSuulka ? ShipPsionicControl.kSuulkaMaxThinkDelay : ShipPsionicControl.kMaxThinkDelay;
     this.m_CurrMaxUpdateFrame = commanderAI.AIRandom.NextInclusive(this.m_MinFrames, this.m_MaxFrames);
     this.m_CurrUpdateFrame    = this.m_CurrMaxUpdateFrame;
     this.m_State              = PsionicControlState.Think;
 }
示例#3
0
 private void Think(int framesElapsed)
 {
     if (this.m_Ship.Target == null || !ShipPsionicControl.PsionicsCanBeUsed(this.m_Ship, this.m_CommanderAI))
     {
         this.m_CurrUpdateFrame = this.m_CurrMaxUpdateFrame;
     }
     else if (this.m_Ship.Target is Ship && !Ship.IsActiveShip(this.m_Ship.Target as Ship) || this.m_Ship.Target is StellarBody && (this.m_Ship.Target as StellarBody).Population <= 0.0)
     {
         this.m_CurrUpdateFrame = this.m_CurrMaxUpdateFrame;
     }
     else
     {
         this.m_CurrUpdateFrame -= framesElapsed;
         if (this.m_CurrUpdateFrame > 0)
         {
             return;
         }
         this.m_CurrMaxUpdateFrame = this.m_CommanderAI.AIRandom.NextInclusive(this.m_MinFrames, this.m_MaxFrames);
         this.m_CurrUpdateFrame    = this.m_CurrMaxUpdateFrame;
         this.m_State = PsionicControlState.ChoosePsionic;
     }
 }
示例#4
0
        private void ChoosePsionic()
        {
            if (this.m_Ship == null || this.m_Ship.Target == null)
            {
                return;
            }
            this.m_HoldPsionic = (Psionic)null;
            Psionic psionic1 = (Psionic)null;
            float   maxValue = 0.0f;
            Dictionary <Psionic, float> dictionary = new Dictionary <Psionic, float>();

            foreach (Psionic psionic2 in this.m_Ship.Psionics)
            {
                float weightForPsionic = ShipPsionicControl.GetWeightForPsionic(this.m_CommanderAI, this.m_Ship, psionic2);
                if ((double)weightForPsionic > 0.0)
                {
                    dictionary.Add(psionic2, weightForPsionic);
                    maxValue += weightForPsionic;
                }
            }
            if (dictionary.Count == 0)
            {
                this.m_State = PsionicControlState.Think;
            }
            else
            {
                float num = this.m_CommanderAI.AIRandom.NextInclusive(1f, maxValue);
                foreach (KeyValuePair <Psionic, float> keyValuePair in dictionary)
                {
                    if ((double)num <= (double)keyValuePair.Value)
                    {
                        psionic1 = keyValuePair.Key;
                        break;
                    }
                    num -= keyValuePair.Value;
                }
                if (psionic1 == null)
                {
                    return;
                }
                psionic1.Activate();
                if (ShipPsionicControl.IsHoldPsionic(psionic1))
                {
                    this.m_State       = PsionicControlState.HoldPsionic;
                    this.m_HoldPsionic = psionic1;
                }
                else
                {
                    switch (psionic1.Type)
                    {
                    case SectionEnumerations.PsionicAbility.Repair:
                    case SectionEnumerations.PsionicAbility.Inspiration:
                    case SectionEnumerations.PsionicAbility.Block:
                        psionic1.PostSetProp("SetTarget", (IGameObject)this.m_CommanderAI.GetFriendlyShips()[this.m_CommanderAI.AIRandom.Next(this.m_CommanderAI.GetFriendlyShips().Count)]);
                        break;

                    default:
                        psionic1.PostSetProp("SetTarget", this.m_Ship.Target.ObjectID);
                        break;
                    }
                    psionic1.Deactivate();
                    this.m_State = PsionicControlState.Think;
                }
            }
        }