Ejemplo n.º 1
0
    public TerraformDevice AddDevice(GameEntityGUID guid, TerraformDeviceDefinition terraformDeviceDefinition, WorldPosition position, global::Empire empire, bool placedByPrivateers)
    {
        TerraformDevice terraformDevice           = new TerraformDevice(empire.Index, guid, position, terraformDeviceDefinition, placedByPrivateers);
        IDatabase <SimulationDescriptor> database = Databases.GetDatabase <SimulationDescriptor>(false);

        Diagnostics.Assert(database != null);
        SimulationDescriptor descriptor = null;

        if (database.TryGetValue(TerraformDeviceManager.ClassTerraformDeviceDescriptor, out descriptor))
        {
            terraformDevice.AddDescriptor(descriptor, false);
        }
        float propertyValue = terraformDevice.Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier);

        terraformDevice.Charges           = 0f;
        terraformDevice.ChargesPerTurn    = terraformDeviceDefinition.ChargesPerTurn;
        terraformDevice.ChargesToActivate = terraformDeviceDefinition.ChargesToActivate * propertyValue;
        terraformDevice.Range             = terraformDeviceDefinition.TerraformRange;
        terraformDevice.DismantleDefense  = (float)terraformDeviceDefinition.DismantleDefense * propertyValue;
        empire.AddChild(terraformDevice);
        empire.Refresh(false);
        this.Register(terraformDevice);
        this.worldPositionSimulationEvaluatorService.SetSomethingChangedOnRegion(this.WorldPositionningService.GetRegionIndex(terraformDevice.WorldPosition));
        return(terraformDevice);
    }
Ejemplo n.º 2
0
    public void ChangeToTamedState(MajorEmpire majorEmpire)
    {
        if (this.IsWild())
        {
            SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuStatusWild);
            base.RemoveDescriptor(value);
        }
        else if (this.IsStunned())
        {
            SimulationDescriptor value2 = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuStatusStunned);
            base.RemoveDescriptor(value2);
        }
        SimulationDescriptor value3 = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuStatusTamed);

        base.AddDescriptor(value3, false);
        this.Refresh(false);
        this.ComputeNextTurnToSpawnUnits(false);
        this.KaijuGarrison.CallRefreshAppliedRegionEffects();
        this.KaijuArmy.OnTamed();
        EventKaijuTamed eventToNotify = new EventKaijuTamed(this.majorEmpire, this);

        this.EventService.Notify(eventToNotify);
        foreach (global::Empire empire in (this.gameService.Game as global::Game).Empires)
        {
            if (empire is MajorEmpire && empire != this.majorEmpire)
            {
                this.eventService.Notify(new GlobalEventKaijuTamed(empire, this));
            }
        }
    }
Ejemplo n.º 3
0
	public void RemoveTamedKaiju(Kaiju kaiju)
	{
		if (this.TamedKaijus.Contains(kaiju))
		{
			IDatabase<SimulationDescriptor> database = Databases.GetDatabase<SimulationDescriptor>(false);
			SimulationDescriptor descriptor = null;
			if (database.TryGetValue(kaiju.KaijuEmpire.KaijuFaction.EmpireTamedKaijuDescriptor, out descriptor))
			{
				base.SimulationObject.RemoveDescriptor(descriptor);
			}
			this.TamedKaijus.Remove(kaiju);
			base.RemoveChild(kaiju);
			if (kaiju.KaijuGarrison != null)
			{
				base.RemoveChild(kaiju.KaijuGarrison);
			}
			if (kaiju.KaijuArmy != null)
			{
				base.RemoveChild(kaiju.KaijuArmy);
				base.GetAgency<DepartmentOfDefense>().RemoveArmy(kaiju.KaijuArmy, false);
			}
			kaiju.Refresh(false);
			this.Refresh(false);
			if (this.TamedKaijusCollectionChanged != null)
			{
				this.TamedKaijusCollectionChanged(this, new CollectionChangeEventArgs(CollectionChangeAction.Remove, kaiju));
			}
		}
	}
Ejemplo n.º 4
0
    protected bool CanAffordFoodCost(AILayer_CreepingNode.EvaluableCreepingNode node)
    {
        List <CreepingNodeConstructionMessage> list = new List <CreepingNodeConstructionMessage>(base.AIEntity.AIPlayer.Blackboard.GetMessages <CreepingNodeConstructionMessage>(BlackboardLayerID.Empire, (CreepingNodeConstructionMessage match) => match.State != BlackboardMessage.StateValue.Message_Canceled));
        SimulationObject     simulationObject       = new SimulationObject("PendingNodesUpkeep");
        SimulationDescriptor descriptor             = null;
        SimulationDescriptor descriptor2            = null;

        if (this.simulationDescriptorDatabase.TryGetValue("ClassCreepingNode", out descriptor2))
        {
            simulationObject.AddDescriptor(descriptor2);
            for (int i = 0; i < list.Count; i++)
            {
                CreepingNodeImprovementDefinition value = this.creepingNodeDefinitionDatabase.GetValue(list[i].NodeDefinitionName);
                if (value != null && this.simulationDescriptorDatabase.TryGetValue(node.nodeDefinition.ConstructionCostDescriptor, out descriptor))
                {
                    simulationObject.AddDescriptor(descriptor);
                }
            }
            if (this.simulationDescriptorDatabase.TryGetValue(node.nodeDefinition.ConstructionCostDescriptor, out descriptor))
            {
                simulationObject.AddDescriptor(descriptor);
            }
            this.aiEntityCity.City.SimulationObject.AddChild(simulationObject);
            this.aiEntityCity.City.SimulationObject.Refresh();
            float propertyValue = this.aiEntityCity.City.GetPropertyValue("NetCityGrowth");
            this.aiEntityCity.City.SimulationObject.RemoveChild(simulationObject);
            this.aiEntityCity.City.SimulationObject.Refresh();
            return(propertyValue > 0f);
        }
        Diagnostics.LogError("Could not find the class creeping node descriptor");
        return(false);
    }
Ejemplo n.º 5
0
    public void LoadRegionVillages(Region region)
    {
        if (region == null)
        {
            return;
        }
        GameEntityGUID       guid       = this.GameEntityRepositoryService.GenerateGUID();
        SimulationDescriptor descriptor = null;

        this.SimulationDescriptorDatabase.TryGetValue("ClassMinorEmpireGarrison", out descriptor);
        DepartmentOfIndustry agency = base.Empire.GetAgency <DepartmentOfIndustry>();
        SimulationDescriptor value  = this.SimulationDescriptorDatabase.GetValue("MinorEmpireVillage");

        for (int i = 0; i < region.PointOfInterests.Length; i++)
        {
            string a;
            if (region.PointOfInterests[i].PointOfInterestDefinition.TryGetValue("Type", out a) && a == "Village")
            {
                guid = this.GameEntityRepositoryService.GenerateGUID();
                Village village = new Village(guid)
                {
                    Empire = (base.Empire as global::Empire)
                };
                village.PointOfInterest = region.PointOfInterests[i];
                village.AddDescriptor(descriptor, false);
                village.AddDescriptor(value, false);
                this.AddVillage(village);
                if (agency != null)
                {
                    agency.AddQueueTo <Village>(village);
                }
            }
        }
        this.MinorEmpire.GenerateStartingUnits();
    }
