Exemplo n.º 1
0
 public override void Pack(BinaryWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     base.Pack(writer);
     writer.Write(this.InsertAtFirstPlace);
     Diagnostics.Assert(!StaticString.IsNullOrEmpty(this.ConstructibleElementName));
     writer.Write(this.ConstructionGameEntityGUID);
     writer.Write(this.ConstructibleElementName);
     if (this.ResourceStocks == null)
     {
         writer.Write(0);
         return;
     }
     writer.Write(this.ResourceStocks.Length);
     for (int i = 0; i < this.ResourceStocks.Length; i++)
     {
         Diagnostics.Assert(this.ResourceStocks[i] != null);
         Diagnostics.Assert(!StaticString.IsNullOrEmpty(this.ResourceStocks[i].PropertyName));
         writer.Write(this.ResourceStocks[i].PropertyName);
         writer.Write(this.ResourceStocks[i].Stock);
     }
 }
Exemplo n.º 2
0
    protected override void ExecuteNeeds(StaticString context, StaticString pass)
    {
        base.ExecuteNeeds(context, pass);
        this.colossusData.Clear();
        for (int i = 0; i < this.departmentOfDefense.Armies.Count; i++)
        {
            AIData_Army aidata = this.aiDataRepositoryHelper.GetAIData <AIData_Army>(this.departmentOfDefense.Armies[i].GUID);
            if (aidata != null && aidata.IsColossus)
            {
                this.colossusData.Add(aidata);
            }
        }
        int index;

        for (index = 0; index < this.colossusData.Count; index++)
        {
            if (!this.aiCommanders.Exists((AICommander match) => match.ForceArmyGUID == this.colossusData[index].Army.GUID))
            {
                this.AddCommander(new AICommander_Colossus
                {
                    ForceArmyGUID = this.colossusData[index].Army.GUID,
                    Empire        = base.AIEntity.Empire,
                    AIPlayer      = base.AIEntity.AIPlayer
                });
            }
        }
        this.UpdateColossusMissions();
    }
Exemplo n.º 3
0
 public SpellUsageTracker(GameEntityGUID encounterGUID, int empireIndex, StaticString spellUsed)
 {
     this.EncounterGUID = encounterGUID;
     this.EmpireIndex   = empireIndex;
     this.spellsUsed    = new List <StaticString>();
     this.spellsUsed.Add(spellUsed);
 }
Exemplo n.º 4
0
 public BattleSimulationArmy(SimulationObject simulationObject, BattleContender contender) : base(simulationObject)
 {
     if (simulationObject == null)
     {
         throw new ArgumentNullException("simulationObject");
     }
     if (contender == null)
     {
         throw new ArgumentNullException("contender");
     }
     this.contender = contender;
     if (contender.DefaultTargetingStrategy != null)
     {
         StaticString armyBattleTargetingStrategy = contender.DefaultTargetingStrategy;
         this.ArmyBattleTargetingStrategy       = armyBattleTargetingStrategy;
         this.ArmyBattleTargetingWantedStrategy = armyBattleTargetingStrategy;
     }
     else
     {
         StaticString armyBattleTargetingStrategy = BattleEncounter.GetDefaultStrategy();
         this.ArmyBattleTargetingWantedStrategy = armyBattleTargetingStrategy;
         this.ArmyBattleTargetingStrategy       = armyBattleTargetingStrategy;
     }
     this.WaitingArmyActions = new List <BattleArmyAction>();
 }
Exemplo n.º 5
0
    public static string FindKaijuFactionIconPath(global::Empire empire, StaticString size)
    {
        string text  = KaijuCouncil.KaijuGenericIconName;
        string text2 = size;

        if (text2 == "LogoLarge")
        {
            text2 = "Large";
        }
        else if (text2 == "LogoSmall")
        {
            text2 = "Small";
        }
        if (empire.SimulationObject.Tags.Contains("AffinityKaijus1"))
        {
            text = "Kaiju1Icon";
        }
        else if (empire.SimulationObject.Tags.Contains("AffinityKaijus2"))
        {
            text = "Kaiju2Icon";
        }
        else if (empire.SimulationObject.Tags.Contains("AffinityKaijus3"))
        {
            text = "Kaiju3Icon";
        }
        global::IGuiService service = Services.GetService <global::IGuiService>();
        GuiElement          guiElement;

        if (service.GuiPanelHelper.TryGetGuiElement(text, out guiElement))
        {
            text = guiElement.Icons[text2];
        }
        return(text);
    }
