示例#1
0
    public IEnumerable <SimulationDescriptor> GetDescriptors()
    {
        int num;

        for (int index = 0; index < this.BoosterDefinition.Descriptors.Length; index = num + 1)
        {
            yield return(this.BoosterDefinition.Descriptors[index]);

            num = index;
        }
        if (this.BoosterDefinition.Effects != null)
        {
            for (int index = 0; index < this.BoosterDefinition.Effects.Length; index = num + 1)
            {
                BoosterEffect effect = this.BoosterDefinition.Effects[index];
                if (Booster.CheckPrerequisites(effect, this.Context))
                {
                    for (int i = 0; i < effect.SimulationDescriptors.Length; i = num + 1)
                    {
                        yield return(effect.SimulationDescriptors[i]);

                        num = i;
                    }
                }
                effect = null;
                num    = index;
            }
        }
        yield break;
    }
示例#2
0
    public void Activate()
    {
        if (!Booster.CanActivate(this.BoosterDefinition, this.Context))
        {
            return;
        }
        if (this.IsActive())
        {
            this.OnReactivation();
            if (this.BoosterDefinition.BoosterType == BoosterDefinition.Type.ResettingTime)
            {
                return;
            }
        }
        else
        {
            if (this.BoosterDefinition.BoosterType == BoosterDefinition.Type.Instant)
            {
                this.Duration = 0;
            }
            else
            {
                this.TurnWhenStarted = this.game.Turn;
                this.Context.AddChild(this);
                this.ApplyClassTimedDescriptor();
                this.ApplyDescriptors(true);
                this.RemainingTime = this.Duration;
            }
            this.ApplyEffects();
            this.Context.Refresh(false);
        }
        if (this.game != null)
        {
            IVisibilityService service = this.game.Services.GetService <IVisibilityService>();
            if (service != null && this.empire != null)
            {
                service.NotifyVisibilityHasChanged(this.empire);
            }
        }
        if (this.BoosterDefinition.Effects != null)
        {
            for (int i = 0; i < this.BoosterDefinition.Effects.Length; i++)
            {
                BoosterEffect effect = this.BoosterDefinition.Effects[i];
                if (Booster.CheckPrerequisites(effect, this.Context))
                {
                    this.ExecuteCommands(effect);
                }
            }
        }
        IEventService service2 = Services.GetService <IEventService>();

        if (service2 != null)
        {
            service2.Notify(new EventBoosterActivated(this.empire, this));
        }
    }
示例#3
0
 protected static bool CanApplyAtLeastOneEffect(BoosterDefinition boosterDefinition, SimulationObjectWrapper context)
 {
     if (boosterDefinition.Effects == null)
     {
         return(false);
     }
     for (int i = 0; i < boosterDefinition.Effects.Length; i++)
     {
         if (Booster.CheckPrerequisites(boosterDefinition.Effects[i], context))
         {
             return(true);
         }
     }
     return(false);
 }
示例#4
0
 public void ApplyEffects()
 {
     if (this.BoosterDefinition.Effects == null)
     {
         return;
     }
     for (int i = 0; i < this.BoosterDefinition.Effects.Length; i++)
     {
         BoosterEffect boosterEffect = this.BoosterDefinition.Effects[i];
         if (Booster.CheckPrerequisites(boosterEffect, this.Context))
         {
             this.ExecuteTransferResource(boosterEffect);
             if (boosterEffect.SimulationDescriptors != null)
             {
                 for (int j = 0; j < boosterEffect.SimulationDescriptors.Length; j++)
                 {
                     base.AddDescriptor(boosterEffect.SimulationDescriptors[j], false);
                 }
             }
         }
     }
 }