Ejemplo n.º 6
0
    public void AddConvertVillageOnLoad(Village village, MajorEmpire converter)
    {
        if (converter == null)
        {
            throw new ArgumentNullException("converter");
        }
        SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue(BarbarianCouncil.VillageStatusConverted);

        village.SwapDescriptor(value);
        if (!village.HasBeenConverted)
        {
            if (village.HasBeenPacified)
            {
                village.HasBeenPacified = false;
            }
            SimulationDescriptor value2 = this.SimulationDescriptorDatabase.GetValue(Village.ConvertedVillage);
            if (value2 != null)
            {
                Diagnostics.Assert(village.PointOfInterest != null);
                village.PointOfInterest.SwapDescriptor(value2);
                village.SwapDescriptor(value2);
            }
            village.Converter = converter;
            if (village.Converter.ConvertedVillages != null && village.Converter.ConvertedVillages.Contains(village))
            {
                village.Converter.AddChild(village);
            }
            DepartmentOfTheInterior.GenerateFIMSEForConvertedVillage(village.Converter, village.PointOfInterest);
        }
    }
Ejemplo n.º 7
0
    private void InitializeAIParameter(IServiceContainer serviceContainer, global::Game game)
    {
        this.WorldPositionningService     = game.Services.GetService <IWorldPositionningService>();
        this.SimulationDescriptorDatabase = Databases.GetDatabase <SimulationDescriptor>(false);
        int num = 0;

        for (int i = 0; i < game.Empires.Length; i++)
        {
            if (game.Empires[i] is MinorEmpire)
            {
                break;
            }
            num++;
        }
        this.scoreByWorldPositionByEmpires = new GridMap <WorldPositionScore> [num];
        this.cityProxyByEmpires            = new SimulationObject[num];
        this.districtProxyByEmpires        = new SimulationObject[num];
        SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue("ClassCity");

        for (int j = 0; j < num; j++)
        {
            this.scoreByWorldPositionByEmpires[j]      = new GridMap <WorldPositionScore>("PositionScore", (int)this.WorldPositionningService.World.WorldParameters.Columns, (int)this.WorldPositionningService.World.WorldParameters.Rows, null);
            this.cityProxyByEmpires[j]                 = new SimulationObject("WorldPositionEvaluation.CityProxy#" + j);
            this.cityProxyByEmpires[j].ModifierForward = ModifierForwardType.ChildrenOnly;
            this.cityProxyByEmpires[j].AddDescriptor(value);
            this.districtProxyByEmpires[j] = new SimulationObject("WorldPositionEvaluation.DistrictProxy#" + j);
            this.districtProxyByEmpires[j].ModifierForward = ModifierForwardType.ChildrenOnly;
            this.cityProxyByEmpires[j].AddChild_ModifierForwardType_ChildrenOnly(this.districtProxyByEmpires[j]);
            game.Empires[j].SimulationObject.AddChild_ModifierForwardType_ChildrenOnly(this.cityProxyByEmpires[j]);
        }
    }
Ejemplo n.º 8
0
 public CreepingNode(GameEntityGUID guid, global::Empire empire) : base("CreepingNode#" + guid.ToString())
 {
     this.GUID                       = guid;
     this.Empire                     = empire;
     this.LineOfSightActive          = true;
     this.LineOfSightDirty           = true;
     this.DismantlingArmyGUID        = GameEntityGUID.Zero;
     this.Life                       = 0f;
     this.LastTurnWhenDismantleBegun = 0;
     this.eventService               = Services.GetService <IEventService>();
     Diagnostics.Assert(this.eventService != null);
     this.gameService = Services.GetService <IGameService>();
     Diagnostics.Assert(this.gameService != null);
     this.game = (this.gameService.Game as global::Game);
     Diagnostics.Assert(this.game != null);
     this.pathfindingService = this.gameService.Game.Services.GetService <IPathfindingService>();
     Diagnostics.Assert(this.pathfindingService != null);
     this.worldPositionningService = this.gameService.Game.Services.GetService <IWorldPositionningService>();
     Diagnostics.Assert(this.worldPositionningService != null);
     this.simulationDescriptorDatabase = Databases.GetDatabase <SimulationDescriptor>(false);
     Diagnostics.Assert(this.simulationDescriptorDatabase != null);
     this.departmentOfTheInterior = this.Empire.GetAgency <DepartmentOfTheInterior>();
     if (ELCPUtilities.UseELCPCreepingNodeRuleset)
     {
         SimulationDescriptor descriptor = null;
         if (this.simulationDescriptorDatabase.TryGetValue("VanillaNode", out descriptor))
         {
             base.SimulationObject.AddDescriptor(descriptor);
         }
     }
     this.StoredConstructionCost = new Dictionary <string, float>();
     this.ExploitedTiles         = new List <WorldPosition>();
 }
