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); } }
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); } } } }