public static bool Prefix(CombatHUDMechwarriorTray __instance, Team team, CombatGameState ___Combat) { try { //__instance.displayedTeam = team; Logger.M.TWL(0, "CombatHUDMechwarriorTray.RefreshTeam team:" + team.DisplayName + " unitCount:" + team.unitCount); foreach (var lance in ___Combat.ActiveContract.Lances.Lances) { Logger.M.WL(1, "lance:" + lance.Key + " " + lance.Value.Count); foreach (var unit in lance.Value) { Logger.M.WL(2, "pilot:" + unit.Pilot.Description.Id + " unit:" + (unit.Unit != null?unit.Unit.Description.Id:"not a mech") + " team:" + unit.TeamDefinitionGuid); } } typeof(CombatHUDMechwarriorTray).GetField("displayedTeam", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, team); CombatHUDPortrait[] Portraits = (CombatHUDPortrait[])typeof(CombatHUDMechwarriorTray).GetField("Portraits", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance); for (int index = 0; index < Portraits.Length; ++index) { Logger.M.WL(1, "set portrait " + index + " unit:" + (index < team.unitCount? team.units[index].DisplayName:"null")); if (index < team.unitCount) { Portraits[index].DisplayedActor = team.units[index]; } else { Portraits[index].DisplayedActor = null; } } return(false); } catch (Exception e) { Logger.LogLine(e.ToString()); return(true); } }
public static Vector3 LastPointAlongSegmentInsideRegion(CombatGameState combat, Vector3 start, Vector3 end, string regionGUID, out bool pointIsValid) { if (!PointInRegion(combat, start, regionGUID)) { pointIsValid = false; return(Vector3.zero); } pointIsValid = true; if (PointInRegion(combat, end, regionGUID)) { return(end); } Vector3 bestYet = start; float segmentLength = (end - start).magnitude; for (int step = 1; step < segmentLength; ++step) { float frac = step / segmentLength; Vector3 interpolated = start + (end - start) * frac; if (!PointInRegion(combat, interpolated, regionGUID)) { break; } bestYet = interpolated; } return(bestYet); }
public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState, ref bool __result) { if (Core.Settings.StoodUpPilotingRoll == false) { return(true); } try { __result = true; Mech actorByGuid = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech; if (actorByGuid == null) { Log.LogWrite("MechStartupInvocation.Invoke failed! Unable to Mech!\n"); return(true); } Log.LogWrite("Mech stoodup roll\n"); float limit = actorByGuid.StoodUpRoll(); float roll = Random.Range(0f, 1f); Log.LogWrite(" roll = " + roll + " against " + limit + "\n"); if (roll < limit) { Log.LogWrite(" success\n"); return(true); } else { Log.LogWrite(" fail to stand up\n"); combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new FloatieMessage(__instance.MechGUID, __instance.MechGUID, "__/CAE.StandUpFail/__", FloatieMessage.MessageNature.Buff)); combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new AddSequenceToStackMessage(actorByGuid.DoneNoAnimation())); } return(false); } catch (Exception e) { Log.LogWrite(e.ToString() + "\n"); } return(true); }
public static void commitDamage(this CombatGameState combat) { foreach (AbstractActor actor in combat.AllActors) { actor.IncomingDamage().commitDamage(); } }
private static AbstractActor InitAbstractActor(AbstractActor actor) { // Init the combat ref for constants ConstructorInfo constantsCI = AccessTools.Constructor(typeof(CombatGameConstants), new Type[] { }); CombatGameConstants constants = (CombatGameConstants)constantsCI.Invoke(new object[] { }); CombatGameState cgs = new CombatGameState(); Traverse constantsT = Traverse.Create(cgs).Property("Constants"); constantsT.SetValue(constants); Traverse combatT = Traverse.Create(actor).Property("Combat"); combatT.SetValue(cgs); // Init any required stats actor.StatCollection = new StatCollection(); // ModStats //actor.StatCollection.AddStatistic<int>(ModStats.PunchAttackMod, 0); // Vanilla actor.StatCollection.AddStatistic <float>("SensorSignatureModifier", 1.0f); return(actor); }
public static void Postfix(CombatHUDWeaponSlot __instance, CombatGameState ___Combat, ICombatant target) { try { if (DemandingJumps.Settings.ToHitSelfJumpedSpareAI && !___Combat.LocalPlayerTeam.IsActive) { return; } Logger.Info("[CombatHUDWeaponSlot_SetHitChance_POSTFIX] CombatGameState.LocalPlayerTeam.IsActive: " + ___Combat.LocalPlayerTeam.IsActive); AbstractActor attacker = __instance.DisplayedWeapon.parent; bool AttackerJumpedThisRound = attacker.HasMovedThisRound && attacker.JumpedLastRound; Logger.Info("[CombatHUDWeaponSlot_SetHitChance_POSTFIX] Fields.JumpPreview: " + Fields.JumpPreview); Logger.Info("[CombatHUDWeaponSlot_SetHitChance_POSTFIX] AttackerJumpedThisRound: " + AttackerJumpedThisRound); if (AttackerJumpedThisRound) { int ToHitSelfJumpedModifier = Utilities.GetAttackerJumpedAccuracyModifier(attacker); Traverse AddToolTipDetail = Traverse.Create(__instance).Method("AddToolTipDetail", "SELF JUMPED", ToHitSelfJumpedModifier); Logger.Info($"[CombatHUDWeaponSlot_SetHitChance_POSTFIX] Invoking AddToolTipDetail for ToHitSelfJumped: {ToHitSelfJumpedModifier}"); AddToolTipDetail.GetValue(); } } catch (Exception e) { Logger.Error(e); } }
public override void Run(RunPayload payload) { if (!GetObjectReferences()) { return; } this.payload = payload; SaveSpawnPositions(lance); Main.Logger.Log($"[SpawnLanceMembersAroundTarget] Attempting for '{lance.name}'"); CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat; Vector3 validOrientationTargetPosition = GetClosestValidPathFindingHex(orientationTarget, orientationTarget.transform.position, $"OrientationTarget.{orientationTarget.name}"); lance.transform.position = validOrientationTargetPosition; List <GameObject> spawnPoints = lance.FindAllContains("SpawnPoint"); foreach (GameObject spawnPoint in spawnPoints) { bool success = SpawnLanceMember(spawnPoint, validOrientationTargetPosition, lookTarget, lookDirection); if (!success) { break; } } invalidSpawnLocations.Clear(); }
private void RegenerateRegion(GameObject regionGo) { CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat; RegionGameLogic regionGameLogic = regionGo.GetComponent <RegionGameLogic>(); List <Vector3> meshPoints = new List <Vector3>(); // Get all region points and fix the y height foreach (Transform t in regionGo.transform) { if (t.gameObject.name.StartsWith("RegionPoint")) { Vector3 position = t.position; float height = combatState.MapMetaData.GetLerpedHeightAt(position); Vector3 fixedHeightPosition = new Vector3(position.x, height, position.z); t.position = fixedHeightPosition; meshPoints.Add(t.localPosition); } } // Create new mesh from points and set to collider and mesh filter MeshCollider collider = regionGo.GetComponent <MeshCollider>(); MeshFilter mf = regionGo.GetComponent <MeshFilter>(); Mesh mesh = MeshTools.CreateHexigon(REGION_RADIUS, meshPoints); collider.sharedMesh = mesh; mf.mesh = mesh; List <MapEncounterLayerDataCell> cells = SceneUtils.GetMapEncounterLayerDataCellsWithinCollider(regionGo); for (int i = 0; i < cells.Count; i++) { MapEncounterLayerDataCell cell = cells[i]; cell.AddRegion(regionGameLogic); } }
public static void Postfix(CombatGameState __instance) { Mod.Log.Trace?.Write("CGS:_I entered."); DataManager dm = UnityGameInstance.BattleTechGame.DataManager; LoadRequest loadRequest = dm.CreateLoadRequest(); // Need to load each unique icon Mod.Log.Info?.Write("LOADING EFFECT ICONS..."); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.ElectronicWarfare, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.SensorsDisabled, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.VisionAndSensors, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.TargetSensorsMark, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.TargetVisualsMark, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.TargetTaggedMark, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.TargetNarcedMark, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.TargetStealthMark, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.TargetMimeticMark, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.TargetECMShieldedMark, null); loadRequest.AddLoadRequest <SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.TargetActiveProbePingedMark, null); loadRequest.ProcessRequests(); Mod.Log.Info?.Write(" ICON LOADING COMPLETE!"); ModState.Combat = __instance; }
// Token: 0x0600866D RID: 34413 RVA: 0x0022E4D0 File Offset: 0x0022C6D0 public override bool Invoke(CombatGameState combatGameState) { InvocationMessage.logger.Log("Invoking a MOVE!"); AbstractActor abstractActor = combatGameState.FindActorByGUID(this.ActorGUID); if (abstractActor == null) { InvocationMessage.logger.LogError(string.Format("MechMovement.Invoke Actor with GUID {0} not found!", this.ActorGUID)); return(false); } ICombatant combatant = null; if (!string.IsNullOrEmpty(this.MeleeTargetGUID)) { combatant = combatGameState.FindCombatantByGUID(this.MeleeTargetGUID, false); if (combatant == null) { InvocationMessage.logger.LogError(string.Format("MechMovement.Invoke ICombatant with GUID {0} not found!", this.MeleeTargetGUID)); return(false); } } if (!combatGameState.TurnDirector.IsInterleaved && this.MoveType != MoveType.Sprinting) { abstractActor.AutoBrace = true; } ActorMovementSequence stackSequence = new ActorMovementSequence(abstractActor, this.Waypoints, this.FinalOrientation, this.MoveType, combatant, this.AbilityConsumesFiring); base.PublishStackSequence(combatGameState.MessageCenter, stackSequence, this); return(true); }
// crit engine reduces speed // destroyed engine destroys CT public static bool Prefix(MechComponent __instance, CombatGameState ___combat, WeaponHitInfo hitInfo, ComponentDamageLevel damageLevel, bool applyEffects) { try { if (__instance.mechComponentRef.Is <Flags>(out var f) && f.IsSet("ignore_damage")) { MechCheckForCritPatch.Message = null; return(false); } if (!CirticalHitStatesHandler.Shared.ProcessWeaponHit(__instance, ___combat, hitInfo, damageLevel, applyEffects, MechCheckForCritPatch.MessageAdditions)) { MechCheckForCritPatch.Message = null; return(false); } if (!EngineCrits.ProcessWeaponHit(__instance, hitInfo, damageLevel, applyEffects, MechCheckForCritPatch.MessageAdditions)) { MechCheckForCritPatch.Message = null; return(false); } } catch (Exception e) { Control.mod.Logger.LogError(e); } return(true); }
private static void OnLoadComplete(CombatGameState combat) { Mod.Log.Info?.Write($"== END load request for all possible ambush spawns"); Mod.Log.Info?.Write($" -- Post-load counts => weaponDefs: {combat.DataManager.WeaponDefs.Count} " + $"pilotDefs: {combat.DataManager.PilotDefs.Count} mechDefs: {combat.DataManager.MechDefs.Count}" + $"turretDefs: {combat.DataManager.TurretDefs.Count} vehicleDefs: {combat.DataManager.VehicleDefs.Count}"); }
public override void Trigger(MessageCenterMessage inMessage, string triggeringName) { Main.LogDebug("[PositionRegion] Positioning Region..."); GameObject regionGo = GameObject.Find(RegionName); CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat; Team playerTeam = combatState.LocalPlayerTeam; Vector3 centerOfTeamMass = GetCenterOfTeamMass(playerTeam, true); Vector3 possiblePosition = Vector3.zero; AbstractActor actor = combatState.AllActors.First((AbstractActor x) => x.TeamId == playerTeam.GUID); while (possiblePosition == Vector3.zero || !PathFinderManager.Instance.IsSpawnValid(regionGo, possiblePosition, actor.GameRep.transform.position, UnitType.Mech, $"PositionRegionResult.{RegionName}")) { Main.LogDebug($"[PositionRegion] {(possiblePosition == Vector3.zero ? "Finding possible position..." : "Trying again to find a possible position...")}"); possiblePosition = SceneUtils.GetRandomPositionFromTarget(centerOfTeamMass, Main.Settings.DynamicWithdraw.MinDistanceForZone, Main.Settings.DynamicWithdraw.MaxDistanceForZone); } regionGo.transform.position = possiblePosition; // Debug // GameObjextExtensions.CreateDebugPoint("DEBUGCenterofTeamMassGizmo", centerOfTeamMass, Color.red); // GameObjextExtensions.CreateDebugPoint("DEBUGDynamicWithdrawCenter", regionGo.transform.position, Color.blue); RegionGameLogic regionGameLogic = regionGo.GetComponent <RegionGameLogic>(); regionGameLogic.Regenerate(); }
// Invoke when the player has finished moving all of their units during non-interleaved mode public static void FilterOnTurnActorIncrement(CombatGameState combat) { List <string> guidsToRemove = new List <string>(); foreach (BattleTech.Building building in ModState.CandidateBuildings) { // Remove any that have become objective targets if (building.objectiveGUIDS.Contains(combat.GUID)) { Mod.Log.Debug?.Write($" -- Building is an objective, needs to be removed."); guidsToRemove.Add(building.GUID); } // Remove any that are dead if (building.IsDead || building.IsFlaggedForDeath) { Mod.Log.Debug?.Write($" -- Building is an dead or dying, must be removed."); guidsToRemove.Add(building.GUID); } // Sanity check infantry spawn if (ModState.AmbushBuildingGUIDToTurrets.ContainsKey(building.GUID)) { Mod.Log.Debug?.Write($" -- didn't clean up after myself in infantry ambush, removing trap shell."); guidsToRemove.Add(building.GUID); } } ModState.CandidateBuildings.RemoveAll(x => guidsToRemove.Contains(x.GUID)); Mod.Log.Debug?.Write($"Cleanup - removed {guidsToRemove.Count} buildings."); }
public static void Postfix(ToHit __instance, ref float __result, CombatGameState ___combat, AbstractActor attacker, Weapon weapon, ICombatant target) { try { if (DemandingJumps.Settings.ToHitSelfJumpedSpareAI && !___combat.LocalPlayerTeam.IsActive) { return; } Logger.Info("[ToHit_GetAllModifiers_POSTFIX] CombatGameState.LocalPlayerTeam.IsActive: " + ___combat.LocalPlayerTeam.IsActive); bool AttackerJumpedThisRound = attacker.HasMovedThisRound && attacker.JumpedLastRound; Logger.Info("[ToHit_GetAllModifiers_POSTFIX] Fields.JumpPreview: " + Fields.JumpPreview); Logger.Info("[ToHit_GetAllModifiers_POSTFIX] AttackerJumpedThisRound: " + AttackerJumpedThisRound); if (Fields.JumpPreview || AttackerJumpedThisRound) { int ToHitSelfJumpedModifier = Utilities.GetAttackerJumpedAccuracyModifier(attacker); Logger.Info("[ToHit_GetAllModifiers_POSTFIX] Unit previews jump or already jumped. Applying ToHit penalty."); __result = __result + (float)ToHitSelfJumpedModifier; } } catch (Exception e) { Logger.Error(e); } }
public bool IsObjectSpawnValid(GameObject spawnPoint, Vector3 checkTarget) { CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat; EncounterLayerData encounterLayerData = MissionControl.Instance.EncounterLayerData; Vector3 checkTargetPosition = checkTarget.GetClosestHexLerpedPointOnGrid(); Vector3 spawnPointPosition = GetClosestValidPathFindingHex(spawnPoint, spawnPoint.transform.position, $"IsObjectSpawnInvalid.{spawnPoint.name}", Vector3.zero, 2); Main.LogDebug($"[SpawnLanceLogic.IsObjectSpawnInvalid] Object spawn point's closest hex lerped point on grid for '{spawnPoint.name}' is '{spawnPointPosition}'"); if (!encounterLayerData.IsInEncounterBounds(spawnPointPosition)) { Main.LogDebugWarning("[SpawnLanceLogic.IsObjectSpawnInvalid] Object spawn is outside of the boundary. Select a new object spawn point."); return(false); } if (!PathFinderManager.Instance.IsSpawnValid(spawnPoint, spawnPointPosition, checkTargetPosition, UnitType.Mech, spawnPoint.name)) { Main.LogDebugWarning($"[SpawnLanceLogic.IsObjectSpawnInvalid] Object spawn '{spawnPoint.name}' path to check target '{checkTarget}' is blocked. Select a new object spawn point"); return(false); } spawnPoint.transform.position = spawnPointPosition; return(true); }
public static void Postfix(ToHit __instance, ref string __result, CombatGameState ___combat, AbstractActor attacker, Weapon weapon, ICombatant target) { try { if (DemandingJumps.Settings.ToHitSelfJumpedSpareAI && !___combat.LocalPlayerTeam.IsActive) { return; } Logger.Info("[ToHit_GetAllModifiersDescription_POSTFIX] CombatGameState.LocalPlayerTeam.IsActive: " + ___combat.LocalPlayerTeam.IsActive); bool AttackerJumpedThisRound = attacker.HasMovedThisRound && attacker.JumpedLastRound; Logger.Info("[ToHit_GetAllModifiersDescription_POSTFIX] Fields.JumpPreview: " + Fields.JumpPreview); Logger.Info("[ToHit_GetAllModifiersDescription_POSTFIX] AttackerJumpedThisRound: " + AttackerJumpedThisRound); if (AttackerJumpedThisRound) { int ToHitSelfJumpedModifier = Utilities.GetAttackerJumpedAccuracyModifier(attacker); Logger.Debug("[ToHit_GetAllModifiersDescription_POSTFIX] Add description for ToHitSelfJumped: " + ToHitSelfJumpedModifier); __result = string.Format("{0}JUMPED {1:+#;-#}; ", __result, ToHitSelfJumpedModifier); } } catch (Exception e) { Logger.Error(e); } }
private VisibilityCacheGate() : base(null, null) { shouldTakeaction = () => counter == 0; actionToTake = () => { CombatGameState combatGameState = UnityGameInstance.BattleTechGame.Combat; List <ICombatant> combatants = combatGameState.GetAllLivingCombatants(); foreach (AbstractActor actor in selfCacheActors.ToList()) { if (biCacheActors.Contains(actor)) { selfCacheActors.Remove(actor); } } foreach (AbstractActor actor in selfCacheActors) { actor.RebuildVisibilityCache(combatants); } foreach (AbstractActor actor in biCacheActors) { actor.UpdateVisibilityCache(combatants); } selfCacheActors.Clear(); biCacheActors.Clear(); }; }
public static bool Prefix(CombatGameState __instance) { RepairHelper.Clear(); HashSet <string> clearComponents = new HashSet <string>(); foreach (var avfx in ComponentVFXHelper.componentsVFXObjects) { clearComponents.Add(avfx.Key); } foreach (var compGUID in clearComponents) { if (ComponentVFXHelper.componentsVFXObjects.ContainsKey(compGUID)) { ComponentVFXHelper.componentsVFXObjects[compGUID].Clean(); } } ComponentVFXHelper.componentsVFXObjects.Clear(); CAEAuraHelper.ClearBubbles(); CombatHUDWeaponPanelExHelper.Clear(); CombatHUDEquipmentPanel.Clear(); ActivatableComponent.Clear(); CombatHUDEquipmentSlotEx.Clear(); CombatHUDEquipmentPanel.Clear(); //DamageHelpers.DamageHelper.Clear(); return(true); }
private Mech CreatePathFinderMech() { GameInstance game = UnityGameInstance.BattleTechGame; CombatGameState combatState = game.Combat; string spawnerId = Guid.NewGuid().ToString(); string uniqueId = $"{spawnerId}.9999999999"; HeraldryDef heraldryDef = null; combatState.DataManager.Heraldries.TryGet(HeraldryDef.HeraldyrDef_SinglePlayerSkirmishPlayer1, out heraldryDef); MechDef mechDef = null; combatState.DataManager.MechDefs.TryGet("mechdef_spider_SDR-5V", out mechDef); PilotDef pilotDef = null; combatState.DataManager.PilotDefs.TryGet("pilot_default", out pilotDef); Mech mech = new Mech(mechDef, pilotDef, new TagSet(), uniqueId, combatState, spawnerId, heraldryDef); string teamId = TeamUtils.GetTeamGuid("NeutralToAll"); Team team = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(teamId); AccessTools.Field(typeof(AbstractActor), "_team").SetValue(mech, team); AccessTools.Field(typeof(AbstractActor), "_teamId").SetValue(mech, teamId); return(mech); }
public static void ProtectOnFirstRound() { Mod.Log.Info($"Protecting units on first turn'"); CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat; HostilityMatrix hm = combatState.HostilityMatrix; Team playerTeam = combatState.LocalPlayerTeam; // Includes player units List <AbstractActor> actors = new List <AbstractActor>(); foreach (AbstractActor actor in combatState.AllActors) { if (hm.IsLocalPlayerEnemy(actor.TeamId) && Mod.Config.Combat.SpawnProtection.ApplyToEnemies) { actors.Add(actor); } else if (hm.IsLocalPlayerNeutral(actor.TeamId) && Mod.Config.Combat.SpawnProtection.ApplyToNeutrals) { actors.Add(actor); } else if (hm.IsLocalPlayerFriendly(actor.TeamId) && Mod.Config.Combat.SpawnProtection.ApplyToAllies) { actors.Add(actor); } } actors.AddRange(playerTeam.units); List <AbstractActor> actorsToProtect = actors.Distinct().ToList(); ProtectActors(actorsToProtect); }
private Vehicle CreatePathFindingVehicle() { GameInstance game = UnityGameInstance.BattleTechGame; CombatGameState combatState = game.Combat; string spawnerId = Guid.NewGuid().ToString(); string uniqueId = $"{spawnerId}.9999999998"; HeraldryDef heraldryDef = null; combatState.DataManager.Heraldries.TryGet(HeraldryDef.HeraldyrDef_SinglePlayerSkirmishPlayer1, out heraldryDef); VehicleDef vehicleDef = null; combatState.DataManager.VehicleDefs.TryGet("vehicledef_DEMOLISHER", out vehicleDef); PilotDef pilotDef = null; combatState.DataManager.PilotDefs.TryGet("pilot_default", out pilotDef); Vehicle vehicle = new Vehicle(vehicleDef, pilotDef, new TagSet(), uniqueId, combatState, spawnerId, heraldryDef); string teamId = TeamUtils.GetTeamGuid("NeutralToAll"); Team team = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(teamId); AccessTools.Field(typeof(AbstractActor), "_team").SetValue(vehicle, team); AccessTools.Field(typeof(AbstractActor), "_teamId").SetValue(vehicle, teamId); return(vehicle); }
void Start() { this.combatState = new CombatGameState(this); this.menuState = new MenuGameState(this); this.SetCombatState(); }
public static void Postfix(MechJumpSequence __instance) { try { //if (__instance.owningActor.team.IsLocalPlayer) if (__instance.owningActor.team.LocalPlayerControlsTeam) { return; } Logger.Debug($"[MechJumpSequence_OnAdded_POSTFIX] Focus on enemy jumping..."); CombatGameState ___combatGameState = (CombatGameState)AccessTools.Property(typeof(MechJumpSequence), "Combat").GetValue(__instance, null); if (___combatGameState.LocalPlayerTeam.CanDetectPosition(__instance.OwningMech.CurrentPosition, __instance.OwningMech)) { CameraControl.Instance.SetMovingToGroundPos(__instance.OwningMech.CurrentPosition, 0.95f); } else if (___combatGameState.LocalPlayerTeam.CanDetectPosition(__instance.FinalPos, __instance.OwningMech)) { CameraControl.Instance.SetMovingToGroundPos(__instance.FinalPos, 0.95f); } else { // Nothing? } } catch (Exception e) { Logger.Error(e); } }
public void InitSceneData() { CombatGameState combat = UnityGameInstance.BattleTechGame.Combat; if (!EncounterLayerParentGameObject) { EncounterLayerParentGameObject = GameObject.Find("EncounterLayerParent"); } EncounterLayerParent = EncounterLayerParentGameObject.GetComponent <EncounterLayerParent>(); EncounterLayerData = GetActiveEncounter(); if (EncounterLayerData == null) // If no EncounterLayer matches the Contract Type GUID, it's a custom contract type { EncounterLayerData = ConstructCustomContractType(); IsCustomContractType = true; } else { IsCustomContractType = false; } EncounterLayerGameObject = EncounterLayerData.gameObject; EncounterLayerData.CalculateEncounterBoundary(); if (HexGrid == null) { HexGrid = ReflectionHelper.GetPrivateStaticField(typeof(WorldPointGameLogic), "_hexGrid") as HexGrid; } }
public static void Postfix(AttackStackSequence __instance, MessageCenterMessage message) { try { Logger.Debug($"[AttackStackSequence_OnAttackBegin_POSTFIX] Focus on attacked target..."); CombatGameState ___combatGameState = (CombatGameState)AccessTools.Property(typeof(AttackStackSequence), "Combat").GetValue(__instance, null); AttackSequenceBeginMessage attackSequenceBeginMessage = message as AttackSequenceBeginMessage; AttackDirector.AttackSequence attackSequence = ___combatGameState.AttackDirector.GetAttackSequence(attackSequenceBeginMessage.sequenceId); bool isChosenTargetFriendly = attackSequence.chosenTarget.team.GUID == ___combatGameState.LocalPlayerTeamGuid || ___combatGameState.HostilityMatrix.IsLocalPlayerFriendly(attackSequence.chosenTarget.team.GUID); bool shouldFocus = (CameraUnchained.Settings.FocusOnTargetedFriendly && isChosenTargetFriendly) || (CameraUnchained.Settings.FocusOnTargetedEnemy && !isChosenTargetFriendly); Logger.Info($"[AttackStackSequence_OnAttackBegin_POSTFIX] isChosenTargetFriendly: {isChosenTargetFriendly}, shouldFocus: {shouldFocus}"); if (attackSequence == null || !shouldFocus) { return; } if (attackSequence.stackItemUID == __instance.SequenceGUID && !__instance.hasOwningSequence) { CameraControl.Instance.SetMovingToGroundPos(attackSequence.chosenTarget.CurrentPosition, 0.95f); } } catch (Exception e) { Logger.Error(e); } }
public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState, ref bool __result) { if (Core.Settings.StartupByHeatControl == false) { return(true); } try { __result = true; Mech actorByGuid = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech; if (actorByGuid == null) { Log.LogWrite("MechStartupInvocation.Invoke failed! Unable to Mech!\n"); return(true); } if (actorByGuid.CurrentHeatAsRatio >= Core.Settings.StartupMinHeatRatio) { combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new FloatieMessage(__instance.MechGUID, __instance.MechGUID, "__/CAE.ReactroTooHot/__", FloatieMessage.MessageNature.Buff)); combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new AddSequenceToStackMessage(actorByGuid.DoneNoAnimation())); } else { return(true); } return(false); } catch (Exception e) { Log.LogWrite(e.ToString() + "\n"); } return(true); }
public static void Postfix(CombatHUDRetreatEscMenu __instance, CombatGameState ___Combat, CombatHUD ___HUD) { Mod.Log.Trace?.Write($"CHUDREM:INIT - entered"); ModState.HUD = ___HUD; ModState.Combat = ___Combat; ModState.RetreatButton = __instance.RetreatButton; if (__instance.RetreatButton.gameObject.activeSelf) { Mod.Log.Info?.Write(" We are in not a priority contract or skirmish, enabling withdrawal."); ModState.WithdrawIsAvailable = true; Transform textT = __instance.RetreatButton.gameObject.transform.Find("Text"); if (textT != null) { GameObject textGO = textT.gameObject; ModState.RetreatButtonText = textGO.GetComponent <TextMeshProUGUI>(); } else { Mod.Log.Error?.Write("Failed to find text component, cannot proceed! Disabling withdrawal logic."); ModState.WithdrawIsAvailable = false; } } else { Mod.Log.Info?.Write(" We are in a priority contract or skirmish, preventing withdrawal."); ModState.WithdrawIsAvailable = true; } }
public static void Reset() { // Reinitialize state CandidateBuildings.Clear(); LoadedResources.Clear(); TargetTeam = null; TargetAllyTeam = null; HostileToAllTeam = null; AmbushBuildingGUIDToTurrets.Clear(); AmbushTurretGUIDtoBuilding.Clear(); CurrentTurretForLOF = null; CurrentTurretForLOS = null; KillingLinkedUnitsSource = null; Ambushes = 0; AmbushOrigins.Clear(); PotentialAmbushOrigins.Clear(); CurrentAmbushChance = Mod.Config.Ambush.BaseChance; CurrentSpawningLance = null; Combat = null; IsUrbanBiome = false; ContractDifficulty = 0; ExplosionAmbushDefForContract = null; InfantryAmbushDefForContract = null; BattleArmorAmbushDefForContract = null; MechAmbushDefForContract = null; VehicleAmbushDefForContract = null; }
public CustomDialogSequence(CombatGameState Combat, CombatHUDDialogSideStack sideStack, bool isCancelable = true) : base(Combat) { this.isCancelable = isCancelable; this.sideStack = sideStack; this.state = DialogState.None; }