Ejemplo n.º 9
0
    protected void ApplyGameModifier(StaticString gameModifierReference, PlayerType playerType)
    {
        IDatabase <GameModifierDefinition> database = Databases.GetDatabase <GameModifierDefinition>(false);

        Diagnostics.Assert(database != null);
        GameModifierDefinition gameModifierDefinition;

        if (!database.TryGetValue(gameModifierReference, out gameModifierDefinition))
        {
            Diagnostics.LogError("Can't found game modifier {0} in database.", new object[]
            {
                gameModifierReference
            });
            return;
        }
        Diagnostics.Assert(gameModifierDefinition != null);
        if (gameModifierDefinition.DescriptorTypesToRemove != null)
        {
            for (int i = 0; i < gameModifierDefinition.DescriptorTypesToRemove.Length; i++)
            {
                string x = gameModifierDefinition.DescriptorTypesToRemove[i];
                base.RemoveDescriptorByType(x);
            }
        }
        if (gameModifierDefinition.EffectsList != null)
        {
            for (int j = 0; j < gameModifierDefinition.EffectsList.Length; j++)
            {
                GameModifierDefinition.Effects effects = gameModifierDefinition.EffectsList[j];
                Diagnostics.Assert(effects != null);
                if (effects.PlayerTypeFilter == PlayerType.Unset || effects.PlayerTypeFilter == playerType)
                {
                    bool flag = true;
                    if (effects.Prerequisites != null)
                    {
                        for (int k = 0; k < effects.Prerequisites.Length; k++)
                        {
                            flag &= effects.Prerequisites[k].Check(base.SimulationObject);
                        }
                    }
                    if (flag)
                    {
                        if (effects.SimulationDescriptors != null)
                        {
                            for (int l = 0; l < effects.SimulationDescriptors.Length; l++)
                            {
                                SimulationDescriptor descriptor = effects.SimulationDescriptors[l];
                                base.AddDescriptor(descriptor, false);
                            }
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 10
0
        public SimulationDescriptor GetDescriptor(string name)
        {
            SimulationDescriptor descriptor = new SimulationDescriptor();

            descriptor.SetName(name);

            descriptor.SetProperties(Properties.ToArray());
            descriptor.SetModifiers(Modifiers.ToArray());

            return(descriptor);
        }
Ejemplo n.º 11
0
 private void RemoveConstructionCostDescriptor()
 {
     if (!string.IsNullOrEmpty(this.NodeDefinition.ConstructionCostDescriptor))
     {
         SimulationDescriptor descriptor = null;
         if (this.simulationDescriptorDatabase.TryGetValue(this.NodeDefinition.ConstructionCostDescriptor, out descriptor))
         {
             base.RemoveDescriptor(descriptor);
         }
     }
 }
Ejemplo n.º 12
0
        private void Session_Update(On.Session.orig_Update orig, Session self)
        {
            // Continue attempting to add the ItemHero until it has been added!
            try
            {
                SimulationDescriptor desc;
                Databases.GetDatabase <SimulationDescriptor>(false).TryGetValue(GetBaseDescriptor().Name, out desc);
                if (desc != null)
                {
                    orig(self);
                    return;
                }
                ItemHeroConfig itemHeroConfig = GetItemHeroConfig();
                Databases.GetDatabase <ItemConfig>(false).Add(itemHeroConfig);
                Log("Added the item (ItemHeroConfig) to the database!");
                Log("Attempting to make sim descriptors");
                SimulationDescriptor descriptor = GetBaseDescriptor();
                Log("Successfully retrieved the overall descriptor!");
                SimulationDescriptor common = GetCommonDescriptor();
                Log("Successfully retrieved the common descriptor!");
                SimulationDescriptor rarity0 = GetRarity0Descriptor();
                Log("Successfully retrieved the rarity0 descriptor!");
                SimulationDescriptor rarity1 = GetRarity1Descriptor();
                Log("Successfully retrieved the rarity1 descriptor!");
                SimulationDescriptor rarity2 = GetRarity2Descriptor();
                Log("Successfully retrieved the rarity2 descriptor!");

                Log("Attempting to add descriptors to database!");

                Databases.GetDatabase <SimulationDescriptor>(false).Add(descriptor);
                Log("Added Base!");
                Databases.GetDatabase <SimulationDescriptor>(false).Add(common);
                Log("Added Common!");
                Databases.GetDatabase <SimulationDescriptor>(false).Add(rarity0);
                Log("Added Rarity0!");
                Databases.GetDatabase <SimulationDescriptor>(false).Add(rarity1);
                Log("Added Rarity1!");
                Databases.GetDatabase <SimulationDescriptor>(false).Add(rarity2);
                Log("Added Rarity2!");
                Log("Added all SimDescriptors to the database!");
            }
            catch (ArgumentException e)
            {
                // It already exists!
            } catch (NullReferenceException e)
            {
                // Database doesn't exist yet!
            }
            orig(self);
        }
Ejemplo n.º 13
0
    private void ReleaseKaijuArmyActions()
    {
        DepartmentOfDefense  agency = this.Empire.GetAgency <DepartmentOfDefense>();
        SimulationDescriptor value  = this.SimulationDescriptorDatabase.GetValue(DepartmentOfTheInterior.ArmyStatusBesiegerDescriptorName);

        this.KaijuArmy.RemoveDescriptor(value);
        if (this.KaijuArmy.IsEarthquaker)
        {
            this.KaijuArmy.SetEarthquakerStatus(false, false, null);
        }
        if (this.KaijuArmy.PillageTarget.IsValid)
        {
            DepartmentOfDefense.StopPillage(this.KaijuArmy);
        }
        if (this.KaijuArmy.IsAspirating)
        {
            agency.StopAspirating(this.KaijuArmy);
        }
        if (this.KaijuArmy.IsDismantlingDevice)
        {
            ITerraformDeviceRepositoryService service = this.gameService.Game.Services.GetService <ITerraformDeviceRepositoryService>();
            TerraformDevice device = service[this.KaijuArmy.DismantlingDeviceTarget] as TerraformDevice;
            agency.StopDismantelingDevice(this.KaijuArmy, device);
        }
        if (this.KaijuArmy.IsDismantlingCreepingNode)
        {
            CreepingNode creepingNode = null;
            if (this.gameEntityRepositoryService.TryGetValue <CreepingNode>(this.KaijuArmy.DismantlingCreepingNodeTarget, out creepingNode))
            {
                agency.StopDismantelingCreepingNode(this.KaijuArmy, creepingNode);
            }
        }
        IWorldPositionningService service2 = this.gameService.Game.Services.GetService <IWorldPositionningService>();
        Region region = service2.GetRegion(this.KaijuArmy.WorldPosition);

        if (region.City != null && region.City.Empire != this.Empire)
        {
            DepartmentOfTheInterior agency2 = region.City.Empire.GetAgency <DepartmentOfTheInterior>();
            if (agency2 != null)
            {
                if (region.City.BesiegingEmpire == this.Empire && agency2.NeedToStopSiege(region.City))
                {
                    agency2.StopSiege(region.City);
                }
                agency2.StopNavalSiege(region.City, this.KaijuArmy);
            }
            IVisibilityService service3 = this.gameService.Game.Services.GetService <IVisibilityService>();
            service3.NotifyVisibilityHasChanged(this.Empire);
        }
    }
Ejemplo n.º 14
0
    public void SpawnKaiju(WorldPosition targetPosition, GameEntityGUID kaijuGUID, GameEntityGUID garrisonGUID, GameEntityGUID armyGUID, GameEntityGUID monsterGUID, GameEntityGUID[] licesGUIDs)
    {
        Kaiju kaiju = new Kaiju(base.Empire as KaijuEmpire, kaijuGUID);

        string[] kaijuDescriptors = this.KaijuEmpire.KaijuFaction.KaijuDescriptors;
        for (int i = 0; i < kaijuDescriptors.Length; i++)
        {
            SimulationDescriptor descriptor = null;
            if (this.descriptorsDatabase.TryGetValue(kaijuDescriptors[i], out descriptor))
            {
                kaiju.AddDescriptor(descriptor, false);
            }
        }
        KaijuGarrison        kaijuGarrison = new KaijuGarrison(garrisonGUID, targetPosition);
        SimulationDescriptor value         = this.descriptorsDatabase.GetValue(Kaiju.ClassKaijuGarrison);

        kaijuGarrison.AddDescriptor(value, false);
        kaijuGarrison.SetPropertyBaseValue(SimulationProperties.MaximumUnitSlotCount, (float)(licesGUIDs.Length + 1));
        kaiju.SetGarrison(kaijuGarrison);
        KaijuArmy            kaijuArmy = this.departmentOfDefense.CreateKaijuArmy(armyGUID, targetPosition, true);
        SimulationDescriptor value2    = this.descriptorsDatabase.GetValue(Kaiju.ClassKaijuArmy);

        kaijuArmy.AddDescriptor(value2, false);
        kaijuArmy.SetPropertyBaseValue(SimulationProperties.MaximumUnitSlotCount, (float)(licesGUIDs.Length + 1));
        kaiju.SetArmy(kaijuArmy);
        this.gameEntityRepositoryService.Register(kaijuArmy);
        this.gameEntityRepositoryService.Register(kaiju);
        kaiju.ChangeToWildState();
        kaiju.ChangeToGarrisonMode(false);
        Unit unit = DepartmentOfDefense.CreateUnitByDesign(monsterGUID, this.KaijuEmpire.FindMonsterDesign(true));

        kaiju.AddUnit(unit);
        for (int j = 0; j < licesGUIDs.Length; j++)
        {
            Unit unit2 = DepartmentOfDefense.CreateUnitByDesign(licesGUIDs[j], this.KaijuEmpire.FindLiceDesign(true));
            kaiju.AddUnit(unit2);
        }
        this.lastLiceArmySpawnTurn = (this.gameService.Game as global::Game).Turn;
        this.Kaiju = kaiju;
        this.KaijuEmpire.AddKaiju(kaiju);
        kaiju.Refresh(false);
        foreach (global::Empire empire in (this.gameService.Game as global::Game).Empires)
        {
            if (empire is MajorEmpire)
            {
                this.eventService.Notify(new EventKaijuSpawned(empire, this.Kaiju));
            }
        }
    }
Ejemplo n.º 15
0
 private void RemoveImprovementDescriptors(CreepingNodeImprovementDefinition definition)
 {
     SimulationDescriptor[] descriptors = definition.Descriptors;
     for (int i = 0; i < descriptors.Length; i++)
     {
         base.RemoveDescriptor(descriptors[i]);
     }
     if (!string.IsNullOrEmpty(definition.VillageInfectionDescriptor))
     {
         SimulationDescriptor descriptor = null;
         if (this.simulationDescriptorDatabase.TryGetValue(definition.VillageInfectionDescriptor, out descriptor))
         {
             base.RemoveDescriptor(descriptor);
         }
     }
 }
Ejemplo n.º 16
0
    public void ChangeToGarrisonMode(bool calledByChangeModeOrderProcessor = false)
    {
        if (calledByChangeModeOrderProcessor && this.OnPrepareToConvertToGarrisonDelegate != null)
        {
            this.OnPrepareToConvertToGarrisonDelegate();
        }
        Region region = this.GameService.Game.Services.GetService <IWorldPositionningService>().GetRegion(this.KaijuArmy.WorldPosition);
        SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuArmyModeDescriptor);

        if (value != null)
        {
            base.RemoveDescriptor(value);
        }
        SimulationDescriptor value2 = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuGarrisonModeDescriptor);

        if (value2 != null)
        {
            base.AddDescriptor(value2, false);
        }
        this.Refresh(false);
        this.KaijuArmy.Refresh(false);
        this.KaijuGarrison.Refresh(false);
        this.KaijuGarrison.Empire = this.Empire;
        this.KaijuGarrison.ClearAllUnits();
        this.TransferUnitsToGarrison();
        this.GameEntityRepositoryService.Unregister(this.KaijuArmy);
        this.Empire.RemoveChild(this.KaijuArmy);
        this.KaijuGarrison.MoveTo(this.KaijuArmy.WorldPosition);
        this.GameEntityRepositoryService.Register(this.KaijuGarrison);
        this.Empire.AddChild(this.KaijuGarrison);
        this.Empire.Refresh(false);
        this.OwnRegion(region);
        this.KaijuArmy.Refresh(false);
        this.KaijuGarrison.Refresh(false);
        this.HideKaijuArmyFromMap();
        this.KaijuGarrison.OnConvertedToGarrison();
        this.KaijuArmy.OnConvertedToGarrison();
        if (this.OnConvertedToGarrisonDelegate != null)
        {
            this.OnConvertedToGarrisonDelegate();
        }
        this.ComputeNextTurnToSpawnUnits(false);
        this.CallRefreshProvidedRegionEffects();
        this.ReleaseKaijuArmyActions();
        this.KaijuGarrison.ForceWorldOrientation(this.WorldOrientation);
    }
    protected override IEnumerator OnLoadGame()
    {
        yield return(base.OnLoadGame());

        this.worldPositionningService     = base.Game.Services.GetService <IWorldPositionningService>();
        this.SimulationDescriptorDatabase = Databases.GetDatabase <SimulationDescriptor>(false);
        SimulationDescriptor classCityDescriptor = this.SimulationDescriptorDatabase.GetValue("ClassCity");

        this.cityProxy = new SimulationObject("PanelFeatureEffects_Terraformation.CityProxy" + PanelFeatureEffects_Terraformation.uniqueId++);
        this.cityProxy.ModifierForward = ModifierForwardType.ChildrenOnly;
        this.cityProxy.AddDescriptor(classCityDescriptor);
        this.districtProxy = new SimulationObject("PanelFeatureEffects_Terraformation.DistrictProxy");
        this.districtProxy.ModifierForward = ModifierForwardType.ChildrenOnly;
        this.stringBuilder  = new StringBuilder();
        this.propertyValues = new float[this.properties.Count];
        yield break;
    }
Ejemplo n.º 18
0
    public void AddFidsModifierDescriptors(SimulationObject district, WorldPosition worldPosition, bool districtIsProxy)
    {
        List <SimulationDescriptor> fidsModifierDescriptorsHavingAnEffectOnPosition = this.GetFidsModifierDescriptorsHavingAnEffectOnPosition(worldPosition);

        for (int i = 0; i < fidsModifierDescriptorsHavingAnEffectOnPosition.Count; i++)
        {
            SimulationDescriptor simulationDescriptor = fidsModifierDescriptorsHavingAnEffectOnPosition[i];
            district.AddDescriptor(simulationDescriptor);
            if (!districtIsProxy)
            {
                if (!this.descriptorsAppliedOnDistrict.ContainsKey(worldPosition))
                {
                    this.descriptorsAppliedOnDistrict.Add(worldPosition, new List <string>());
                }
                this.descriptorsAppliedOnDistrict[worldPosition].Add(simulationDescriptor.Name);
            }
        }
        district.Refresh();
    }
Ejemplo n.º 19
0
 private void UpdateEmpireDiplomaticAbilityDescriptor(DiplomaticAbilityDefinition diplomaticAbilityDefinition, global::Empire empire, bool isAddOperation)
 {
     if (diplomaticAbilityDefinition == null || diplomaticAbilityDefinition.Descriptors == null)
     {
         return;
     }
     for (int i = 0; i < diplomaticAbilityDefinition.Descriptors.Length; i++)
     {
         SimulationDescriptor descriptor = diplomaticAbilityDefinition.Descriptors[i];
         if (isAddOperation)
         {
             empire.AddDescriptor(descriptor, false);
         }
         else
         {
             empire.RemoveDescriptor(descriptor);
         }
     }
     empire.Refresh(false);
 }
Ejemplo n.º 20
0
    public void ConvertVillage(Village village, MajorEmpire converter)
    {
        if (converter == null)
        {
            throw new ArgumentNullException("converter");
        }
        SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue(BarbarianCouncil.VillageStatusConverted);

        village.SwapDescriptor(value);
        if (!village.HasBeenConverted)
        {
            if (village.HasBeenPacified)
            {
                village.HasBeenPacified = false;
            }
            SimulationDescriptor value2 = this.SimulationDescriptorDatabase.GetValue(Village.ConvertedVillage);
            if (value2 != null)
            {
                Diagnostics.Assert(village.PointOfInterest != null);
                village.PointOfInterest.SwapDescriptor(value2);
                village.SwapDescriptor(value2);
            }
            for (int i = village.StandardUnits.Count - 1; i >= 0; i--)
            {
                Unit unit = village.StandardUnits[i];
                this.GameEntityRepositoryService.Unregister(unit);
                village.RemoveUnit(unit);
                unit.Dispose();
            }
            village.Converter = converter;
            village.ConvertedUnitSpawnTurn = (this.GameService.Game as global::Game).Turn + village.GetConvertedUnitProductionTimer();
            EventVillageConverted eventToNotify = new EventVillageConverted(converter, village);
            this.EventService.Notify(eventToNotify);
            if (village.Converter.ConvertedVillages != null)
            {
                Diagnostics.Assert(!village.Converter.ConvertedVillages.Contains(village));
                village.Converter.AddConvertedVillage(village);
            }
            DepartmentOfTheInterior.GenerateFIMSEForConvertedVillage(village.Converter, village.PointOfInterest);
        }
    }
Ejemplo n.º 21
0
 private void Session_Update(On.Session.orig_Update orig, Session self)
 {
     if (!displayedData)
     {
         Log("Number of Active Heroes: " + Hero.LocalPlayerActiveRecruitedHeroes.Count);
         foreach (Hero h in Hero.LocalPlayerActiveRecruitedHeroes)
         {
             try
             {
                 Log("Entering a check with Name: " + h.LocalizedName);
                 SimulationDescriptor dbdescriptorByName = SimMonoBehaviour.GetDBDescriptorByName(h.Config.Name);
                 Log("DBDescriptorByName: " + dbdescriptorByName.Name);
                 var obj = h.GetSimDescriptorByType(SimulationProperties.SimDescTypeHero);
                 Log("Name: " + obj.Name + " Type: " + obj.Type);
                 Log("Modifiers:");
                 if (obj.SimulationModifierDescriptors != null)
                 {
                     foreach (SimulationModifierDescriptor m in obj.SimulationModifierDescriptors)
                     {
                         Log("- " + m.TargetPropertyName);
                     }
                 }
                 Log("Properties:");
                 if (obj.SimulationPropertyDescriptors != null)
                 {
                     foreach (SimulationPropertyDescriptor d in obj.SimulationPropertyDescriptors)
                     {
                         Log("- " + d.Name + ": " + d.BaseValue);
                     }
                 }
                 Log("Level 1 Name: " + h.GetLevelDescriptorName(1));
                 displayedData = true;
             }
             catch (NullReferenceException e)
             {
                 // Thats ok for now
             }
         }
     }
     orig(self);
 }
Ejemplo n.º 22
0
    public override IEnumerator LoadGame(global::Game game)
    {
        yield return(base.LoadGame(game));

        if (this.CommandService != null && Amplitude.Unity.Framework.Application.Version.Accessibility <= Accessibility.Internal)
        {
            this.CommandService.RegisterCommand(new Command("/Tutorial", "Changes the activation state of the tutorial manager."), new Func <string[], string>(this.Command_Tutorial));
        }
        if (this.IsActive)
        {
            this.SetNotifications(true);
            IGameService gameService = Services.GetService <IGameService>();
            Diagnostics.Assert(gameService != null);
            Diagnostics.Assert(gameService.Game != null);
            Diagnostics.Assert(gameService.Game is global::Game);
            SimulationDescriptor tutorialEmpireDescriptor = Databases.GetDatabase <SimulationDescriptor>(false).GetValue("EmpireTutorial");
            Diagnostics.Assert(tutorialEmpireDescriptor != null);
            foreach (global::Empire empire in game.Empires)
            {
                empire.AddDescriptor(tutorialEmpireDescriptor, false);
            }
            if (!string.IsNullOrEmpty(TutorialInstructionPanel.WaitingInstruction.Content))
            {
                this.eventService = Services.GetService <IEventService>();
                Diagnostics.Assert(this.eventService != null);
                this.eventService.EventRaise += this.EventService_EventRaise;
            }
            this.guiService = Services.GetService <Amplitude.Unity.Gui.IGuiService>();
            Diagnostics.Assert(this.guiService != null);
            TutorialInstructionPanel instructionPanel = this.guiService.GetGuiPanel <TutorialInstructionPanel>();
            Diagnostics.Assert(instructionPanel != null);
            instructionPanel.OnTutorialLoad();
            TutorialHighlightPanel highlightPanel = this.guiService.GetGuiPanel <TutorialHighlightPanel>();
            Diagnostics.Assert(highlightPanel != null);
            highlightPanel.OnTutorialLoad();
        }
        yield break;
    }
Ejemplo n.º 23
0
    public void PacifyVillage(Village village, IEnumerable <global::Empire> empiresWhichHelpedPacification = null)
    {
        SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue(BarbarianCouncil.VillageStatusPacified);

        village.SwapDescriptor(value);
        if (!village.HasBeenPacified)
        {
            village.HasBeenPacified = true;
            SimulationDescriptor value2 = this.SimulationDescriptorDatabase.GetValue(Village.PacifiedVillage);
            if (value2 != null)
            {
                Diagnostics.Assert(village.PointOfInterest != null);
                village.PointOfInterest.SwapDescriptor(value2);
                village.SwapDescriptor(value2);
            }
            for (int i = village.StandardUnits.Count - 1; i >= 0; i--)
            {
                Unit unit = village.StandardUnits[i];
                this.GameEntityRepositoryService.Unregister(unit);
                village.RemoveUnit(unit);
                unit.Dispose();
            }
            if (empiresWhichHelpedPacification != null)
            {
                foreach (global::Empire empire in empiresWhichHelpedPacification)
                {
                    this.EventService.Notify(new EventVillagePacified(empire, village));
                }
            }
            if (village.Converter != null && village.Converter.ConvertedVillages != null)
            {
                DepartmentOfTheInterior.ClearFIMSEOnConvertedVillage(village.Converter, village.PointOfInterest);
                village.Converter.RemoveConvertedVillage(village);
                village.Converter = null;
            }
        }
    }
Ejemplo n.º 24
0
    public void ChangeToStunState(global::Empire stunner)
    {
        if (this.IsWild())
        {
            SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuStatusWild);
            base.RemoveDescriptor(value);
        }
        else if (this.IsTamed())
        {
            SimulationDescriptor value2 = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuStatusTamed);
            base.RemoveDescriptor(value2);
        }
        SimulationDescriptor value3 = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuStatusStunned);

        base.AddDescriptor(value3, false);
        this.Refresh(false);
        this.ComputeNextTurnToRecoverFromStun();
        this.ComputeNextTurnToSpawnUnits(false);
        this.KaijuGarrison.CallRefreshAppliedRegionEffects();
        this.KaijuArmy.OnStunned();
        EventKaijuStunned eventToNotify = new EventKaijuStunned(stunner, this);

        this.EventService.Notify(eventToNotify);
    }
Ejemplo n.º 25
0
    private bool CanAfforFoodCost(global::Empire empire, CreepingNodeImprovementDefinition nodeDefinition)
    {
        DepartmentOfTheInterior agency           = empire.GetAgency <DepartmentOfTheInterior>();
        SimulationObject        simulationObject = new SimulationObject("DummyNode");
        SimulationDescriptor    descriptor       = null;
        SimulationDescriptor    descriptor2      = null;

        if (this.simulationDescriptorDatabase.TryGetValue("ClassCreepingNode", out descriptor2))
        {
            simulationObject.AddDescriptor(descriptor2);
            if (this.simulationDescriptorDatabase.TryGetValue(nodeDefinition.ConstructionCostDescriptor, out descriptor))
            {
                simulationObject.AddDescriptor(descriptor);
            }
            agency.MainCity.SimulationObject.AddChild(simulationObject);
            agency.MainCity.SimulationObject.Refresh();
            float propertyValue = agency.MainCity.GetPropertyValue("NetCityGrowth");
            agency.MainCity.SimulationObject.RemoveChild(simulationObject);
            agency.MainCity.SimulationObject.Refresh();
            return(propertyValue >= 0f);
        }
        Diagnostics.LogError("Could not find the class creeping node descriptor");
        return(false);
    }
Ejemplo n.º 26
0
 public void Show(ConstructibleTooltipData constructibleData)
 {
     this.ConstructibleTitle.Text = AgeLocalizer.Instance.LocalizeString(constructibleData.Title);
     this.effectDescriptions.Clear();
     this.simulationEffectParser.ParseSimulationDescriptor(constructibleData, this.effectDescriptions, null, false, false);
     this.EffectMapper.LoadEffects(this.effectDescriptions, true);
     if (this.EffectMapper.EffectsList.Height == 0f)
     {
         this.EffectTitle.Text = AgeLocalizer.Instance.LocalizeString("%FeatureNoEffectsTitle");
     }
     else
     {
         this.EffectTitle.Text = AgeLocalizer.Instance.LocalizeString("%FeatureEffectsTitle");
     }
     this.EffectGroup.Height  = this.EffectMapper.EffectsList.PixelOffsetTop + this.EffectMapper.EffectsList.PixelMarginTop + this.EffectMapper.EffectsList.Height + this.EffectMapper.EffectsList.PixelMarginBottom + this.EffectMapper.EffectsList.PixelOffsetBottom;
     this.CostGroup.Visible   = true;
     this.CostGroup.Y         = this.ConstructibleTitle.AgeTransform.Height + this.EffectGroup.Height;
     this.AgeTransform.Height = this.CostGroup.Y;
     if (constructibleData != null && ((ICostFeatureProvider)constructibleData).Constructible != null && ((ICostFeatureProvider)constructibleData).Empire != null)
     {
         DepartmentOfTheTreasury agency  = ((ICostFeatureProvider)constructibleData).Empire.GetAgency <DepartmentOfTheTreasury>();
         SimulationObjectWrapper context = (((ICostFeatureProvider)constructibleData).Context == null) ? ((ICostFeatureProvider)constructibleData).Empire : ((ICostFeatureProvider)constructibleData).Context;
         string text = string.Empty;
         int    num;
         PanelFeatureCost.ComputeCostAndTurn(this.guiService, ((ICostFeatureProvider)constructibleData).Constructible, agency, context, out text, out num);
         this.TurnIcon.AgeTransform.Visible  = false;
         this.TurnValue.AgeTransform.Visible = false;
         if (((ICostFeatureProvider)constructibleData).Constructible is CreepingNodeImprovementDefinition)
         {
             IDatabase <SimulationDescriptor> database = Databases.GetDatabase <SimulationDescriptor>(false);
             text = ((!(text == "-")) ? text : string.Empty);
             CreepingNodeImprovementDefinition creepingNodeImprovementDefinition = ((ICostFeatureProvider)constructibleData).Constructible as CreepingNodeImprovementDefinition;
             SimulationObject     simulationObject = new SimulationObject("DummyNode");
             SimulationDescriptor descriptor       = null;
             if (database.TryGetValue("ClassCreepingNode", out descriptor))
             {
                 simulationObject.AddDescriptor(descriptor);
             }
             else
             {
                 Diagnostics.LogError("Could not find the class creeping node descriptor");
             }
             float propertyBaseValue = simulationObject.GetPropertyBaseValue(creepingNodeImprovementDefinition.BaseCostPropertyName);
             float num2          = simulationObject.GetPropertyBaseValue(SimulationProperties.NodeCostIncrement);
             float propertyValue = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NodeCostIncrementModifier);
             num2 *= propertyValue;
             if (creepingNodeImprovementDefinition.SubCategory == "SubCategoryVillage")
             {
                 num2 *= ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NodeOvergrownVillageCostModifier);
             }
             float  propertyValue2 = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NumberOfCreepingNodes);
             float  propertyValue3 = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NumberOfFinishedCreepingNodes);
             int    num3           = Mathf.CeilToInt(propertyBaseValue + num2 * (2f * propertyValue2 - propertyValue3 + 1f));
             float  propertyValue4 = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier);
             int    num4           = (int)Math.Max(0.0, Math.Ceiling((double)((float)creepingNodeImprovementDefinition.ConstructionTurns * propertyValue4)));
             string str            = string.Format(AgeLocalizer.Instance.LocalizeString("%FeaturePanelNodeCost"), num3.ToString(), num4.ToString());
             text = text + " " + str;
         }
         if (!string.IsNullOrEmpty(text))
         {
             this.CostValue.Text = text;
             if (this.CostValue.AgeTransform.PixelMarginTop == this.CostTitle.AgeTransform.PixelMarginTop)
             {
                 this.CostValue.AgeTransform.PixelMarginLeft = 2f * this.CostTitle.AgeTransform.PixelMarginLeft + this.CostTitle.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.CostTitle.Text), this.CostTitle.ForceCaps, false);
             }
             this.AgeTransform.Height += this.CostTitle.AgeTransform.Height;
             return;
         }
     }
     else
     {
         this.CostGroup.Visible = false;
     }
 }