Exemplo n.º 6
0
        private void SetNetworkStatistic(StaticString statisticName, float statisticValue)
        {
            AchievementStatistic statistic = this.GetStatistic(statisticName);

            if (statistic != null)
            {
                if (statistic.Type == AchievementStatistic.StatisticType.Float)
                {
                    this.SetNetworkStatisticFloat(statisticName, statisticValue);
                }
                else if (statistic.Type == AchievementStatistic.StatisticType.Int)
                {
                    this.SetNetworkStatisticInteger(statisticName, (int)statisticValue);
                }
                if (this.OnStatisticSet != null)
                {
                    this.OnStatisticSet(this, new EventArgs());
                }
                if (this.debug)
                {
                    Diagnostics.Log("[Achievement Statistic] Network statistic (name: '{0}') has been set to '{1}'.", new object[]
                    {
                        statisticName,
                        statistic.Value
                    });
                }
            }
        }
Exemplo n.º 7
0
 protected override void CreateLocalNeeds(StaticString context, StaticString pass)
 {
     base.CreateLocalNeeds(context, pass);
     for (int i = this.boosterDefinitionWrappers.Count - 1; i >= 0; i--)
     {
         float num = this.boosterDefinitionWrappers[i].EvaluationFunction();
         this.boosterDefinitionWrappers[i].LastComputedPriority = num;
         CityBoosterNeeds cityBoosterNeeds;
         if (base.AIEntity.AIPlayer.Blackboard.TryGetMessage <CityBoosterNeeds>(this.boosterDefinitionWrappers[i].CurrentMessageId, out cityBoosterNeeds) && cityBoosterNeeds.State == BlackboardMessage.StateValue.Message_None)
         {
             if (cityBoosterNeeds.AvailabilityState == CityBoosterNeeds.CityBoosterState.Cancelled || num == 0f)
             {
                 base.AIEntity.AIPlayer.Blackboard.CancelMessage(cityBoosterNeeds);
             }
             else
             {
                 cityBoosterNeeds.BoosterPriority = num;
                 cityBoosterNeeds.TimeOut         = 1;
             }
         }
         else
         {
             this.GenerateEvaluateMessageFor(this.boosterDefinitionWrappers[i]);
         }
     }
 }
    private void OverrideAffinitiesDropListTooltips()
    {
        AgeControlPopup componentInChildren = this.AffinityDropList.GetComponentInChildren <AgeControlPopup>();

        if (componentInChildren != null)
        {
            List <AgeTransform> children = componentInChildren.AgeTransform.GetChildren();
            for (int i = 0; i < children.Count; i++)
            {
                if (i < this.affinityGuiTraits.Count)
                {
                    GuiFactionTrait guiFactionTrait = this.affinityGuiTraits[i];
                    for (int j = 0; j < guiFactionTrait.SubGuiTraits.Count; j++)
                    {
                        GuiFactionTrait guiFactionTrait2 = guiFactionTrait.SubGuiTraits[j];
                        if (guiFactionTrait2.Type == GuiFactionTrait.TraitType.Affinity)
                        {
                            AgeTooltip component = children[i].GetComponent <AgeTooltip>();
                            if (component != null)
                            {
                                StaticString relatedAffinity = StaticString.Empty;
                                if (this.SelectedAffinity != null)
                                {
                                    relatedAffinity = this.SelectedAffinity.Name;
                                }
                                guiFactionTrait2.GenerateTooltip(component, relatedAffinity);
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 9
0
 public bool ChangeMouseCursor(StaticString cursorName)
 {
     if (base.AgeManager == null)
     {
         return(false);
     }
     if (this.CursorName != cursorName)
     {
         IDatabase <GuiCursor> database = Databases.GetDatabase <GuiCursor>(false);
         if (database == null)
         {
             return(false);
         }
         GuiCursor guiCursor;
         if (database.TryGetValue(cursorName, out guiCursor))
         {
             Texture2D texture2D = base.AgeManager.FindDynamicTexture(guiCursor.Image.Path, false);
             if (texture2D != null)
             {
                 UnityEngine.Cursor.SetCursor(texture2D, guiCursor.HotSpot, CursorMode.Auto);
             }
         }
         else
         {
             Diagnostics.LogWarning("Unable to find GuiCursor of name {0}", new object[]
             {
                 cursorName
             });
         }
         this.CursorName = cursorName;
     }
     return(true);
 }
Exemplo n.º 10
0
        public static SeedCollection GetMostCurrentSeeds(StaticString shipName, int level)
        {
            if (Collections == null)
            {
                return(null);
            }
            SeedCollection best        = null;
            DateTime       now         = DateTime.Now;
            DateTime       currentBest = DateTime.MinValue;

            foreach (SeedCollection collection in Collections)
            {
                if (collection.GetSeedForShipLevel(shipName, level) == null)
                {
                    continue;
                }
                if (collection.ReadFrom.Length <= 0)
                {
                    // This collection hasn't been written/read from, so it is the most up to date.
                    return(collection);
                }
                if (File.Exists(collection.ReadFrom))
                {
                    DateTime current = File.GetLastWriteTime(collection.ReadFrom);
                    if ((now - current) < (now - currentBest))
                    {
                        best        = collection;
                        currentBest = current;
                    }
                }
            }
            return(best);
        }
Exemplo n.º 11
0
    public void RefreshTerrainDescriptors()
    {
        if (base.SimulationObject == null)
        {
            return;
        }
        IWorldPositionningService service = ((global::Game)Services.GetService <IGameService>().Game).GetService <IWorldPositionningService>();

        DepartmentOfTheInterior.RemoveAnyTerrainTypeDescriptor(base.SimulationObject);
        DepartmentOfTheInterior.RemoveAnyBiomeTypeDescriptor(base.SimulationObject);
        DepartmentOfTheInterior.RemoveAnyAnomalyDescriptor(base.SimulationObject);
        DepartmentOfTheInterior.RemoveAnyRiverTypeDescriptor(base.SimulationObject);
        byte         terrainType            = service.GetTerrainType(this.WorldPosition);
        StaticString terrainTypeMappingName = service.GetTerrainTypeMappingName(terrainType);

        DepartmentOfTheInterior.ApplyTerrainTypeDescriptor(base.SimulationObject, terrainTypeMappingName);
        byte         biomeType            = service.GetBiomeType(this.WorldPosition);
        StaticString biomeTypeMappingName = service.GetBiomeTypeMappingName(biomeType);

        DepartmentOfTheInterior.ApplyBiomeTypeDescriptor(base.SimulationObject, biomeTypeMappingName);
        byte         anomalyType            = service.GetAnomalyType(this.WorldPosition);
        StaticString anomalyTypeMappingName = service.GetAnomalyTypeMappingName(anomalyType);

        DepartmentOfTheInterior.ApplyAnomalyDescriptor(base.SimulationObject, anomalyTypeMappingName);
        short        riverId = service.GetRiverId(this.WorldPosition);
        StaticString riverTypeMappingName = service.GetRiverTypeMappingName(riverId);

        DepartmentOfTheInterior.ApplyRiverTypeDescriptor(base.SimulationObject, riverTypeMappingName);
        this.Refresh(false);
    }
Exemplo n.º 12
0
    public bool TryMakeUnexpectedImmediateExpense(StaticString accountName, float expense, float expensePriority)
    {
        int i = 0;

        while (i < this.accounts.Count)
        {
            Account account = this.accounts[i];
            if (account.AccountTag == accountName)
            {
                float num;
                if (expensePriority > account.WantedAmountPriority)
                {
                    num = account.GetAvailableAmountWithoutPromise();
                }
                else
                {
                    num = account.GetAvailableAmount();
                }
                if (num >= expense)
                {
                    account.EstimatedBalance -= expense;
                    return(true);
                }
                return(false);
            }
            else
            {
                i++;
            }
        }
        return(false);
    }
 public override void Release()
 {
     base.Release();
     this.gameEntityRepositoryService = null;
     this.questManagementService      = null;
     this.QuestName = null;
 }
Exemplo n.º 14
0
    public bool IsConstructible(WorldPosition position, StaticString pointOfInterestTemplatePropertyName, int bits = 0)
    {
        bool flag = this.IsConstructible(position, bits);

        if (flag)
        {
            Region region = this.GetRegion(position);
            if (region != null && region.PointOfInterests != null)
            {
                for (int i = 0; i < region.PointOfInterests.Length; i++)
                {
                    PointOfInterest pointOfInterest = region.PointOfInterests[i];
                    if (!(pointOfInterest.WorldPosition != position))
                    {
                        Diagnostics.Assert(pointOfInterest != null);
                        Diagnostics.Assert(pointOfInterest.PointOfInterestDefinition != null);
                        Diagnostics.Assert(pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplate != null);
                        string text;
                        if (pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplate.Properties != null && pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplate.Properties.TryGetValue(pointOfInterestTemplatePropertyName, out text))
                        {
                            flag = false;
                        }
                        break;
                    }
                }
            }
        }
        if (this.PillarService.IsPositionOccupiedByAPillar(position))
        {
            flag = false;
        }
        return(flag);
    }
Exemplo n.º 15
0
    public float ComputeResourceAvailabilityForUnit(StaticString resourceName)
    {
        Diagnostics.Assert(this.departmentOfTreasury != null);
        float num = 0f;

        if (!this.departmentOfTreasury.TryGetResourceStockValue(this.Empire.SimulationObject, resourceName, out num, false))
        {
            Diagnostics.LogWarning("{0} is not available in Empire {1}", new object[]
            {
                resourceName,
                this.Empire.Name
            });
        }
        float num2 = 0f;

        if (!this.departmentOfTreasury.TryGetNetResourceValue(this.Empire.SimulationObject, resourceName, out num2, false))
        {
            num2 = 0f;
        }
        float num3 = this.Empire.GetPropertyValue(SimulationProperties.NetCityProduction) / this.AverageUnitDesignProductionCost;
        float num4 = num2 / (num3 * (float)this.departmentOfTheInterior.Cities.Count);
        float num5 = num / 4f;

        return(num4 + num5);
    }
Exemplo n.º 16
0
    public Contender GetEnemyContenderWithAbilityFromContender(Contender contender, StaticString unitAbility)
    {
        Contender contender2 = null;

        if (this.Contenders != null)
        {
            for (int i = 0; i < this.Contenders.Count; i++)
            {
                if (this.Contenders[i].Group != contender.Group)
                {
                    if (contender2 != null && this.Contenders[i].IsMainContender)
                    {
                        contender2 = this.Contenders[i];
                    }
                    for (int j = 0; j < this.Contenders[i].EncounterUnits.Count; j++)
                    {
                        if (this.Contenders[i].EncounterUnits[j].Unit.CheckUnitAbility(unitAbility, -1))
                        {
                            return(this.Contenders[i]);
                        }
                    }
                }
            }
        }
        return(contender2);
    }
Exemplo n.º 17
0
    protected override void ExecuteNeeds(StaticString context, StaticString pass)
    {
        base.ExecuteNeeds(context, pass);
        ISynchronousJobRepositoryAIHelper service = AIScheduler.Services.GetService <ISynchronousJobRepositoryAIHelper>();

        if (this.availableNodes.Count > 0 && this.nodesPerPopulation > 0f)
        {
            service.RegisterSynchronousJob(new SynchronousJob(this.SyncrhronousJob_QueueNode));
        }
        List <CreepingNodeBuyoutMessage> list = new List <CreepingNodeBuyoutMessage>(base.AIEntity.AIPlayer.Blackboard.GetMessages <CreepingNodeBuyoutMessage>(BlackboardLayerID.Empire, (CreepingNodeBuyoutMessage match) => match.State != BlackboardMessage.StateValue.Message_Canceled));

        for (int i = list.Count - 1; i >= 0; i--)
        {
            CreepingNodeBuyoutMessage message = list[i];
            if (!this.IsMessageValid(message))
            {
                base.AIEntity.AIPlayer.Blackboard.CancelMessage(message);
                list.RemoveAt(i);
            }
        }
        if (list.Count > 0)
        {
            this.validatedBuyoutMessages = list;
            service.RegisterSynchronousJob(new SynchronousJob(this.SyncrhronousJob_BuyoutNode));
        }
    }
 public TransitionConditional_OnDelay(StaticString name, float delay) : base(name)
 {
     m_Delay = delegate()
     {
         return(delay);
     };
 }
Exemplo n.º 19
0
    public static string FormatInstantCost(Empire empire, float cost, StaticString resourceName, bool monochromatic = false, int decimals = 1)
    {
        DepartmentOfTheTreasury agency = empire.GetAgency <DepartmentOfTheTreasury>();
        float num;

        if (!agency.TryGetResourceStockValue(empire.SimulationObject, resourceName, out num, false))
        {
            Diagnostics.Log("Can't get resource stock value {0} on simulation object {1}.", new object[]
            {
                resourceName,
                empire.SimulationObject.Name
            });
        }
        StringBuilder stringBuilder = new StringBuilder();
        bool          flag          = false;

        if (!monochromatic && num < cost)
        {
            AgeUtils.ColorToHexaKey(Color.red, ref stringBuilder, false);
            flag = true;
        }
        stringBuilder.Append(GuiFormater.FormatGui(cost, false, decimals == 0, false, decimals));
        if (!monochromatic && flag)
        {
            stringBuilder.Append("#REVERT#");
        }
        stringBuilder.Append(" ");
        stringBuilder.Append(Services.GetService <IGuiService>().FormatSymbol(resourceName));
        return(stringBuilder.ToString());
    }
Exemplo n.º 20
0
 protected override void RefreshObjectives(StaticString context, StaticString pass)
 {
     base.RefreshObjectives(context, pass);
     for (int i = 0; i < this.MajorEmpire.TamedKaijus.Count; i++)
     {
         Kaiju kaiju = this.MajorEmpire.TamedKaijus[i];
         if (kaiju.OnArmyMode())
         {
             AICommander aicommander = this.aiCommanders.Find((AICommander match) => match.ForceArmyGUID == kaiju.KaijuArmy.GUID);
             if (aicommander == null)
             {
                 this.AddCommander(new AICommander_KaijuSupport
                 {
                     ForceArmyGUID = kaiju.KaijuArmy.GUID,
                     Empire        = base.AIEntity.Empire,
                     AIPlayer      = base.AIEntity.AIPlayer
                 });
             }
             else
             {
                 aicommander.Initialize();
                 aicommander.Load();
                 aicommander.CreateMission();
             }
         }
     }
 }
Exemplo n.º 21
0
    private bool IsSpellAlreadyCasted(SpellDefinitionTooltipData spellDefinitionTooltipData, ref bool isThisSpellActive)
    {
        Contender firstAlliedContenderFromEmpireWithUnits = spellDefinitionTooltipData.Encounter.GetFirstAlliedContenderFromEmpireWithUnits(spellDefinitionTooltipData.Empire);

        foreach (SpellDefinition spellDefinition in this.spellDefinitionDatabase)
        {
            if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(spellDefinitionTooltipData.Empire, spellDefinition, new string[]
            {
                ConstructionFlags.Prerequisite
            }))
            {
                for (int i = 0; i < spellDefinition.SpellBattleActions.Length; i++)
                {
                    StaticString       name = spellDefinition.SpellBattleActions[i].BattleActionUserDefinitionReference.Name;
                    BattleAction.State state;
                    if (firstAlliedContenderFromEmpireWithUnits.TryGetBattleActionUserState(name, out state) && state != BattleAction.State.Available)
                    {
                        isThisSpellActive = (spellDefinition.Name == spellDefinitionTooltipData.SpellDefinition.Name);
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Exemplo n.º 22
0
        public void DeclareConditional(Transition <TOwner> transition, StaticString behaviorType, StaticString name, List <StaticString> args)
        {
            StaticString behaviorDeclType;

            try
            {
                behaviorDeclType = m_Type2DeclTypeMap[behaviorType];
            }
            catch (KeyNotFoundException ex)
            {
                Log.Exception(ex);
                return;
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
                return;
            }

            try
            {
                m_ConditionalAllocators[behaviorDeclType].Invoke(transition, behaviorDeclType, name, args);
            }
            catch (KeyNotFoundException ex)
            {
                Log.Exception(ex);
                return;
            }
        }
Exemplo n.º 23
0
 public QuestBTOrder(StaticString questname, GameEntityGUID targetGUID, float armypower = 1f)
 {
     this.questName         = questname;
     this.objectiveGUID     = targetGUID;
     this.requiredArmyPower = armypower;
     this.resourceNeeded    = StaticString.Empty;
 }
Exemplo n.º 24
0
 public void NativeStatic()
 {
     for (int i = 0; i < Iterations; i++)
     {
         StaticString.GetHashCode();
     }
 }
Exemplo n.º 25
0
 public void DeterministicStatic()
 {
     for (int i = 0; i < Iterations; i++)
     {
         StaticString.GetDeterministicHashCode();
     }
 }
Exemplo n.º 26
0
 public void Remove(StaticString ship)
 {
     if (!seeds.ContainsKey(ship))
     {
         return;
     }
     seeds.Remove(ship);
 }
Exemplo n.º 27
0
 public string GetLobbyMemberData(Steamworks.SteamID steamIDMember, StaticString key)
 {
     if (this.SteamMatchMakingService != null && this.SteamIDLobby != null)
     {
         return(this.SteamMatchMakingService.SteamMatchMaking.GetLobbyMemberData(this.SteamIDLobby, steamIDMember, key));
     }
     return(null);
 }
Exemplo n.º 28
0
 protected override void EvaluateNeeds(StaticString context, StaticString pass)
 {
     base.EvaluateNeeds(context, pass);
     foreach (EvaluableMessage_Assimilation evaluableMessage_Assimilation in base.AIEntity.AIPlayer.Blackboard.GetMessages <EvaluableMessage_Assimilation>(BlackboardLayerID.Empire, (EvaluableMessage_Assimilation match) => match.EvaluationState == EvaluableMessage.EvaluableMessageState.Pending || match.EvaluationState == EvaluableMessage.EvaluableMessageState.Validate))
     {
         evaluableMessage_Assimilation.UpdateBuyEvaluation("Assimilation", 0UL, DepartmentOfTheInterior.GetAssimilationCost(this.Empire, 0), 2, 0f, 0UL);
     }
 }
Exemplo n.º 29
0
 public static string FormatStockAndNet(float stockValue, float netValue, StaticString resourceName, bool useKilo = false)
 {
     if (useKilo)
     {
         return(string.Format("{0} {1}({2})", Services.GetService <IGuiService>().FormatSymbol(resourceName), (stockValue < 1000f) ? GuiFormater.FormatGui(Mathf.Floor(stockValue), false, false, false, 0) : ((stockValue < 10000f) ? (GuiFormater.FormatGui(Mathf.Floor(stockValue / 1000f), false, false, false, 0) + "." + GuiFormater.FormatGui(Mathf.Floor(stockValue % 1000f / 100f), false, false, false, 0) + "k") : (GuiFormater.FormatGui(Mathf.Floor(stockValue / 1000f), false, false, false, 0) + "k")), (netValue < 1000f) ? GuiFormater.FormatGui(netValue, false, false, true, 0) : ((netValue < 10000f) ? (GuiFormater.FormatGui(netValue / 1000f, false, false, true, 0) + "." + GuiFormater.FormatGui(netValue % 1000f / 100f, false, false, false, 0) + "k") : (GuiFormater.FormatGui(netValue / 1000f, false, false, true, 0) + "k"))));
     }
     return(string.Format("{0} {1}({2})", Services.GetService <IGuiService>().FormatSymbol(resourceName), GuiFormater.FormatGui(Mathf.Floor(stockValue), false, false, false, 0), GuiFormater.FormatGui(netValue, false, false, true, 0)));
 }
Exemplo n.º 30
0
 public void Remove(StaticString ship, int level)
 {
     if (!seeds.ContainsKey(ship) || seeds[ship].ContainsKey(level))
     {
         return;
     }
     seeds[ship].Remove(level);
 }
 public void AddStaticString(StaticString ss)
 {
     stringsToDraw.Add(ss);
 }