public static void Postfix(PilotableActorRepresentation __instance, VisibilityLevel newLevel) { try { Log.LogWrite("PilotableActorRepresentation.OnPlayerVisibilityChanged " + __instance.parentCombatant.DisplayName + " " + newLevel + "\n"); if (__instance.parentActor == null) { Log.LogWrite(" are you f*****g seriously?? parentActor is null\n", true); return; } foreach (MechComponent component in __instance.parentActor.allComponents) { try { ActivatableComponent activatable = component.componentDef.GetComponent <ActivatableComponent>(); if (activatable == null) { continue; } ; if ((activatable.activateVFXOutOfLOSHide == false) && (activatable.presistantVFXOutOfLOSHide == false)) { continue; } if (activatable.activateVFXOutOfLOSHide == true) { ObjectSpawnDataSelf activeVFX = component.ActivateVFX(); if (activeVFX != null) { if (newLevel != VisibilityLevel.LOSFull) { activeVFX.Hide(); } else { activeVFX.Show(); } } } if (activatable.presistantVFXOutOfLOSHide == true) { ObjectSpawnDataSelf presistantVFX = component.PresitantVFX(); if (presistantVFX != null) { if (newLevel != VisibilityLevel.LOSFull) { presistantVFX.Hide(); } else { presistantVFX.Show(); } } } } catch (Exception e) { Log.LogWrite(e.ToString() + "\n", true); } } }catch (Exception e) { Log.LogWrite(e.ToString() + "\n", true); } }
static void Prefix(PilotableActorRepresentation __instance, ref VisibilityLevel newLevel) { if (!FogOfWarManager.GetInstance().IsFogOfWarOn) { newLevel = VisibilityLevel.LOSFull; } }
public static void Postfix(PilotableActorRepresentation __instance) { try { var rep = __instance; OverrideGhostVFXSettings.BlipGhostType blip; if (rep.BlipObjectGhostWeak.activeSelf) { blip = Control.settings.OverrideGhostVFX.BlipWeak; } else if (rep.BlipObjectGhostStrong.activeSelf) { blip = Control.settings.OverrideGhostVFX.BlipStrong; } else { return; } rep.BlipObjectGhostWeak.SetActive(false); rep.BlipObjectGhostStrong.SetActive(false); if (blip == OverrideGhostVFXSettings.BlipGhostType.Weak) { rep.BlipObjectGhostWeak.SetActive(true); } else if (blip == OverrideGhostVFXSettings.BlipGhostType.Strong) { rep.BlipObjectGhostStrong.SetActive(true); } } catch (Exception e) { Control.Logger.Error.Log(e); } }
public static void Postfix(MechComponent __instance, bool __state) { Mod.Log.Trace?.Write("MC:CCE:post entered."); if (__state) { Mod.Log.Debug?.Write($" Stealth effect was cancelled, parent visibility needs refreshed."); EWState parentState = new EWState(__instance.parent); PilotableActorRepresentation par = __instance.parent.GameRep as PilotableActorRepresentation; if (parentState.HasStealth()) { VfxHelper.EnableStealthVfx(__instance.parent); } else { VfxHelper.DisableSensorStealthEffect(__instance.parent); } if (parentState.HasMimetic()) { VfxHelper.EnableMimeticEffect(__instance.parent); } else { VfxHelper.DisableMimeticEffect(__instance.parent); } // Force a refresh in case the signature increased due to stealth loss // TODO: Make this player hostile only List <ICombatant> allLivingCombatants = __instance.parent.Combat.GetAllLivingCombatants(); __instance.parent.VisibilityCache.UpdateCacheReciprocal(allLivingCombatants); } }
static void Prefix(Mech __instance) { try { string folder = Path.Combine(MechSkinLoader.ModDirectory, __instance.MechDef.Chassis.PrefabBase); if (Directory.Exists(folder)) { PilotableActorRepresentation pilotableActorRepresentation = __instance.GameRep as PilotableActorRepresentation; if (pilotableActorRepresentation == null) { MechSkinLoader.Logger.Log("pilotableActorRepresentation is null"); } else { MechCustomization ___mechCustomization = (MechCustomization)AccessTools.Method(typeof(PilotableActorRepresentation), "get_mechCustomization").Invoke(pilotableActorRepresentation, new object[] { }); if (___mechCustomization == null) { MechSkinLoader.Logger.Log("___mechCustomization is null"); } else { List <string> skins = new List <string>(); string[] files = Directory.GetFiles(folder); foreach (string file in files) { skins.Add(Path.GetFileName(file)); } foreach (string skinname in skins) { bool flag = false; Texture2D[] array = ___mechCustomization.paintPatterns; for (int i = 0; i < array.Length; i++) { if (array[i].name == skinname) { flag = true; } } if (!flag) { Texture2D texture2D = UnityEngine.Object.Instantiate <Texture2D>(___mechCustomization.paintPatterns[0]); texture2D.name = skinname; byte[] data = File.ReadAllBytes(Path.Combine(folder, skinname)); texture2D.LoadImage(data); Array.Resize <Texture2D>(ref ___mechCustomization.paintPatterns, ___mechCustomization.paintPatterns.Length + 1); ___mechCustomization.paintPatterns[___mechCustomization.paintPatterns.Length - 1] = texture2D; } } } } } else { MechSkinLoader.Logger.LogIfDebug("Not found " + __instance.MechDef.Chassis.PrefabBase); } } catch (Exception e) { MechSkinLoader.Logger.LogError(e); } }
static void Prefix(PilotableActorRepresentation __instance, ref VisibilityLevel newLevel) { if (!FogOfWarManager.GetInstance().IsFogOfWarOn) { Main.Logger.LogDebug($"[BTDebug] Running PilotableActorRepresentation Prefix for Fog of War"); newLevel = VisibilityLevel.LOSFull; } }
public static void Prefix(PilotableActorRepresentation __instance, ref Vector3 ___blipPendingPosition) { //Mod.Log.Debug?.Write($" UPDATE BLIPS INVOKED"); if (__instance.BlipObjectUnknown.activeSelf && __instance.VisibleObject.activeSelf && !__instance.BlipObjectIdentified.activeSelf) { float height = Math.Min(__instance.VisibleObject.transform.position.y + 20f, ___blipPendingPosition.y + 20f); ___blipPendingPosition.y = height; } }
public static void Postfix(CombatHUDNumFlagHex __instance) { if (__instance.DisplayedActor != null && __instance.DisplayedActor.IsActorOnScreen()) { PilotableActorRepresentation par = (PilotableActorRepresentation)__instance.DisplayedActor.GameRep; if (par != null && par.VisibleObject.activeSelf && par.BlipObjectUnknown.activeSelf) { __instance.anchorPosition = CombatHUDInWorldScalingActorInfo.AnchorPosition.Feet; } else { __instance.anchorPosition = CombatHUDInWorldScalingActorInfo.AnchorPosition.Head; } } }
static void Postfix(PilotableActorRepresentation __instance, VisibilityLevel newLevel) { Mod.Log.Trace?.Write("PAR:OPVC entered."); Traverse parentT = Traverse.Create(__instance).Property("parentActor"); AbstractActor parentActor = parentT.GetValue <AbstractActor>(); if (ModState.AmbushTurretGUIDtoBuilding.Keys.Contains(parentActor.GUID)) { Turret turret = parentActor as Turret; if (newLevel == VisibilityLevel.LOSFull) { __instance.VisibleObject.SetActive(false); } } }
public static void DEBUG_ToggleForcedVisibility(bool forceVisible, CombatGameState Combat) { List <ICombatant> list = Combat.AllActors.ConvertAll <ICombatant>((AbstractActor x) => x); for (int i = 0; i < list.Count; i++) { PilotableActorRepresentation pilotableActorRepresentation = list[i].GameRep as PilotableActorRepresentation; if (pilotableActorRepresentation != null) { if (forceVisible) { pilotableActorRepresentation.SetForcedPlayerVisibilityLevel(VisibilityLevel.LOSFull, true); } else { pilotableActorRepresentation.ClearForcedPlayerVisibilityLevel(list); } } } }
public static void DisableMimeticEffect(AbstractActor actor) { if (!ModState.TurnDirectorStarted) { return; } if (actor.StatCollection.ContainsStatistic(ModStats.MimeticVFXEnabled)) { Mod.Log.Debug?.Write("DISABLING MIMETIC EFFECT"); actor.GameRep.StopManualPersistentVFX(MimeticEffectVfxId); if (Mod.Config.Toggles.MimeticUsesGhost) { Mod.Log.Debug?.Write($"Disabling GhostWeak VFX on actor: {CombatantUtils.Label(actor)}"); PilotableActorRepresentation par = actor.GameRep as PilotableActorRepresentation; par.BlipObjectGhostStrong.SetActive(false); par.BlipObjectGhostWeak.SetActive(false); } actor.StatCollection.RemoveStatistic(ModStats.MimeticVFXEnabled); } }
public static void Init_Pre(PilotableActorRepresentation __instance) { __instance.BlipObjectGhostWeak = __instance.BlipObjectUnknown; __instance.BlipObjectGhostStrong = __instance.BlipObjectIdentified; }
public static void EnableMimeticEffect(AbstractActor actor) { if (!ModState.TurnDirectorStarted) { return; } if (!actor.StatCollection.ContainsStatistic(ModStats.MimeticVFXEnabled)) { Mod.Log.Debug?.Write("ENABLING MIMETIC EFFECT"); ParticleSystem ps = PlayVFXAt(actor.GameRep, actor.GameRep.thisTransform, Vector3.zero, ECMBubbleBaseVFX, MimeticEffectVfxId, true, Vector3.zero, false, -1f);; ps.Stop(true); foreach (Transform child in ps.transform) { if (child.gameObject.name == "sphere rumble") { Mod.Log.Trace?.Write($" - Configuring sphere rumble"); if (actor.UnitType == UnitType.Mech) { // problate ellipsoid child.gameObject.transform.localScale = new Vector3(0.12f, 0.12f, 0.12f); } else if (actor.UnitType == UnitType.Vehicle) { // oblong ellipsoid child.gameObject.transform.localScale = new Vector3(0.24f, 0.12f, 0.24f); } else { // Turrets and unknown get sphere child.gameObject.transform.localScale = new Vector3(0.24f, 0.24f, 0.24f); } // Try to manipulate the animation speed ParticleSystem[] childPS = child.gameObject.GetComponentsInChildren <ParticleSystem>(); if (childPS != null && childPS.Length != 0) { foreach (ParticleSystem cPS in childPS) { var main = cPS.main; main.duration = 4f; } } // Center the sphere if (actor.GameRep is MechRepresentation mr) { float headToTorso = mr.vfxHeadTransform.position.y - mr.vfxCenterTorsoTransform.position.y; float torsoToLeg = mr.vfxCenterTorsoTransform.position.y - mr.vfxLeftLegTransform.position.y; Mod.Log.Trace?.Write($"Parent mech headToTorso:{headToTorso} / torsoToLeg:{torsoToLeg}"); child.gameObject.transform.position = mr.vfxCenterTorsoTransform.position; child.gameObject.transform.localPosition = new Vector3(0f, headToTorso * 2, 2f); Mod.Log.Debug?.Write($"Centering sphere on mech torso at position: {mr.TorsoAttach.position}"); } else if (actor.GameRep is VehicleRepresentation vr) { child.gameObject.transform.position = vr.BodyAttach.position; child.gameObject.transform.localPosition = new Vector3(0f, 0f, 2f); Mod.Log.Debug?.Write($"Centering sphere on vehicle body at position: {vr.BodyAttach.position}"); } else if (actor.GameRep is TurretRepresentation tr) { child.gameObject.transform.position = tr.BodyAttach.position; child.gameObject.transform.localPosition = new Vector3(0f, 0f, 2f); Mod.Log.Debug?.Write($"Centering sphere on turret body at position: {tr.BodyAttach.position}"); } ParticleSystemRenderer spherePSR = child.gameObject.transform.GetComponent <ParticleSystemRenderer>(); spherePSR.material = VfxHelper.DistortionMaterial; } else { child.gameObject.SetActive(false); } } ps.Play(true); if (Mod.Config.Toggles.MimeticUsesGhost) { Mod.Log.Debug?.Write($"Enabling GhostWeak VFX on actor: {CombatantUtils.Label(actor)}"); PilotableActorRepresentation par = actor.GameRep as PilotableActorRepresentation; par.BlipObjectGhostStrong.SetActive(false); par.BlipObjectGhostWeak.SetActive(true); } actor.StatCollection.AddStatistic(ModStats.MimeticVFXEnabled, true); } }
public static void Postfix(PilotableActorRepresentation __instance, VisibilityLevel newLevel) { Mod.Log.Trace?.Write("PAR:OPVC entered."); Traverse parentT = Traverse.Create(__instance).Property("parentActor"); AbstractActor parentActor = parentT.GetValue <AbstractActor>(); if (parentActor == null) { Mod.Log.Trace?.Write($"ParentActor is null, skipping!"); return; } EWState parentState = new EWState(parentActor); if (newLevel == VisibilityLevel.LOSFull) { if (parentState.HasStealth()) { VfxHelper.EnableStealthVfx(parentActor); } else { VfxHelper.DisableSensorStealthEffect(parentActor); } if (parentState.HasMimetic()) { VfxHelper.EnableMimeticEffect(parentActor); } else { VfxHelper.DisableMimeticEffect(parentActor); } __instance.BlipObjectUnknown.SetActive(false); __instance.BlipObjectUnknown.SetActive(false); } else if (newLevel >= VisibilityLevel.Blip0Minimum) { Mod.Log.Debug?.Write($"Actor: {CombatantUtils.Label(parentActor)} has changed player visibility to: {newLevel}"); if (parentActor.team.IsFriendly(parentActor.Combat.LocalPlayerTeam)) { Mod.Log.Debug?.Write($" Target actor is friendly, forcing blip off"); __instance.BlipObjectUnknown.SetActive(false); } else { // Because Blip1 corresponds to ArmorAndWeapon, go ahead and show the model as the chassis is 'known' if (newLevel >= VisibilityLevel.Blip1Type) { Mod.Log.Debug?.Write($" Actor is a foe, disabling the identified blip and showing the object"); __instance.VisibleObject.SetActive(true); __instance.BlipObjectIdentified.SetActive(false); __instance.BlipObjectUnknown.transform.localScale = new Vector3(1f, 0.8f, 1f); __instance.BlipObjectUnknown.SetActive(true); } } } }