Ejemplo n.º 27
0
    public void ChangeToArmyMode(bool calledByChangeModeOrderProcessor = false)
    {
        if (calledByChangeModeOrderProcessor && this.OnPrepareToConvertToArmyDelegate != null)
        {
            this.OnPrepareToConvertToArmyDelegate();
        }
        WorldPosition worldPosition = this.KaijuGarrison.WorldPosition;

        this.LeaveCurrentRegion();
        SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuGarrisonModeDescriptor);

        if (value != null)
        {
            base.RemoveDescriptor(value);
        }
        SimulationDescriptor value2 = this.SimulationDescriptorDatabase.GetValue(Kaiju.KaijuArmyModeDescriptor);

        if (value2 != null)
        {
            base.AddDescriptor(value2, false);
        }
        this.Refresh(false);
        this.KaijuArmy.ClearAllUnits();
        this.TransferUnitsToArmy();
        this.KaijuArmy.Refresh(false);
        this.KaijuGarrison.Refresh(false);
        this.GameEntityRepositoryService.Unregister(this.KaijuGarrison);
        this.Empire.RemoveChild(this.KaijuGarrison);
        this.Empire.Refresh(false);
        this.KaijuArmy.SetWorldPosition(WorldPosition.Invalid);
        this.KaijuArmy.MoveTo(worldPosition);
        this.GameEntityRepositoryService.Register(this.KaijuArmy);
        this.Empire.AddChild(this.KaijuArmy);
        this.KaijuArmy.Empire = this.Empire;
        this.KaijuArmy.Refresh(false);
        this.KaijuGarrison.Refresh(false);
        if (this.MajorEmpire != null && !this.MajorEmpire.IsEliminated && this.MajorEmpire.GetAgency <DepartmentOfDefense>().TechnologyDefinitionShipState == DepartmentOfScience.ConstructibleElement.State.Researched)
        {
            IDatabase <SimulationDescriptor> database = Databases.GetDatabase <SimulationDescriptor>(false);
            SimulationDescriptor             descriptor;
            if (database != null && database.TryGetValue(PathfindingContext.MovementCapacitySailDescriptor, out descriptor))
            {
                if (!this.KaijuArmy.SimulationObject.Tags.Contains(PathfindingContext.MovementCapacitySailDescriptor))
                {
                    this.KaijuArmy.AddDescriptor(descriptor, true);
                }
                foreach (Unit unit in this.KaijuArmy.Units)
                {
                    if (!unit.SimulationObject.Tags.Contains(PathfindingContext.MovementCapacitySailDescriptor))
                    {
                        unit.AddDescriptor(descriptor, true);
                    }
                }
            }
        }
        this.KaijuArmy.Refresh(false);
        this.ShowKaijuArmyInMap();
        this.KaijuGarrison.OnConvertedToArmy();
        this.KaijuArmy.OnConvertedToArmy();
        this.ComputeNextTurnToSpawnUnits(false);
        if (this.OnConvertedToArmyDelegate != null)
        {
            this.OnConvertedToArmyDelegate();
        }
        this.CallRefreshProvidedRegionEffects();
        this.KaijuArmy.ForceWorldOrientation(this.WorldOrientation);
    }
