private void HeroSelectionItem_OnLeftClick(On.HeroSelectionItem.orig_OnLeftClick orig, HeroSelectionItem self) { self.GetComponent <AgeControlToggle>().OnRightClickMethod = "OnRightClick"; try { self.gameObject.AddComponent <RightClickScript>(); } catch (Exception) { mod.Log("Already added RightClickScript!"); } // Even if the hero has been selected, try to select it again. int duplicates = 0; foreach (Amplitude.StaticString s in Dungeon.NextDungeonGenerationParams.NewGame_SelectedHeroes) { if (s.Equals(self.HeroStats.ConfigName)) { duplicates++; } } if (duplicates < allowedDuplicateCountWrapper.Value) { // Try selecting it again! mod.Log("Selecting Hero: " + self.HeroStats.ConfigName + " again!"); IAudioEventService service = Services.GetService <IAudioEventService>(); SingletonManager.Get <GameSelectionPanel>(true).TrySelectHero(self.HeroStats.ConfigName); service.Play2DEvent("Master/GUI/Main_SelectHero"); return; } orig(self); }
public void OnRightClick() { SingletonManager.Get <GameSelectionPanel>(true).TryUnselectHero(GetComponent <HeroSelectionItem>().HeroStats.ConfigName); IAudioEventService service = Services.GetService <IAudioEventService>(); service.Play2DEvent("Master/GUI/Main_DeselectHero"); }
public override void Begin(params object[] parameters) { base.Begin(parameters); Diagnostics.Log("GameClientState_Turn_Begin."); this.EventService = Services.GetService <IEventService>(); IGuiService service = Services.GetService <IGuiService>(); Diagnostics.Assert(service != null); if (service.GetGuiPanel <LoadingScreen>().IsVisible) { service.GetGuiPanel <LoadingScreen>().Hide(false); service.GetGuiPanel <GameWorldScreen>().Show(new object[0]); service.GetGuiPanel <GameOverlayPanel>().Show(new object[0]); service.GetGuiPanel <InGameConsolePanel>().Load(); } Amplitude.Unity.View.IViewService service2 = Services.GetService <Amplitude.Unity.View.IViewService>(); if (service2 != null && (service2.CurrentView == null || service2.CurrentView.GetType() != typeof(WorldView))) { service2.PostViewChange(typeof(WorldView), new object[0]); } this.coroutine = Amplitude.Coroutine.StartCoroutine(this.RunAsync(), null); string text = AgeLocalizer.Instance.LocalizeString("%RichPresenceInGame" + base.GameClient.Session.SessionMode); text = text.Replace("$Name", base.GameClient.Session.GetLobbyData <string>("name", null)); text = text.Replace("$Turn", (base.GameClient.Session.GetLobbyData <int>("_Turn", 0) + 1).ToString()); Steamworks.SteamAPI.SteamFriends.SetRichPresence("status", text); IAudioEventService service3 = Services.GetService <IAudioEventService>(); if (service3 != null) { service3.Play2DEvent("Gui/Interface/EndTurnValid"); } }
public void HighlightReady() { this.HighlightCircle.Visible = true; this.HighlightCircle.StartAllModifiers(true, false); base.StartCoroutine(this.FadeCircle()); IAudioEventService service = Services.GetService <IAudioEventService>(); service.Play2DEvent("Gui/Interface/InGame/PlayerEndTurn"); }
protected override void OnLobbyChatUpdate(LobbyChatUpdateEventArgs e) { base.OnLobbyChatUpdate(e); if (base.SteamIDLobby == e.SteamIDLobby) { string text = string.Empty; if ((e.ChatMemberStateChange & LobbyChatUpdateStateChange.Entered) == LobbyChatUpdateStateChange.Entered) { text = "Entered"; IAudioEventService service = Services.GetService <IAudioEventService>(); service.Play2DEvent("Gui/Interface/Lobby/EnterLobby"); } else if ((e.ChatMemberStateChange & LobbyChatUpdateStateChange.Left) == LobbyChatUpdateStateChange.Left) { text = "Left"; IAudioEventService service2 = Services.GetService <IAudioEventService>(); service2.Play2DEvent("Gui/Interface/Lobby/QuitLobby"); } else if ((e.ChatMemberStateChange & LobbyChatUpdateStateChange.Disconnected) == LobbyChatUpdateStateChange.Disconnected) { text = "Disconnected"; IAudioEventService service3 = Services.GetService <IAudioEventService>(); service3.Play2DEvent("Gui/Interface/Lobby/QuitLobby"); } else if ((e.ChatMemberStateChange & LobbyChatUpdateStateChange.Kicked) == LobbyChatUpdateStateChange.Kicked) { text = "Kicked"; IAudioEventService service4 = Services.GetService <IAudioEventService>(); service4.Play2DEvent("Gui/Interface/Lobby/QuitLobby"); } if (!string.IsNullOrEmpty(text)) { ILocalizationService service5 = Services.GetService <ILocalizationService>(); if (service5 != null) { string text2 = string.Format("%LobbyChat{0}", text); if (e.SteamIDUserChanged == base.SteamIDUser) { text2 += "+"; } string friendPersonaName = Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(e.SteamIDUserChanged); string text3 = service5.Localize(text2).ToString().Replace("$Player", friendPersonaName); string empty = string.Empty; if (e.SteamIDMakingChanges.IsValid) { Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(e.SteamIDMakingChanges); text3 = text3.Replace("$ChangingPlayer", empty); } if (!string.IsNullOrEmpty(text3)) { base.SendLocalChatMessage("s:/" + text3); } } } } }
public override bool HandleCancelRequest() { if (this.LookingEmpire.Index != base.Empire.Index) { IAudioEventService service = Services.GetService <IAudioEventService>(); service.Play2DEvent("Gui/Interface/InGame/OpenPanelButton"); this.OnInspect(base.Empire); return(true); } return(base.HandleCancelRequest()); }
protected void OnCursorActivate(params object[] parameters) { Diagnostics.Assert(base.WorldPositionningService != null); Diagnostics.Assert(this.PlayerControllerRepositoryService != null); Diagnostics.Assert(base.GlobalPositionningService != null); if (this.City != null) { this.City.CityDistrictCollectionChange -= this.City_CityDistrictCollectionChange; this.City.Empire.GetAgency <DepartmentOfTheInterior>().CitiesCollectionChanged -= this.DistrictWorldCursor_CitiesCollectionChanged; this.City = null; this.ResourceRendererService.SetSelectedRegion(-1); } if (parameters != null) { this.City = (parameters.FirstOrDefault((object iterator) => iterator != null && iterator.GetType() == typeof(City)) as City); } if (base.CursorTarget != null) { this.WorldDistrict = base.CursorTarget.GetComponent <WorldDistrict>(); if (this.WorldDistrict != null) { this.City = this.WorldDistrict.District.City; } else if (this.City == null) { Diagnostics.LogError("Invalid cursor target (cant find component of type: 'WorldDistrict')."); return; } } else if (this.City == null) { Diagnostics.LogError("Cursor target is null."); return; } if (this.City == null) { base.Back(); return; } IAudioEventService service = Services.GetService <IAudioEventService>(); Diagnostics.Assert(service != null); service.Play2DEvent("Gui/Interface/CitySelection"); if (this.City.Empire != this.PlayerControllerRepositoryService.ActivePlayerController.Empire) { this.City.CityDistrictCollectionChange += this.City_CityDistrictCollectionChange; this.City.Empire.GetAgency <DepartmentOfTheInterior>().CitiesCollectionChanged += this.DistrictWorldCursor_CitiesCollectionChanged; return; } if (this.ResourceRendererService != null) { this.ResourceRendererService.Clear(); } this.Camp = (parameters.FirstOrDefault((object iterator) => iterator != null && iterator.GetType() == typeof(Camp)) as Camp); if (this.Camp != null || (this.District != null && this.City.Camp != null && this.City.Camp.ContainsDistrict(this.District.GUID))) { if (this.Camp == null) { this.Camp = this.City.Camp; } base.Focus(this.City.Camp, true); for (int i = 0; i < this.City.Camp.Districts.Count; i++) { this.ResourceRendererService.Add(this.City.Camp.Districts[i].WorldPosition); } } else { this.ResourceRendererService.SetSelectedRegion(this.City.Region.Index); if (this.ResourceRendererService != null) { this.City_CityDistrictCollectionChange(this, new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null)); this.City.CityDistrictCollectionChange += this.City_CityDistrictCollectionChange; this.City.Empire.GetAgency <DepartmentOfTheInterior>().CitiesCollectionChanged += this.DistrictWorldCursor_CitiesCollectionChanged; } } this.City.OnCityCampChanged += this.City_OnCityCampChanged; this.City.OnCityDisposed += this.City_OnCityDisposed; global::Empire empire = this.PlayerControllerRepositoryService.ActivePlayerController.Empire as global::Empire; if (this.City.Empire.Index == empire.Index && empire.SimulationObject.Tags.Contains("FactionTraitMimics1")) { this.departmentOfCreepingNodes = empire.GetAgency <DepartmentOfCreepingNodes>(); this.CheckNodes = true; } this.SelectCreepingNodes(10); }
private void ValidatePath() { IGuiService service = Services.GetService <IGuiService>(); IAudioEventService service2 = Services.GetService <IAudioEventService>(); Diagnostics.Assert(service2 != null); bool flag = base.SelectedUnits.Length == 0 || base.SelectedUnits.Length == this.Army.StandardUnits.Count || (this.Garrison.UnitsCount == 1 && this.Garrison.Hero != null); if (!base.IsTransferable(WorldCursor.HighlightedWorldPosition) && flag) { global::Empire empire = this.WorldArmy.Army.Empire; if (this.battleTarget is Army) { Army army = this.battleTarget as Army; if (army.Empire.Index == this.Army.Empire.Index) { int num = Mathf.Max(army.MaximumUnitSlot - army.CurrentUnitSlot, 0); if (this.Army.HasCatspaw || army.HasCatspaw) { QuickWarningPanel.Show("%UnitsTransferImpossibleWithCatsPawArmy"); } else if (this.Army.StandardUnits.Count > num) { QuickWarningPanel.Show(string.Format(AgeLocalizer.Instance.LocalizeString("%UnitsTransferNotEnoughSlotsInTargetArmy"), num)); } else if (this.Army.GetPropertyValue(SimulationProperties.Movement) <= 0f && base.WorldPositionningService.GetDistance(this.Army.WorldPosition, army.WorldPosition) == 1) { QuickWarningPanel.Show(AgeLocalizer.Instance.LocalizeString("%" + ArmyAction_TransferUnits.NotEnoughMovementToTransfer + "Description")); } else if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Length > 1 && !this.Army.HasCatspaw && !army.HasCatspaw) { OrderGoToAndMerge order = new OrderGoToAndMerge(empire.Index, this.WorldArmy.Army.GUID, this.battleTarget.GUID, (from unit in base.SelectedUnits select unit.GUID).ToArray <GameEntityGUID>(), this.TemporaryWorldPath); this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order); } } else { DepartmentOfForeignAffairs agency = empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency != null); bool flag2 = this.Army.IsNaval == army.IsNaval; if ((agency.CanAttack(this.battleTarget) || this.WorldArmy.Army.IsPrivateers) && flag2) { ArmyAction armyAction = null; IDatabase <ArmyAction> database = Databases.GetDatabase <ArmyAction>(false); float cost = 0f; if (database != null && database.TryGetValue(ArmyAction_Attack.ReadOnlyName, out armyAction)) { cost = armyAction.GetCostInActionPoints(); } if (!this.Army.HasEnoughActionPoint(cost)) { QuickWarningPanel.Show(AgeLocalizer.Instance.LocalizeString("%ArmyNotEnoughActionPointsDescription")); } else if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Length > 1) { OrderGoToAndAttack order2 = new OrderGoToAndAttack(empire.Index, this.WorldArmy.Army.GUID, this.battleTarget.GUID, this.TemporaryWorldPath); this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order2); } else { OrderAttack order3 = new OrderAttack(empire.Index, this.WorldArmy.Army.GUID, this.battleTarget.GUID); this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order3); } service2.Play2DEvent("Gui/Interface/InGame/OrderAttack"); } else if (army.Empire is MajorEmpire && flag2) { global::Empire empire2 = army.Empire; service.GetGuiPanel <WarDeclarationModalPanel>().Show(new object[] { empire2, "AttackTarget" }); } } } else { bool flag3 = false; if (this.battleTarget != null) { if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Length > 1) { flag3 = (this.TemporaryWorldPath.ControlPoints.Length == 0); flag3 |= (this.TemporaryWorldPath.ControlPoints.Length == 1 && (int)this.TemporaryWorldPath.ControlPoints[0] == this.TemporaryWorldPath.Length - 1); } else { flag3 = base.PathfindingService.IsTransitionPassable(this.Army.WorldPosition, this.battleTarget.WorldPosition, this.Army, PathfindingFlags.IgnoreArmies | PathfindingFlags.IgnoreOtherEmpireDistrict | PathfindingFlags.IgnoreDiplomacy | PathfindingFlags.IgnorePOI | PathfindingFlags.IgnoreSieges | PathfindingFlags.IgnoreKaijuGarrisons, null); } } if (flag3 || this.battleTarget is Fortress || this.battleTarget is KaijuGarrison) { flag3 = false; bool flag4 = true; if (this.battleTarget is KaijuGarrison) { KaijuGarrison kaijuGarrison = this.battleTarget as KaijuGarrison; DepartmentOfForeignAffairs agency2 = empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency2 != null); if (!agency2.CanAttack(this.battleTarget)) { flag4 = false; global::Empire empire3 = kaijuGarrison.Empire; service.GetGuiPanel <WarDeclarationModalPanel>().Show(new object[] { empire3, "AttackTarget" }); } } if (flag4) { ArmyActionModalPanel guiPanel = service.GetGuiPanel <ArmyActionModalPanel>(); if (guiPanel != null) { WorldPosition destination = (this.TemporaryWorldPath == null || this.TemporaryWorldPath.Length <= 1) ? WorldPosition.Invalid : this.TemporaryWorldPath.Destination; if (guiPanel.CheckForArmyActionsAvailability(this.Army, this.battleTarget, destination).Count > 0) { flag3 = true; } } } } if (flag3 && this.battleTarget != null && !this.Army.IsPrivateers) { MajorEmpire majorEmpire = null; if (this.battleTarget is Garrison) { majorEmpire = ((this.battleTarget as Garrison).Empire as MajorEmpire); } else if (this.battleTarget is District) { majorEmpire = ((this.battleTarget as District).Empire as MajorEmpire); } if (majorEmpire != null && majorEmpire.Index != this.Army.Empire.Index) { flag3 = this.Army.Empire.GetAgency <DepartmentOfForeignAffairs>().IsSymetricallyDiscovered(majorEmpire); } } if (flag3) { WorldPosition worldPosition = (this.TemporaryWorldPath == null || this.TemporaryWorldPath.Length <= 1) ? WorldPosition.Invalid : this.TemporaryWorldPath.Destination; service.Show(typeof(ArmyActionModalPanel), new object[] { this.Army, this.battleTarget, base.SelectedUnits, worldPosition }); } else if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Destination != WorldPosition.Invalid) { OrderGoTo order4 = new OrderGoTo(empire.Index, this.WorldArmy.Army.GUID, this.TemporaryWorldPath.Destination); this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order4); service2.Play2DEvent("Gui/Interface/InGame/OrderGoTo"); } else if (WorldCursor.HighlightedWorldPosition != WorldPosition.Invalid) { Region region = base.WorldPositionningService.GetRegion(WorldCursor.HighlightedWorldPosition); if (region != null && region.City != null && region.City.Empire != null) { DepartmentOfForeignAffairs agency3 = this.Army.Empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency3 != null); if (!agency3.CanMoveOn(WorldCursor.HighlightedWorldPosition, this.WorldArmy.Army.IsPrivateers, this.WorldArmy.Army.IsCamouflaged)) { District district = base.WorldPositionningService.GetDistrict(WorldCursor.HighlightedWorldPosition); if ((district == null || district.Type == DistrictType.Exploitation) && region.City.Empire is MajorEmpire) { service.GetGuiPanel <WarDeclarationModalPanel>().Show(new object[] { region.City.Empire, "BreakCloseBorder" }); } } } } } } this.LastHighlightedWorldPosition = WorldPosition.Invalid; this.LastUnpathableWorldPosition = WorldPosition.Invalid; this.SelectTarget(); this.UpdateBattlegroundVisibility(); if (this.TemporaryWorldPath != null) { this.PathRendererService.RemovePath(this.TemporaryWorldPath); this.TemporaryWorldPath = null; } }
protected override void OnCursorActivate(bool activate, params object[] parameters) { base.OnCursorActivate(activate, parameters); if (!activate) { if (this.PathRendererService != null) { if (this.TemporaryWorldPath != null) { this.PathRendererService.RemovePath(this.TemporaryWorldPath); this.TemporaryWorldPath = null; } if (this.WorldPath != null) { this.PathRendererService.RemovePath(this.WorldPath); this.WorldPath = null; } } if (this.WorldArmy != null) { this.WorldArmy.Army.WorldPathChange -= this.Army_WorldPathChange; this.WorldArmy.Army.WorldPositionChange -= this.Army_WorldPositionChange; this.WorldArmy = null; } this.LastHighlightedWorldPosition = default(WorldPosition); this.LastHighlightedWorldPosition = WorldPosition.Invalid; this.battleTarget = null; this.HideBattleZone(); return; } Diagnostics.Assert(base.GameEntityRepositoryService != null); Diagnostics.Assert(base.PathfindingService != null); Diagnostics.Assert(this.PlayerControllerRepositoryService != null); Diagnostics.Assert(base.WorldPositionningService != null); Diagnostics.Assert(this.PathRendererService != null); if (base.CursorTarget == null) { Diagnostics.LogError("Cursor target is null."); return; } this.WorldArmy = base.CursorTarget.GetComponent <WorldArmy>(); if (this.WorldArmy == null) { Diagnostics.LogError("Invalid cursor target (cant find component of type: 'WorldArmy')."); return; } if (this.PlayerControllerRepositoryService == null || this.PlayerControllerRepositoryService.ActivePlayerController == null) { return; } Diagnostics.Assert(this.WorldArmy.Army != null); if (this.WorldArmy.Army.Empire != this.PlayerControllerRepositoryService.ActivePlayerController.Empire) { return; } base.AddMouseCursorKey("PlayerArmyWorldCursor"); for (int i = 0; i < this.allArmyActions.Count; i++) { StaticString staticString = this.allArmyActions[i].MouseCursorKey(); if (staticString != null && this.allArmyActions[i].MayExecuteSomewhereLater(this.Army)) { base.AddMouseCursorKey(staticString); } } base.Focus(this.Army, false); IAudioEventService service = Services.GetService <IAudioEventService>(); Diagnostics.Assert(service != null); service.Play2DEvent("Gui/Interface/InGame/SelectUnit"); if (this.WorldArmy.Army.WorldPath != null && this.WorldArmy.Army.WorldPath.Length > 1) { this.WorldPath = this.WorldArmy.Army.WorldPath; this.WorldPath.Rebuild(this.Army.WorldPosition, this.Army, this.Army.GetPropertyValue(SimulationProperties.MovementRatio), int.MaxValue, PathfindingFlags.IgnoreArmies, false); this.PathRendererService.RenderPath(this.WorldPath, this.WorldArmy.Army.WorldPosition); } this.WorldArmy.Army.WorldPathChange += this.Army_WorldPathChange; this.WorldArmy.Army.WorldPositionChange += this.Army_WorldPositionChange; }