private void OnInfectedCityGarrisonShortcut() { this.CurrentSelection = InfectedCityLine.CurrentCity; this.EnforceRadios(); this.UnbindSubPanels(); this.SetupGarrisonPanel(InfectedCityLine.CurrentCity); }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { Army army = aiBehaviorTree.Variables[this.TargetVarName] as Army; Kaiju kaiju = aiBehaviorTree.Variables[this.TargetVarName] as Kaiju; if (army == null && kaiju != null && kaiju.OnArmyMode()) { army = kaiju.KaijuArmy; } if (army != null) { return(this.ArmyExecute(army, aiBehaviorTree, parameters)); } Garrison garrison = aiBehaviorTree.Variables[this.TargetVarName] as Garrison; if (garrison == null && kaiju != null && kaiju.OnGarrisonMode()) { garrison = kaiju.KaijuGarrison; } if (garrison != null) { return(this.GeneralExecute(garrison, aiBehaviorTree, parameters)); } aiBehaviorTree.ErrorCode = 10; return(State.Failure); }
private void Client_TurnEnded_RegenUnits() { if (this.OnArmyMode()) { return; } Garrison activeTroops = this.GetActiveTroops(); float num = activeTroops.GetPropertyValue(SimulationProperties.InGarrisonRegenModifier); if (this.majorEmpire != null) { Region region = this.gameService.Game.Services.GetService <IWorldPositionningService>().GetRegion(this.WorldPosition); if (region.Owner != null && region.Owner.Index == this.Empire.Index) { num += this.Empire.GetPropertyValue(SimulationProperties.InOwnedRegionUnitRegenModifier); } } else { num += this.Empire.GetPropertyValue(SimulationProperties.InOwnedRegionUnitRegenModifier); } foreach (Unit unit in activeTroops.Units) { DepartmentOfDefense.RegenUnit(unit, num, 0); unit.Refresh(false); } this.Empire.GetAgency <DepartmentOfDefense>().CleanGarrisonAfterEncounter(activeTroops); this.Refresh(false); }
protected override bool TryComputeArmyMissionParameter() { this.besiegers = null; if (this.City.BesiegingEmpire != null) { this.besiegers = DepartmentOfTheInterior.GetBesiegers(this.City); if (this.besiegers.Length == 0) { return(false); } float num = 0f; float num2 = 0f; Garrison defender = this.besiegers[0]; this.intelligenceAiHelper.EstimateMPInBattleground(this.City, defender, ref num, ref num2); if (num > num2) { return(this.AskForArmy(true)); } float propertyValue = this.City.GetPropertyValue(SimulationProperties.CityDefensePoint); float besiegingPower = DepartmentOfTheInterior.GetBesiegingPower(this.City, true); if (propertyValue <= besiegingPower) { return(this.AskForArmy(true)); } } else { if (base.AIDataArmyGUID.IsValid) { return(this.DisbandArmy()); } base.Completion = AICommanderMission.AICommanderMissionCompletion.Success; } return(false); }
private void OnSelectKaiju() { this.CurrentSelection = KaijuLine.CurrentKaiju; this.EnforceRadios(); this.HideSubPanels(false); this.UnbindSubPanels(); }
private void OnSelectInfectedCity() { this.CurrentSelection = InfectedCityLine.CurrentCity; this.EnforceRadios(); this.HideSubPanels(false); this.UnbindSubPanels(); }
private void OnSelectFortress() { this.CurrentSelection = FortressLine.CurrentFortress; this.EnforceRadios(); this.HideSubPanels(false); this.UnbindSubPanels(); }
private void OnSelectVillage() { this.CurrentSelection = VillageLine.CurrentVillage; this.EnforceRadios(); this.HideSubPanels(false); this.UnbindSubPanels(); }
private void BuyTradable(ITradable tradable, Garrison destination = null) { if (base.PlayerController == null) { Diagnostics.LogError("No PlayerController on BuyablePanel."); return; } if (this.SelectedTradableLine == null || this.SelectedTradableLine.Tradable == null) { Diagnostics.LogError("Trying to buy a tradable while there is no tradable selected."); return; } if (this.SelectedTradableLine.Tradable is TradableUnit && !(this.SelectedTradableLine.Tradable is TradableHero) && destination != null) { OrderBuyoutTradableUnit order = new OrderBuyoutTradableUnit(base.Empire.Index, this.SelectedTradableLine.Tradable.UID, (float)this.CurrentQuantity, destination.GUID); base.PlayerController.PostOrder(order); } else { OrderBuyoutTradable order2 = new OrderBuyoutTradable(base.Empire.Index, this.SelectedTradableLine.Tradable.UID, (float)this.CurrentQuantity); base.PlayerController.PostOrder(order2); } this.SelectedTradableLine = null; this.RefreshButtons(); }
private State GeneralExecute(Garrison targetgarr, AIBehaviorTree aiBehaviorTree, params object[] parameters) { bool flag = false; IEncounterRepositoryService service = Services.GetService <IGameService>().Game.Services.GetService <IEncounterRepositoryService>(); if (service != null) { IEnumerable <Encounter> enumerable = service; if (enumerable != null) { flag = enumerable.Any((Encounter encounter) => encounter.IsGarrisonInEncounter(targetgarr.GUID, false)); } } if (this.Inverted) { if (!flag) { return(State.Success); } aiBehaviorTree.ErrorCode = 17; return(State.Failure); } else { if (flag) { return(State.Success); } aiBehaviorTree.ErrorCode = 16; return(State.Failure); } }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) != AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } if (!aiBehaviorTree.Variables.ContainsKey(this.TargetVarName)) { return(State.Failure); } Garrison garrison = aiBehaviorTree.Variables[this.TargetVarName] as Garrison; if (aiBehaviorTree.Variables[this.TargetVarName] is Kaiju) { garrison = (aiBehaviorTree.Variables[this.TargetVarName] as Kaiju).GetActiveTroops(); } if (garrison == null) { aiBehaviorTree.ErrorCode = 10; return(State.Failure); } if (garrison == army) { return(State.Failure); } IWorldPositionable worldPositionable = garrison as IWorldPositionable; if (worldPositionable == null) { return(State.Failure); } if (this.worldPositionningService.GetDistance(army.WorldPosition, worldPositionable.WorldPosition) > 1) { return(State.Failure); } if (army.GetPropertyValue(SimulationProperties.Movement) <= 0f) { return(State.Failure); } WorldPosition bestAttackPosition = this.GetBestAttackPosition(army, garrison, worldPositionable); if (bestAttackPosition != army.WorldPosition) { if (aiBehaviorTree.Variables.ContainsKey(this.Output_BestAttackPositionVarName)) { aiBehaviorTree.Variables[this.Output_BestAttackPositionVarName] = bestAttackPosition; } else { aiBehaviorTree.Variables.Add(this.Output_BestAttackPositionVarName, bestAttackPosition); } return(State.Success); } return(State.Failure); }
private void ValidateDestinationChoice(Garrison garrison) { if (this.SelectedTradableLine == null || this.SelectedTradableLine.Tradable == null) { Diagnostics.LogError("No tradable unit selected after city validation."); return; } this.BuyTradable(this.SelectedTradableLine.Tradable, garrison); }
void HandleGetGarrisonInfo(GetGarrisonInfo getGarrisonInfo) { Garrison garrison = _player.GetGarrison(); if (garrison != null) { garrison.SendInfo(); } }
void HandleGarrisonRequestBlueprintAndSpecializationData(GarrisonRequestBlueprintAndSpecializationData garrisonRequestBlueprintAndSpecializationData) { Garrison garrison = _player.GetGarrison(); if (garrison != null) { garrison.SendBlueprintAndSpecializationData(); } }
void HandleGarrisonGetMapData(GarrisonGetMapData garrisonGetMapData) { Garrison garrison = _player.GetGarrison(); if (garrison != null) { garrison.SendMapData(_player); } }
void HandleGarrisonGetBuildingLandmarks(GarrisonGetBuildingLandmarks garrisonGetBuildingLandmarks) { Garrison garrison = _player.GetGarrison(); if (garrison != null) { garrison.SendBuildingLandmarks(_player); } }
public void MoveToRegion(WorldPosition position) { IGameService service = Services.GetService <IGameService>(); if (service == null) { Diagnostics.LogError("Cannot retreive the gameService."); return; } IWorldPositionningService service2 = service.Game.Services.GetService <IWorldPositionningService>(); if (service2 == null) { Diagnostics.LogError("Cannot retreive the worldPositionningService."); return; } Region region = service2.GetRegion(position); if (region == null) { Diagnostics.LogError("Cannot retreive the region."); return; } Garrison activeTroops = this.GetActiveTroops(); List <Unit> list = new List <Unit>(); foreach (Unit unit in activeTroops.StandardUnits) { if (unit.SimulationObject.Tags.Contains(DownloadableContent16.TransportShipUnit)) { list.Add(unit); } } if (list.Count > 0) { for (int i = 0; i < list.Count; i++) { list[i].SwitchToEmbarkedUnit(false); } if (this.OnArmyMode()) { this.KaijuArmy.SetSails(); } } this.MoveTo(position); if (this.OnArmyMode()) { this.ChangeToGarrisonMode(false); return; } if (this.OnGarrisonMode()) { this.LeaveCurrentRegion(); this.OwnRegion(region); } }
private bool EvaluateImmolationNeed(Army army, Garrison target) { float num = 0f; float num2 = 0f; AIScheduler.Services.GetService <IIntelligenceAIHelper>().EstimateMPInBattleground(army, target, ref num2, ref num); float num3 = num / num2; return(num3 < this.PowerRatioCeil && num3 > this.PowerRatioFloor); }
public void garrisonIn(Building b) { //make a new garrison instance as a child of the action group object Garrison gar = ObjectManager.initGarrison(transform); //set building to garrison in gar.setTarget(b); //add the action to the action group component mActions.prependAction(gar); }
private WorldPosition GetBestAttackPosition(Army army, Garrison target, IWorldPositionable targetWorldPositionable) { bool flag = this.worldPositionningService.IsWaterTile(targetWorldPositionable.WorldPosition); WorldPosition worldPosition = army.WorldPosition; float num = 0f; float num2 = 0f; this.intelligenceAiHelper.EstimateMPInBattleground(army, worldPosition, target, ref num2, ref num); if (num == 0f) { num = 1f; } float num3 = num2 / num; float num4 = 0f; float num5 = 0f; WorldOrientation orientation = this.worldPositionningService.GetOrientation(targetWorldPositionable.WorldPosition, army.WorldPosition); WorldOrientation direction = orientation.Rotate(-1); WorldPosition neighbourTile = this.worldPositionningService.GetNeighbourTile(targetWorldPositionable.WorldPosition, direction, 1); if (neighbourTile.IsValid && this.worldPositionningService.IsWaterTile(neighbourTile) == flag && this.pathfindingService.IsTransitionPassable(neighbourTile, targetWorldPositionable.WorldPosition, army, OrderAttack.AttackFlags, null) && this.pathfindingService.IsTileStopableAndPassable(neighbourTile, army, PathfindingFlags.IgnoreFogOfWar, null) && this.pathfindingService.IsTransitionPassable(neighbourTile, army.WorldPosition, army, OrderAttack.AttackFlags, null)) { this.intelligenceAiHelper.EstimateMPInBattleground(army, neighbourTile, target, ref num5, ref num4); if (num5 == 0f) { num5 = 1f; } float num6 = num5 / num4; if (num3 < num6) { num3 = num6; num2 = num5; num = num4; worldPosition = neighbourTile; } } WorldOrientation direction2 = orientation.Rotate(1); WorldPosition neighbourTile2 = this.worldPositionningService.GetNeighbourTile(targetWorldPositionable.WorldPosition, direction2, 1); if (neighbourTile2.IsValid && this.worldPositionningService.IsWaterTile(neighbourTile2) == flag && this.pathfindingService.IsTransitionPassable(neighbourTile2, targetWorldPositionable.WorldPosition, army, OrderAttack.AttackFlags, null) && this.pathfindingService.IsTileStopableAndPassable(neighbourTile2, army, PathfindingFlags.IgnoreFogOfWar, null) && this.pathfindingService.IsTransitionPassable(neighbourTile2, army.WorldPosition, army, OrderAttack.AttackFlags, null)) { this.intelligenceAiHelper.EstimateMPInBattleground(army, neighbourTile2, target, ref num5, ref num4); if (num5 == 0f) { num5 = 1f; } float num7 = num5 / num4; if (num3 < num7) { num2 = num5; num = num4; worldPosition = neighbourTile2; } } return(worldPosition); }
static void Main(string[] args) { var locations = new LocationRepository().GetMediumScenarioLocations(); var british = new Domain.Entities.British(1, "British", 5, new BritishForces(7, 10, 3, 6, 6)); var garrison = new Garrison(new Map(locations), british); foreach (var movement in garrison.CommandMovements) { System.Console.WriteLine(movement.Description); } System.Console.ReadKey(); }
private void ResetActiveGarrisonUnitProperties() { Garrison activeTroops = this.GetActiveTroops(); foreach (Unit unit in activeTroops.Units) { unit.UpdateExperienceReward(this.Empire); unit.SetPropertyBaseValue(SimulationProperties.ActionPointsSpent, 0f); unit.SetPropertyBaseValue(SimulationProperties.MovementRatio, 1f); } this.Refresh(false); }
private Garrison CreateGarrison(Dictionary <UnitType, int> armyForGarrison, Player owner) { var location = owner.Location; var garrison = new Garrison(armyForGarrison, location, owner); garrison.UnityId = "Garrison " + lastId++; actor.World.Round.Map[location].AddObject(garrison); actor.World.HommObjectsCreationHelper.CreateArmy(garrison, garrison.location); actor.World.HommEngine.SetFlag(garrison.UnityId, owner.Name); return(garrison); }
void HandleGarrisonCancelConstruction(GarrisonCancelConstruction garrisonCancelConstruction) { if (!_player.GetNPCIfCanInteractWith(garrisonCancelConstruction.NpcGUID, NPCFlags.None, NPCFlags2.GarrisonArchitect)) { return; } Garrison garrison = _player.GetGarrison(); if (garrison != null) { garrison.CancelBuildingConstruction(garrisonCancelConstruction.PlotInstanceID); } }
void HandleGarrisonPurchaseBuilding(GarrisonPurchaseBuilding garrisonPurchaseBuilding) { if (!_player.GetNPCIfCanInteractWith(garrisonPurchaseBuilding.NpcGUID, NPCFlags.None, NPCFlags2.GarrisonArchitect)) { return; } Garrison garrison = _player.GetGarrison(); if (garrison != null) { garrison.PlaceBuilding(garrisonPurchaseBuilding.PlotInstanceID, garrisonPurchaseBuilding.BuildingID); } }
private void Debug(Garrison garrison) { Debugger.Log($"Garrison guards:"); foreach (var kv in garrison.Army) { Debugger.Log($"{kv.Key} - {kv.Value}"); } Debugger.Log($"{actor.ControllerId} army:"); foreach (var kv in actor.Player.Army) { Debugger.Log($"{kv.Key} - {kv.Value}"); } }
private void Client_TurnBegin_UpdateUnitDesigns() { Garrison activeTroops = this.GetActiveTroops(); UnitDesign unitDesign = this.KaijuEmpire.FindMonsterDesign(true); UnitDesign newUnitDesign = this.KaijuEmpire.FindLiceDesign(true); foreach (Unit unit in activeTroops.Units) { if (unit.UnitDesign.Tags.Contains(Kaiju.MonsterUnitTag) && unit.UnitDesign.Model != unitDesign.Model) { unit.RetrofitTo(unitDesign); } else if (unit.UnitDesign.Tags.Contains(Kaiju.LiceUnitTag) && unit.UnitDesign.Model != unitDesign.Model) { unit.RetrofitTo(newUnitDesign); } } }
private void OnConstructionShortcut() { this.CurrentSelection = CityLine.CurrentCity; this.EnforceRadios(); this.UnbindSubPanels(); this.cityOptionsPanel.Bind(CityLine.CurrentCity); this.cityQueuePanel.Bind(CityLine.CurrentCity); if (!this.cityOptionsPanel.IsVisible) { this.cityOptionsPanel.Show(new object[0]); } else { this.cityOptionsPanel.RefreshContent(); } if (!this.cityQueuePanel.IsVisible) { this.cityQueuePanel.Show(new object[0]); } else { this.cityQueuePanel.RefreshContent(); } if (this.cityGarrisonPanel.IsVisible) { this.cityGarrisonPanel.Hide(true); } if (this.CityWorkersPanel.IsVisible) { this.CityWorkersPanel.Hide(true); } if (this.villageGarrisonPanel.IsVisible) { this.villageGarrisonPanel.Hide(true); } if (this.fortressGarrisonPanel.IsVisible) { this.fortressGarrisonPanel.Hide(true); } if (this.kaijuGarrisonPanel.IsVisible) { this.kaijuGarrisonPanel.Hide(true); } }
private void btnCalculate_Click(object sender, EventArgs e) { LoadConfiguration(); results_results.Text = ""; List <Player> CalculatedPlayers = new List <Player>(); foreach (Player p in AllPlayers) { CalculatedPlayers.Add(new Player(p)); } AllGarrison = new List <Garrison>(); while (CalculatedPlayers.Count(x => x.ArmyPower < ActiveConfiguration.TargetPowerLevel) > 0) { int playerIndex = CalculatedPlayers.IndexOf(CalculatedPlayers.Where(x => x.ArmyPower < ActiveConfiguration.TargetPowerLevel).OrderByDescending(x => x.ArmyPower).First()); int delta = ActiveConfiguration.TargetPowerLevel - CalculatedPlayers[playerIndex].ArmyPower; if (CalculatedPlayers.Count(x => x.Is_Active && x.ArmyPower - delta > ActiveConfiguration.TargetPowerLevel) == 0) { break; } int fromPlayerIndex = CalculatedPlayers.IndexOf(CalculatedPlayers.Where(x => x.Is_Active && x.ArmyPower - delta > ActiveConfiguration.TargetPowerLevel && AllGarrison.Count(z => z.From_Id == x.Id) < ActiveConfiguration.MaxMarches).OrderBy(x => x.ArmyPower).First()); Garrison g = new Garrison(); g.From_Id = CalculatedPlayers[fromPlayerIndex].Id; g.From_Name = CalculatedPlayers[fromPlayerIndex].Name; g.To_Id = CalculatedPlayers[playerIndex].Id; g.To_Name = CalculatedPlayers[playerIndex].Name; g.ArmyPower = delta; CalculatedPlayers[fromPlayerIndex].ArmyPower -= delta; CalculatedPlayers[playerIndex].ArmyPower += delta; AllGarrison.Add(g); } foreach (Garrison g in AllGarrison) { string template = $"From {g.From_Name} to {g.To_Name} -> {g.ArmyPower}\r\n"; results_results.Text += template; } }
private void _Internal_RegroupSmallFreeArmies(Garrison garrison) { int num = 0; int num2 = 0; for (int i = 0; i < garrison.StandardUnits.Count; i++) { AIData_Unit aidata_Unit; if (this.aiDataRepository.TryGetAIData <AIData_Unit>(garrison.StandardUnits[i].GUID, out aidata_Unit)) { if (aidata_Unit.ReservationExtraTag == AIData_Unit.AIDataReservationExtraTag.FreeForExploration) { num++; } else { num2++; } } } float num3 = (float)num / (float)garrison.MaximumUnitSlot; int num4 = Mathf.Max(this.minimumUnitsToKeepInGarrison, Mathf.CeilToInt((float)garrison.MaximumUnitSlot * this.unitInGarrisonMaxPercent)); if (num3 >= this.unitInGarrisonMaxPercent) { if (num2 < num4) { num -= num4 - num2; } int num5 = 0; while (num5 < garrison.StandardUnits.Count && num > 0) { AIData_Unit aidata_Unit2; if (this.aiDataRepository.TryGetAIData <AIData_Unit>(garrison.StandardUnits[num5].GUID, out aidata_Unit2) && aidata_Unit2.ReservationExtraTag == AIData_Unit.AIDataReservationExtraTag.FreeForExploration) { num--; this.smallEntitiesToRegroup.Add(aidata_Unit2); } num5++; } } }