Ejemplo n.º 28
0
        private HeroGameStatsData[] UserProfile_GetSelectableHeroes(On.UserProfile.orig_GetSelectableHeroes orig, bool hiddenHeroesOnly)
        {
            HeroConfig[] values = Databases.GetDatabase <HeroConfig>(false).GetValues();
            foreach (HeroConfig heroConfig in values)
            {
                Log("Loaded HeroConfig with name: " + heroConfig.Name + " while GettingSelectableHeroes");
                if (heroConfig.Name == "Hero_" + GetName() || heroConfig.Name == "Hero_H0001")
                {
                    Log("Found an important Hero!");
                    Log("Displaying Data: ");
                    Log("AITarget: " + heroConfig.AITargetType);
                    Log("AIConfig:");
                    var ai = Databases.GetDatabase <AIConfig>(false).GetValue(heroConfig.Name);
                    if (ai != null)
                    {
                        Log("- Name: " + ai.Name);
                        Log("- AI TargetInteractionConfigs:");
                        foreach (AITargetInteractionConfig c in ai.AITargetInteractionConfigs)
                        {
                            Log("-- TargetType: " + c.XmlSerializableTargetType + " Interaction: " + c.Interaction);
                        }
                    }
                    Log("Archetype: " + heroConfig.Archetype);
                    Log("AttackType: " + heroConfig.AttackType);
                    Log("Equipment Slots:");
                    foreach (EquipmentSlotConfig e in heroConfig.EquipmentSlots)
                    {
                        Log("- " + e.CategoryName + ", " + e.TypeName);
                    }
                    Log("Faction: " + heroConfig.Faction);
                    Log("Damages Stat: " + heroConfig.GetDamagesStat());
                    Log("SimObj: " + heroConfig.GetHeroSimObj());
                    IDatabase <SimulationDescriptor> simDescDatabase = SimMonoBehaviour.GetSimDescDatabase();
                    SimulationDescriptor             hDesc           = simDescDatabase.GetValue("Hero");
                    SimulationDescriptor             desc            = simDescDatabase.GetValue(heroConfig.Name);

                    //Log("Hero Descriptor:");
                    //Log("Modifiers:");
                    //foreach (SimulationModifierDescriptor d in hDesc.SimulationModifierDescriptors)
                    //{
                    //    Log("- " + d.TargetPropertyName + " With operation: " + d.Operation);
                    //}
                    //Log("Properties:");
                    //foreach (SimulationPropertyDescriptor p in hDesc.SimulationPropertyDescriptors)
                    //{
                    //    Log("- " + p.Name + ": " + p.BaseValue);
                    //}

                    Log("Personal Descriptor:");
                    Log("Name, Type: " + desc.Name + ", " + desc.Type);
                    Log("Modifiers:");
                    if (desc.SimulationModifierDescriptors != null)
                    {
                        foreach (SimulationModifierDescriptor d in desc.SimulationModifierDescriptors)
                        {
                            if (d == null)
                            {
                                continue;
                            }
                            Log("- " + d.TargetPropertyName + " With operation: " + d.Operation);
                        }
                    }
                    Log("Properties:");
                    if (desc.SimulationPropertyDescriptors != null)
                    {
                        foreach (SimulationPropertyDescriptor p in desc.SimulationPropertyDescriptors)
                        {
                            if (p == null)
                            {
                                continue;
                            }
                            Log("- " + p.Name + ": " + p.BaseValue);
                        }
                    }

                    Log("Life Stat: " + heroConfig.GetLifeStat());
                    Log("Random Weight: " + heroConfig.GetRandomSelectionWeight());
                    Log("Speed Stat: " + heroConfig.GetSpeedStat());
                    Log("Wit Stat: " + heroConfig.GetWitStat());
                    if (heroConfig.IntroDialogs != null)
                    {
                        Log("Intro Dialoges:");
                        foreach (DialogConfig c in heroConfig.IntroDialogs)
                        {
                            if (c == null)
                            {
                                continue;
                            }
                            Log("- " + c.Name + ": " + c.Text);
                        }
                    }
                    Log("Event Active: " + heroConfig.IsCommunityEventActive());
                    Log("Is Event Hero: " + heroConfig.IsCommunityEventHero());
                    Log("Is Hidden: " + heroConfig.IsHidden());
                    Log("Name: " + heroConfig.Name);
                    Log("Recruit Base Cost: " + heroConfig.RecruitmentFoodCost);
                    Log("Situation Dialogs:");
                    if (heroConfig.SituationDialogCount != null)
                    {
                        foreach (Amplitude.StaticString s in heroConfig.SituationDialogCount.Keys)
                        {
                            if (s == null)
                            {
                                continue;
                            }
                            Log("- " + s + ": " + heroConfig.SituationDialogCount[s]);
                        }
                    }
                    Log("Sprite animations path: " + heroConfig.SpriteAnimationsPath);
                    Log("Unlock Level Count: " + heroConfig.UnlockLevelCount);
                }
            }
            return(orig(hiddenHeroesOnly));
        }
