public static bool ResolvePilotInjuryCheck(Mech mech, int heatToCheck, int rootSequenceGUID, int sequenceGUID, float heatCheck) { bool failedInjuryCheck = !CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.PilotInjury, heatToCheck, mech, heatCheck, ModText.FT_Check_Injury); Mod.Log.Debug?.Write($" failedInjuryCheck: {failedInjuryCheck}"); if (failedInjuryCheck) { Mod.Log.Info?.Write($"-- Pilot Heat Injury check failed for {CombatantUtils.Label(mech)}, forcing injury from heat"); mech.pilot.InjurePilot(sequenceGUID.ToString(), rootSequenceGUID, 1, DamageType.OverheatSelf, null, mech); if (!mech.pilot.IsIncapacitated) { AudioEventManager.SetPilotVOSwitch <AudioSwitch_dialog_dark_light>(AudioSwitch_dialog_dark_light.dark, mech); AudioEventManager.PlayPilotVO(VOEvents.Pilot_TakeDamage, mech, null, null, true); if (mech.team.LocalPlayerControlsTeam) { AudioEventManager.PlayAudioEvent("audioeventdef_musictriggers_combat", "friendly_warrior_injured", null, null); } } else { mech.FlagForDeath("Pilot Killed", DeathMethod.PilotKilled, DamageType.OverheatSelf, 1, sequenceGUID, "0", false); string localText = new Text(Mod.LocalizedText.Floaties[ModText.FT_Death_By_Overheat]).ToString(); mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage( new ShowActorInfoSequence(mech, new Text(localText, Array.Empty <object>()), FloatieMessage.MessageNature.PilotInjury, true)) ); mech.HandleDeath("0"); } } return(failedInjuryCheck); }
public static void PlayVFX(AIMCritInfo info) { try { ICombatant target = info.target; if (target.GameRep == null) { return; } MechComponent component = info.component; bool isAmmo = component is AmmunitionBox, isJumpJet = component is Jumpjet, isHeatSink = component.componentDef is HeatSinkDef; if (target.team.LocalPlayerControlsTeam) { AudioEventManager.PlayAudioEvent("audioeventdef_musictriggers_combat", "critical_hit_friendly ", null, null); } else if (!target.team.IsFriendly(Combat.LocalPlayerTeam)) { AudioEventManager.PlayAudioEvent("audioeventdef_musictriggers_combat", "critical_hit_enemy", null, null); } if (target.GameRep is MechRepresentation MechRep && !isJumpJet && !isHeatSink && !isAmmo && component.DamageLevel > ComponentDamageLevel.Functional) { MechRep.PlayComponentCritVFX(info.GetCritLocation()); } if (isAmmo && component.DamageLevel > ComponentDamageLevel.Functional) { target.GameRep.PlayVFX(info.GetCritLocation(), Combat.Constants.VFXNames.componentDestruction_AmmoExplosion, true, Vector3.zero, true, -1f); } } catch (Exception ex) { Error(ex); } }
private static void PlayInjuryMusic(this Pilot pilot) { AudioEventManager.PlayAudioEvent( AudioConstantsDef.MUSICTRIGGERS_COMBAT, pilot.ParentActor.team.LocalPlayerControlsTeam ? nameof(AudioTriggerList.friendly_warrior_injured) : nameof(AudioTriggerList.enemy_warrior_injured) ); }
public static bool Prefix(string defId, string eventId, AkGameObj audioObject, AkCallbackManager.EventCallback audioEventCallback, ref bool __result) { // play everything except contract_lanceconfirm because you can't launch a mission without it if (modSettings.EnableBarks || defId != "audioeventdef_simgame_vo_barks") { return(true); } if (eventId == "contract_lanceconfirm" || eventId == "skirmish_lanceconfirm") { __result = AudioEventManager.PlayAudioEvent(AudioEventManager.GetAudioEvent(defId, eventId), audioObject, audioEventCallback); } return(false); }
public static void ReadyMech(SimGameState s, MechDef d, int baySlot) { WorkOrderEntry_ReadyMech workOrderEntry_ReadyMech = new WorkOrderEntry_ReadyMech(string.Format("ReadyMech-{0}", d.GUID), string.Format("Readying 'Mech - {0}", new object[] { d.Chassis.Description.Name }), s.Constants.Story.MechReadyTime, baySlot, d, string.Format(s.Constants.Story.MechReadiedWorkOrderCompletedText, new object[] { d.Chassis.Description.Name })); s.MechLabQueue.Add(workOrderEntry_ReadyMech); s.ReadyingMechs[baySlot] = d; s.RoomManager.AddWorkQueueEntry(workOrderEntry_ReadyMech); s.UpdateMechLabWorkQueue(false); AudioEventManager.PlayAudioEvent("audioeventdef_simgame_vo_barks", "workqueue_readymech", WwiseManager.GlobalAudioObject, null); }
public override void OnAdded() { base.OnAdded(); if (this.OwningMech.GameRep != null) { string text = string.Format("MechOverheatSequence_{0}_{1}", base.RootSequenceGUID, base.SequenceGUID); AudioEventManager.CreateVOQueue(text, -1f, null, null); AudioEventManager.QueueVOEvent(text, VOEvents.Mech_Overheat_Shutdown, this.OwningMech); AudioEventManager.StartVOQueue(1f); this.OwningMech.GameRep.PlayVFX(1, this.OwningMech.Combat.Constants.VFXNames.heat_heatShutdown, true, Vector3.zero, false, -1f); this.AddChildSequence(new ShowActorInfoSequence(this.OwningMech, "Emergency Shutdown Initiated!", FloatieMessage.MessageNature.Debuff, true), this.ChildSequenceCount - 1); WwiseManager.PostEvent <AudioEventList_ui>(AudioEventList_ui.ui_overheat_alarm_3, WwiseManager.GlobalAudioObject, null, null); if (this.OwningMech.team.LocalPlayerControlsTeam) { AudioEventManager.PlayAudioEvent("audioeventdef_musictriggers_combat", "friendly_overheating", null, null); } } }
public static void ReadyMech(SimGameState s, MechDef d, int baySlot, bool donotoverridetime = false) { int mechReadyTime = s.Constants.Story.MechReadyTime; if (Settings.AssembledMechsReadyingFlatCost > 0 && !donotoverridetime) { mechReadyTime = Settings.AssembledMechsReadyingFlatCost + Settings.AssembledMechsReadyingPerNonFixedComponentCost * d.Inventory.Where((a) => !a.IsFixed).Count(); } WorkOrderEntry_ReadyMech workOrderEntry_ReadyMech = new WorkOrderEntry_ReadyMech(string.Format("ReadyMech-{0}", d.GUID), $"Readying {d.GetMechOmniVehicle()} - {d.Chassis.Description.Name}", mechReadyTime, baySlot, d, string.Format(s.Constants.Story.MechReadiedWorkOrderCompletedText, new object[] { d.Chassis.Description.Name })); s.MechLabQueue.Add(workOrderEntry_ReadyMech); s.ReadyingMechs[baySlot] = d; s.RoomManager.AddWorkQueueEntry(workOrderEntry_ReadyMech); s.UpdateMechLabWorkQueue(false); AudioEventManager.PlayAudioEvent("audioeventdef_simgame_vo_barks", "workqueue_readymech", WwiseManager.GlobalAudioObject, null); s.CompanyStats.ModifyStat("Mission", 0, "COMPANY_MechsAdded", StatCollection.StatOperation.Int_Add, 1, -1, true); }
// Prevent the debuff floatie public override void OnAdded() { base.OnAdded(); if (this.OwningMech.GameRep != null) { Mod.Log.Info?.Write("Sending floatie notification."); string text = string.Format("MechOverheatSequence_{0}_{1}", base.RootSequenceGUID, base.SequenceGUID); AudioEventManager.CreateVOQueue(text, -1f, null, null); AudioEventManager.QueueVOEvent(text, VOEvents.Mech_Overheat_Shutdown, this.OwningMech); AudioEventManager.StartVOQueue(1f); this.OwningMech.GameRep.PlayVFX(8, this.OwningMech.Combat.Constants.VFXNames.heat_heatShutdown, true, Vector3.zero, false, -1f); WwiseManager.PostEvent <AudioEventList_ui>(AudioEventList_ui.ui_overheat_alarm_3, WwiseManager.GlobalAudioObject, null, null); if (this.OwningMech.team.LocalPlayerControlsTeam) { AudioEventManager.PlayAudioEvent("audioeventdef_musictriggers_combat", "friendly_overheating", null, null); } } }
private static void AddBullsharkLT(SimGameState s) { MechDef d = s.DataManager.MechDefs.Get("mechdef_bullshark_BSK-LT"); d = new MechDef(d, s.GenerateSimGameUID(), true); d.SetInventory(d.Inventory.Where((x) => x.IsFixed || x.ComponentDefID.Equals("Ammo_AmmunitionBox_Generic_LongTom")).ToArray()); int baySlot = s.GetFirstFreeMechBay(); int mechReadyTime = 625000; // about 50 days WorkOrderEntry_ReadyMech workOrderEntry_ReadyMech = new WorkOrderEntry_ReadyMech(string.Format("ReadyMech-{0}", d.GUID), string.Format("Readying 'Mech - {0}", new object[] { d.Chassis.Description.Name }), mechReadyTime, baySlot, d, string.Format(s.Constants.Story.MechReadiedWorkOrderCompletedText, new object[] { d.Chassis.Description.Name })); s.MechLabQueue.Add(workOrderEntry_ReadyMech); s.ReadyingMechs[baySlot] = d; s.RoomManager.AddWorkQueueEntry(workOrderEntry_ReadyMech); s.UpdateMechLabWorkQueue(false); AudioEventManager.PlayAudioEvent("audioeventdef_simgame_vo_barks", "workqueue_readymech", WwiseManager.GlobalAudioObject, null); }
public static bool Prefix(MechHeatSequence __instance, HeatSequenceState newState) { if (newState != HeatSequenceState.Finished) { return(true); } Traverse stateT = Traverse.Create(__instance).Field("state"); HeatSequenceState currentState = (HeatSequenceState)stateT.GetValue <int>(); if (currentState == newState) { return(true); } Mod.Log.Info($"MHS - executing updated logic for state: {newState} on actor:{__instance.OwningMech.DisplayName}_{__instance.OwningMech.GetPilot().Name}."); stateT.SetValue((int)newState); Traverse timeInCurrentStateT = Traverse.Create(__instance).Field("timeInCurrentState"); timeInCurrentStateT.SetValue(0f); /* Finished Can be invoked from a rising state (heat being added): * Attack Sequence, artillery sequence, actor burning effect, (heatSinkStep=false, applyStartupHeatSinks=false) * On End of turn sequence - (heatSinkStep=true, applyStartupHeatSinks=false) * On Mech Startup sequence - (heatSinkStep=true, applyStartupHeatSinks=true) */ if (!__instance.PerformHeatSinkStep) { Mod.Log.Debug($"Reconciling heat for actor: {CombatantUtils.Label(__instance.OwningMech)}"); Mod.Log.Debug($" Before - currentHeat: {__instance.OwningMech.CurrentHeat} tempHeat: {__instance.OwningMech.TempHeat} " + $"isPastMaxHeat: {__instance.OwningMech.IsPastMaxHeat} hasAppliedHeatSinks: {__instance.OwningMech.HasAppliedHeatSinks}"); // Checks for heat damage, clamps heat to max and min __instance.OwningMech.ReconcileHeat(__instance.RootSequenceGUID, __instance.InstigatorID); Mod.Log.Debug($" After - currentHeat: {__instance.OwningMech.CurrentHeat} tempHeat: {__instance.OwningMech.TempHeat} " + $"isPastMaxHeat: {__instance.OwningMech.IsPastMaxHeat} hasAppliedHeatSinks: {__instance.OwningMech.HasAppliedHeatSinks}"); } //if (__instance.OwningMech.IsPastMaxHeat && !__instance.OwningMech.IsShutDown) { // __instance.OwningMech.GenerateOverheatedSequence(__instance); // return; //} if (__instance.PerformHeatSinkStep && !__instance.ApplyStartupHeatSinks) { // We are at the end of the turn - force an overheat Mod.Log.Info("AT END OF TURN - CHECKING EFFECTS"); MultiSequence sequence = new MultiSequence(__instance.OwningMech.Combat); // Possible sequences // Shutdown // Fall from shutdown // Ammo Explosion // System damage // Pilot injury // Pilot death float heatCheck = __instance.OwningMech.HeatCheckMod(Mod.Config.Piloting.SkillMulti); float pilotCheck = __instance.OwningMech.PilotCheckMod(Mod.Config.Piloting.SkillMulti); Mod.Log.Debug($" Actor: {CombatantUtils.Label(__instance.OwningMech)} has gutsMulti: {heatCheck} pilotingMulti: {pilotCheck}"); // Resolve Pilot Injury bool failedInjuryCheck = !CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.PilotInjury, __instance.OwningMech.CurrentHeat, __instance.OwningMech, heatCheck, ModConfig.FT_Check_Injury); Mod.Log.Debug($" failedInjuryCheck: {failedInjuryCheck}"); if (failedInjuryCheck) { Mod.Log.Debug("-- Pilot Injury check failed, forcing injury from heat"); __instance.OwningMech.pilot.InjurePilot(__instance.SequenceGUID.ToString(), __instance.RootSequenceGUID, 1, DamageType.OverheatSelf, null, __instance.OwningMech); if (!__instance.OwningMech.pilot.IsIncapacitated) { AudioEventManager.SetPilotVOSwitch <AudioSwitch_dialog_dark_light>(AudioSwitch_dialog_dark_light.dark, __instance.OwningMech); AudioEventManager.PlayPilotVO(VOEvents.Pilot_TakeDamage, __instance.OwningMech, null, null, true); if (__instance.OwningMech.team.LocalPlayerControlsTeam) { AudioEventManager.PlayAudioEvent("audioeventdef_musictriggers_combat", "friendly_warrior_injured", null, null); } } } // Resolve System Damage bool failedSystemFailureCheck = !CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.SystemFailures, __instance.OwningMech.CurrentHeat, __instance.OwningMech, heatCheck, ModConfig.FT_Check_System_Failure); Mod.Log.Debug($" failedSystemFailureCheck: {failedSystemFailureCheck}"); if (failedSystemFailureCheck) { Mod.Log.Debug("-- System Failure check failed, forcing system damage"); List <MechComponent> functionalComponents = __instance.OwningMech.allComponents.Where(mc => mc.IsFunctional).ToList(); MechComponent componentToDamage = functionalComponents.GetRandomElement(); Mod.Log.Debug($" Destroying component: {componentToDamage.UIName} from heat damage."); WeaponHitInfo fakeHit = new WeaponHitInfo(__instance.RootSequenceGUID, -1, -1, -1, string.Empty, string.Empty, -1, null, null, null, null, null, null, null, new AttackDirection[] { AttackDirection.None }, null, null, null); componentToDamage.DamageComponent(fakeHit, ComponentDamageLevel.Destroyed, true); } // Resolve Ammo Explosion - regular ammo bool failedAmmoCheck = false; AmmunitionBox mostDamaging = HeatHelper.FindMostDamagingAmmoBox(__instance.OwningMech, false); if (mostDamaging != null) { failedAmmoCheck = !CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.Explosion, __instance.OwningMech.CurrentHeat, __instance.OwningMech, heatCheck, ModConfig.FT_Check_Explosion); Mod.Log.Debug($" failedAmmoCheck: {failedAmmoCheck}"); if (failedAmmoCheck) { Mod.Log.Debug("-- Ammo Explosion check failed, forcing ammo explosion"); if (mostDamaging != null) { Mod.Log.Debug($" Exploding ammo: {mostDamaging.UIName}"); WeaponHitInfo fakeHit = new WeaponHitInfo(__instance.RootSequenceGUID, -1, -1, -1, string.Empty, string.Empty, -1, null, null, null, null, null, null, null, new AttackDirection[] { AttackDirection.None }, null, null, null); mostDamaging.DamageComponent(fakeHit, ComponentDamageLevel.Destroyed, true); } else { Mod.Log.Debug(" Unit has no ammo boxes, skipping."); } } } // Resolve Ammo Explosion - inferno ammo bool failedVolatileAmmoCheck = false; AmmunitionBox mostDamagingVolatile = HeatHelper.FindMostDamagingAmmoBox(__instance.OwningMech, true); if (mostDamagingVolatile != null) { failedVolatileAmmoCheck = !CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.Explosion, __instance.OwningMech.CurrentHeat, __instance.OwningMech, heatCheck, ModConfig.FT_Check_Explosion); Mod.Log.Debug($" failedVolatileAmmoCheck: {failedVolatileAmmoCheck}"); if (failedVolatileAmmoCheck) { Mod.Log.Debug("-- Volatile Ammo Explosion check failed, forcing volatile ammo explosion"); if (mostDamaging != null) { Mod.Log.Debug($" Exploding inferno ammo: {mostDamagingVolatile.UIName}"); WeaponHitInfo fakeHit = new WeaponHitInfo(__instance.RootSequenceGUID, -1, -1, -1, string.Empty, string.Empty, -1, null, null, null, null, null, null, null, new AttackDirection[] { AttackDirection.None }, null, null, null); mostDamagingVolatile.DamageComponent(fakeHit, ComponentDamageLevel.Destroyed, true); } else { Mod.Log.Debug(" Unit has no inferno ammo boxes, skipping."); } } } bool failedShutdownCheck = false; if (!__instance.OwningMech.IsShutDown) { // Resolve Shutdown + Fall failedShutdownCheck = !CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.Shutdown, __instance.OwningMech.CurrentHeat, __instance.OwningMech, heatCheck, ModConfig.FT_Check_Shutdown); Mod.Log.Debug($" failedShutdownCheck: {failedShutdownCheck}"); if (failedShutdownCheck) { Mod.Log.Debug("-- Shutdown check failed, forcing unit to shutdown"); string debuffText = new Text(Mod.Config.LocalizedFloaties[ModConfig.FT_Shutdown_Failed_Overide]).ToString(); sequence.AddChildSequence(new ShowActorInfoSequence(__instance.OwningMech, debuffText, FloatieMessage.MessageNature.Debuff, true), sequence.ChildSequenceCount - 1); MechEmergencyShutdownSequence mechShutdownSequence = new MechEmergencyShutdownSequence(__instance.OwningMech) { RootSequenceGUID = __instance.SequenceGUID }; sequence.AddChildSequence(mechShutdownSequence, sequence.ChildSequenceCount - 1); if (__instance.OwningMech.IsOrWillBeProne) { bool failedFallingCheck = !CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.ShutdownFallThreshold, __instance.OwningMech, pilotCheck, ModConfig.FT_Check_Fall); Mod.Log.Debug($" failedFallingCheck: {failedFallingCheck}"); if (failedFallingCheck) { Mod.Log.Info("Pilot check from shutdown failed! Forcing a fall!"); string fallDebuffText = new Text(Mod.Config.LocalizedFloaties[ModConfig.FT_Shutdown_Fall]).ToString(); sequence.AddChildSequence(new ShowActorInfoSequence(__instance.OwningMech, fallDebuffText, FloatieMessage.MessageNature.Debuff, true), sequence.ChildSequenceCount - 1); MechFallSequence mfs = new MechFallSequence(__instance.OwningMech, "Overheat", new Vector2(0f, -1f)) { RootSequenceGUID = __instance.SequenceGUID }; sequence.AddChildSequence(mfs, sequence.ChildSequenceCount - 1); } else { Mod.Log.Info($"Pilot check to avoid falling passed."); } } else { Mod.Log.Debug("Unit is already prone, skipping."); } } } else { Mod.Log.Debug("Unit is already shutdown, skipping."); } if (failedInjuryCheck || failedSystemFailureCheck || failedAmmoCheck || failedShutdownCheck) { __instance.OwningMech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(sequence)); } return(false); } if (__instance.OwningMech.GameRep != null) { if (__instance.OwningMech.team.LocalPlayerControlsTeam) { if (__instance.OwningMech.CurrentHeat > __instance.OwningMech.OverheatLevel) { string text = string.Format("MechHeatSequence_{0}_{1}", __instance.RootSequenceGUID, __instance.SequenceGUID); AudioEventManager.CreateVOQueue(text, -1f, null, null); AudioEventManager.QueueVOEvent(text, VOEvents.Mech_Overheat_Warning, __instance.OwningMech); AudioEventManager.StartVOQueue(1f); } if ((float)__instance.OwningMech.CurrentHeat > (float)__instance.OwningMech.MaxHeat - (float)(__instance.OwningMech.MaxHeat - __instance.OwningMech.OverheatLevel) * 0.333f) { WwiseManager.PostEvent <AudioEventList_ui>(AudioEventList_ui.ui_overheat_alarm_3, WwiseManager.GlobalAudioObject, null, null); } else if ((float)__instance.OwningMech.CurrentHeat > (float)__instance.OwningMech.MaxHeat - (float)(__instance.OwningMech.MaxHeat - __instance.OwningMech.OverheatLevel) * 0.666f) { WwiseManager.PostEvent <AudioEventList_ui>(AudioEventList_ui.ui_overheat_alarm_2, WwiseManager.GlobalAudioObject, null, null); } else if (__instance.OwningMech.CurrentHeat > __instance.OwningMech.OverheatLevel) { WwiseManager.PostEvent <AudioEventList_ui>(AudioEventList_ui.ui_overheat_alarm_1, WwiseManager.GlobalAudioObject, null, null); } } if (__instance.OwningMech.CurrentHeat > Mod.Config.Heat.ShowLowOverheatAnim) { __instance.OwningMech.GameRep.StopManualPersistentVFX(__instance.OwningMech.Combat.Constants.VFXNames.heat_midHeat_persistent); __instance.OwningMech.GameRep.PlayVFX(8, __instance.OwningMech.Combat.Constants.VFXNames.heat_highHeat_persistent, true, Vector3.zero, false, -1f); return(false); } if ((float)__instance.OwningMech.CurrentHeat > Mod.Config.Heat.ShowExtremeOverheatAnim) { __instance.OwningMech.GameRep.StopManualPersistentVFX(__instance.OwningMech.Combat.Constants.VFXNames.heat_highHeat_persistent); __instance.OwningMech.GameRep.PlayVFX(8, __instance.OwningMech.Combat.Constants.VFXNames.heat_midHeat_persistent, true, Vector3.zero, false, -1f); return(false); } __instance.OwningMech.GameRep.StopManualPersistentVFX(__instance.OwningMech.Combat.Constants.VFXNames.heat_highHeat_persistent); __instance.OwningMech.GameRep.StopManualPersistentVFX(__instance.OwningMech.Combat.Constants.VFXNames.heat_midHeat_persistent); } return(false); }
private static void OnBuyItem(int num) { var selected = ShopHelper.selectedController; var shop_def = selected.shopDefItem; Control.LogDebug(DInfo.ShopActions, $"-- {num}x{shop_def.ID}"); if (selected == null) { Control.LogError("OnBuyItem null item, cancel"); return; } var id = selected.GetId(); if (!shop_def.IsInfinite && num > selected.quantity) { Control.LogDebug(DInfo.ShopActions, $"--- {num} > {selected.quantity}, adjucting"); num = selected.quantity; } if (BuyItem(shop_def, num)) { Control.LogDebug(DInfo.ShopActions, $"--- refresh shop"); if (!shop_def.IsInfinite) { if (num < selected.quantity) { Control.LogDebug(DInfo.ShopActions, $"---- {num} < {selected.quantity} - reducing"); selected.ModifyQuantity(-num); } else { Control.LogDebug(DInfo.ShopActions, $"--- {num} >= {selected.quantity} - removing"); selected.quantity = 1; ShopHelper.inventoryWidget.RemoveDataItem(selected); selected.Pool(); ShopHelper.selectedController = null; } } Control.LogDebug(DInfo.ShopActions, $"--- PlayVO"); if (ShopHelper.canPlayVO) { ShopHelper.canPlayVO = false; ShopItemType type = shop_def.Type; string text; if (type != ShopItemType.Weapon) { if (type == ShopItemType.Mech) { text = "store_newmechs"; } else { text = "store_newequipment"; } } else { text = "store_newweapons"; } if (!string.IsNullOrEmpty(text)) { AudioEventManager.PlayAudioEvent("audioeventdef_simgame_vo_barks", text, WwiseManager.GlobalAudioObject, null); } ShopScreen.StartCoroutine(PurchaseVOCooldown(5f)); } } ShopHelper.inventoryWidget.RefreshInventoryList(); ShopScreen.UpdateMoneySpot(); ShopScreen.RefreshAllMoneyListings(); if (shop_def.Type == ShopItemType.MechPart) { ShopScreen.OnItemSelected(ShopHelper.inventoryWidget.GetSelectedViewItem()); } ShopHelper.triggerIronManAutoSave = true; }
public static bool ReadyVehicle(MechBayPanel __instance, MechBayChassisUnitElement chassisElement, ref MechBayChassisUnitElement ___selectedChassis, MechBayRowGroupWidget ___bayGroupWidget) { try { var chassisDef = chassisElement.ChassisDef; if (!chassisDef.IsVehicle()) { return(true); } var id = chassisElement.ChassisDef.Description.Id; var sim = __instance.Sim; int start = sim.VehicleShift(); int end = start + sim.GetMaxActiveMechs(); int baySlot = -1; for (int i = start; i < end; i++) { MechDef mech_in_slot = null; if (!sim.ActiveMechs.TryGetValue(i, out mech_in_slot)) { sim.ReadyingMechs.TryGetValue(i, out mech_in_slot); } if (mech_in_slot == null) { baySlot = i; break; } } if (baySlot < 0) { Control.Instance.LogDebug(DInfo.General, "No Free vehicle slots for {0}", id); return(false); } var mid = ChassisHandler.GetMDefFromCDef(id); var sim_id = sim.GenerateSimGameUID(); var stock = __instance.DataManager.MechDefs.Get(mid); var mech = new MechDef(chassisDef, sim_id, stock); mech.SetInventory(stock.Inventory); WorkOrderEntry_ReadyMech workOrderEntry_ReadyMech = new WorkOrderEntry_ReadyMech( string.Format("ReadyMech-{0}", sim_id), Strings.T("Readying 'Mech - {0}", new object[] { chassisDef.Description.Name }), sim.Constants.Story.MechReadyTime, baySlot, mech, Strings.T( sim.Constants.Story.MechReadiedWorkOrderCompletedText, new object[] { chassisDef.Description.Name })); sim.MechLabQueue.Add(workOrderEntry_ReadyMech); sim.ReadyingMechs[baySlot] = mech; sim.RoomManager.AddWorkQueueEntry(workOrderEntry_ReadyMech); sim.UpdateMechLabWorkQueue(false); sim.RemoveItemStat(id, typeof(MechDef), false); AudioEventManager.PlayAudioEvent("audioeventdef_simgame_vo_barks", "workqueue_readymech", WwiseManager.GlobalAudioObject, null); ___selectedChassis = null; __instance.RefreshData(true); __instance.ViewBays(); __instance.SelectMech(___bayGroupWidget.GetMechUnitForSlot(baySlot), true); } catch (Exception e) { Control.Instance.LogError(e); } return(false); }
public static void CritComponent(this MechComponent component, ref WeaponHitInfo hitInfo) { Weapon weapon1 = component as Weapon; AmmunitionBox ammoBox = component as AmmunitionBox; Jumpjet jumpjet = component as Jumpjet; HeatSinkDef componentDef = component.componentDef as HeatSinkDef; bool flag = weapon1 != null; if (component.parent != null) { if (component.parent.GameRep != null) { WwiseManager.SetSwitch <AudioSwitch_weapon_type>(AudioSwitch_weapon_type.laser_medium, component.parent.GameRep.audioObject); WwiseManager.SetSwitch <AudioSwitch_surface_type>(AudioSwitch_surface_type.mech_critical_hit, component.parent.GameRep.audioObject); int num1 = (int)WwiseManager.PostEvent <AudioEventList_impact>(AudioEventList_impact.impact_weapon, component.parent.GameRep.audioObject, (AkCallbackManager.EventCallback)null, (object)null); int num2 = (int)WwiseManager.PostEvent <AudioEventList_explosion>(AudioEventList_explosion.explosion_small, component.parent.GameRep.audioObject, (AkCallbackManager.EventCallback)null, (object)null); if (component.parent.team.LocalPlayerControlsTeam) { AudioEventManager.PlayAudioEvent("audioeventdef_musictriggers_combat", "critical_hit_friendly ", (AkGameObj)null, (AkCallbackManager.EventCallback)null); } else if (!component.parent.team.IsFriendly(component.parent.Combat.LocalPlayerTeam)) { AudioEventManager.PlayAudioEvent("audioeventdef_musictriggers_combat", "critical_hit_enemy", (AkGameObj)null, (AkCallbackManager.EventCallback)null); } if (jumpjet == null && componentDef == null && (ammoBox == null && component.DamageLevel > ComponentDamageLevel.Functional)) { if (component.parent is Mech mech) { mech.GameRep.PlayComponentCritVFX(component.Location); } } if (ammoBox != null && component.DamageLevel > ComponentDamageLevel.Functional) { component.parent.GameRep.PlayVFX(component.Location, (string)component.parent.Combat.Constants.VFXNames.componentDestruction_AmmoExplosion, true, Vector3.zero, true, -1f); } } } ComponentDamageLevel damageLevel = component.DamageLevel; switch (damageLevel) { case ComponentDamageLevel.Functional: if (flag) { damageLevel = ComponentDamageLevel.Penalized; component.parent.Combat.MessageCenter.PublishMessage((MessageCenterMessage) new AddSequenceToStackMessage((IStackSequence) new ShowActorInfoSequence((ICombatant)component.parent, new Text("{0} CRIT", new object[1] { (object)component.UIName }), FloatieMessage.MessageNature.CriticalHit, true))); goto case ComponentDamageLevel.Destroyed; } else { damageLevel = ComponentDamageLevel.Destroyed; component.parent.Combat.MessageCenter.PublishMessage((MessageCenterMessage) new AddSequenceToStackMessage((IStackSequence) new ShowActorInfoSequence((ICombatant)component.parent, new Text("{0} DESTROYED", new object[1] { (object)component.UIName }), FloatieMessage.MessageNature.ComponentDestroyed, true))); goto case ComponentDamageLevel.Destroyed; } case ComponentDamageLevel.Destroyed: component.DamageComponent(hitInfo, damageLevel, true); break; default: damageLevel = ComponentDamageLevel.Destroyed; component.parent.Combat.MessageCenter.PublishMessage((MessageCenterMessage) new AddSequenceToStackMessage((IStackSequence) new ShowActorInfoSequence((ICombatant)component.parent, new Text("{0} DESTROYED", new object[1] { (object)component.UIName }), FloatieMessage.MessageNature.ComponentDestroyed, true))); goto case ComponentDamageLevel.Destroyed; } }