Ejemplo n.º 29
0
        public void ParseSimulationDescriptor(SimulationDescriptor descriptor, List <EffectDescription> effectDescriptions, StaticString defaultClass, bool displayEmptyDescriptors = false, SimulationObject context = null, bool isContextTheSource = true, bool isForceOn = false, bool parseTitle = false)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }
            GuiElement guiElement;

            if (this.GuiService.GuiPanelHelper.TryGetGuiElement(descriptor.Name, out guiElement) && guiElement is ExtendedGuiElement)
            {
                ExtendedGuiElement extendedGuiElement = guiElement as ExtendedGuiElement;
                if (extendedGuiElement.TooltipElement != null)
                {
                    if (!string.IsNullOrEmpty(extendedGuiElement.TooltipElement.EffectOverride))
                    {
                        EffectDescription effectDescription = new EffectDescription();
                        effectDescription.Override = AgeLocalizer.Instance.LocalizeString(extendedGuiElement.TooltipElement.EffectOverride);
                        if (extendedGuiElement.Name.ToString().Contains("Bonus1Value"))
                        {
                            effectDescription.Override = effectDescription.Override.Replace("+500", "+" + 500f * (float)this.GetGameSpeed() / 2f);
                        }
                        else if (extendedGuiElement.Name.ToString().Contains("Bonus2Value"))
                        {
                            effectDescription.Override = effectDescription.Override.Replace("+1000", "+" + 1000f * (float)this.GetGameSpeed() / 2f);
                        }
                        if (parseTitle)
                        {
                            effectDescription.Title = AgeLocalizer.Instance.LocalizeString(guiElement.Title);
                        }
                        effectDescriptions.Add(effectDescription);
                    }
                    if (extendedGuiElement.TooltipElement.Ignore)
                    {
                        return;
                    }
                }
            }
            if (descriptor.SimulationModifierDescriptors == null)
            {
                if (this.GuiService.GuiPanelHelper.TryGetGuiElement(descriptor.Name, out guiElement))
                {
                    if (guiElement is ExtendedGuiElement)
                    {
                        ExtendedGuiElement extendedGuiElement2 = guiElement as ExtendedGuiElement;
                        if (extendedGuiElement2.TooltipElement != null && extendedGuiElement2.TooltipElement.Ignore)
                        {
                            return;
                        }
                    }
                    EffectDescription effectDescription2 = new EffectDescription();
                    effectDescription2.Override = AgeLocalizer.Instance.LocalizeString(guiElement.Title);
                    if (guiElement.Name == "TechnologyNecrophages8")
                    {
                        effectDescription2.Override = effectDescription2.Override.Replace("+1", "+" + this.GetGameSpeed());
                    }
                    if (parseTitle)
                    {
                        effectDescription2.Title = AgeLocalizer.Instance.LocalizeString(guiElement.Title);
                    }
                    effectDescription2.On = this.ComputeReadableString(defaultClass, false);
                    effectDescriptions.Add(effectDescription2);
                }
                return;
            }
            bool flag = false;

            if (parseTitle)
            {
                flag = true;
            }
            for (int i = 0; i < descriptor.SimulationModifierDescriptors.Length; i++)
            {
                SimulationModifierDescriptor simulationModifierDescriptor = descriptor.SimulationModifierDescriptors[i];
                if (simulationModifierDescriptor.Operation != SimulationModifierDescriptor.ModifierOperation.Force && !simulationModifierDescriptor.TooltipHidden)
                {
                    EffectDescription effectDescription3 = null;
                    this.ParseModifier(descriptor, simulationModifierDescriptor, defaultClass, context, isContextTheSource, out effectDescription3, isForceOn);
                    if (effectDescription3 != null)
                    {
                        if (context != null && isContextTheSource)
                        {
                            effectDescription3.From = this.ComputeReadableString(descriptor.Name, true);
                        }
                        if (flag)
                        {
                            effectDescription3.Title = AgeLocalizer.Instance.LocalizeString("%" + descriptor.Name + "Title");
                            flag = false;
                        }
                        effectDescriptions.Add(effectDescription3);
                    }
                }
            }
        }
Ejemplo n.º 30
0
    public void UpdateInfectionStatus()
    {
        bool flag  = this.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitMimics3);
        bool flag2 = this.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitMimics1) || this.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitCultists7);
        IDatabase <SimulationDescriptor> database   = Databases.GetDatabase <SimulationDescriptor>(false);
        SimulationDescriptor             descriptor = null;

        if (!database.TryGetValue(City.TagCityStatusInfected, out descriptor))
        {
            Diagnostics.LogError("Infection Status descriptor could not be retrieved.");
            return;
        }
        if (this.LastNonInfectedOwner == null)
        {
            DepartmentOfTheInterior agency = this.Empire.GetAgency <DepartmentOfTheInterior>();
            if (!flag || !flag2 || agency.Cities.Count == 1)
            {
                this.LastNonInfectedOwner = this.Empire;
                return;
            }
            DepartmentOfPlanificationAndDevelopment agency2 = this.Empire.GetAgency <DepartmentOfPlanificationAndDevelopment>();
            global::Game game = this.gameService.Game as global::Game;
            if (game != null)
            {
                List <int> list  = new List <int>();
                List <int> list2 = new List <int>();
                foreach (global::Empire empire in game.Empires)
                {
                    if (!(empire is MajorEmpire))
                    {
                        break;
                    }
                    if (empire.Faction.Affinity.Name != this.Empire.Faction.Affinity.Name && !agency2.HasIntegratedFaction(empire.Faction))
                    {
                        list.Add(empire.Index);
                    }
                    else if (empire.Index != this.Empire.Index)
                    {
                        list2.Add(empire.Index);
                    }
                }
                if (list.Count == 0)
                {
                    list = list2;
                }
                int index = UnityEngine.Random.Range(0, list.Count);
                this.LastNonInfectedOwner = game.Empires[list[index]];
            }
        }
        if (this.Empire == this.LastNonInfectedOwner)
        {
            if (this.IsInfected)
            {
                base.RemoveDescriptor(descriptor);
                return;
            }
        }
        else if (flag)
        {
            if (!this.IsInfected)
            {
                base.AddDescriptor(descriptor, false);
                return;
            }
        }
        else
        {
            if (this.IsInfected)
            {
                base.RemoveDescriptor(descriptor);
            }
            this.LastNonInfectedOwner = this.Empire;
        }
    }