public static void Postfix(ActorMovementSequence __instance) { var traverse = Traverse.Create(__instance); var combat = traverse.Property("Combat").GetValue <CombatGameState>(); AuraCache.RefreshECMStates(combat.AllActors, EffectTriggerType.Passive); }
/*public static bool ShouldAffectThisActor(this AuraCache instance, AbstractActor fromActor, EffectData effect, EffectTriggerType triggerSource) { * return (bool)mShouldAffectThisActor.Invoke(instance, new object[] { fromActor, effect, triggerSource }); * } * public static bool AuraConditionsPassed(this AuraCache instance, AbstractActor fromActor, MechComponent auraComponent, EffectData effectData, float distSquared, EffectTriggerType triggerSource) { * return (bool)mAuraConditionsPassed.Invoke(instance, new object[] { fromActor, auraComponent, effectData, distSquared, triggerSource }); * }*/ public static bool Prefix(AuraCache __instance, AbstractActor fromActor, MechComponent auraComponent, float distSquared, ref List <EffectData> __result) { /*AbstractActor Owner = (AbstractActor)FOwner.Invoke(__instance, new object[0] { }); * List<EffectData> effectDataList = new List<EffectData>(); * for (int index = 0; index < auraComponent.componentDef.statusEffects.Length; ++index) { * if (__instance.ShouldAffectThisActor(fromActor, auraComponent.componentDef.statusEffects[index], EffectTriggerType.Preview) && __instance.AuraConditionsPassed(fromActor, auraComponent, auraComponent.componentDef.statusEffects[index], distSquared, EffectTriggerType.Preview)) * effectDataList.Add(auraComponent.componentDef.statusEffects[index]); * } * ActivatableComponent activatable = auraComponent.componentDef.GetComponent<ActivatableComponent>(); * if (activatable != null) { * if (auraComponent.isActive()) { * for (int index = 0; index < activatable.statusEffects.Length; ++index) { * if (__instance.ShouldAffectThisActor(fromActor, activatable.statusEffects[index], EffectTriggerType.Preview) && __instance.AuraConditionsPassed(fromActor, auraComponent, activatable.statusEffects[index], distSquared, EffectTriggerType.Preview)) * effectDataList.Add(activatable.statusEffects[index]); * } * } else { * for (int index = 0; index < activatable.offlineStatusEffects.Length; ++index) { * if (__instance.ShouldAffectThisActor(fromActor, activatable.offlineStatusEffects[index], EffectTriggerType.Preview) && __instance.AuraConditionsPassed(fromActor, auraComponent, activatable.offlineStatusEffects[index], distSquared, EffectTriggerType.Preview)) * effectDataList.Add(activatable.offlineStatusEffects[index]); * } * } * } * __result = effectDataList;*/ return(false); //Log.LogWrite("AuraCache.PreviewAura prefix owner:" + Owner.DisplayName + ":" + Owner.GUID + " from: " + fromActor.DisplayName + ":" + fromActor.GUID + " component:" + auraComponent.defId + "\n"); }
/*public static void AddEffectIfNotPresent(this AuraCache instance, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos, string effectCreatorId, EffectData effect, ref List<string> existingEffectIDs, EffectTriggerType triggerSource) { * object[] args = new object[7] { fromActor, movingActor, movingActorPos, effectCreatorId, effect, existingEffectIDs, triggerSource}; * mAddEffectIfNotPresent.Invoke(instance, args); * existingEffectIDs = (List<string>)args[5]; * } * public static void RemoveEffectIfPresent(this AuraCache instance, AbstractActor fromActor, string effectCreatorId, EffectData effect, List<Effect> existingEffects, EffectTriggerType triggerSource) { * object[] args = new object[5] { fromActor, effectCreatorId, effect, existingEffects, triggerSource }; * mRemoveEffectIfPresent.Invoke(instance, args); * }*/ public static bool Prefix(AuraCache __instance, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos, MechComponent auraComponent, float distSquared, EffectTriggerType triggerSource, bool skipECMCheck) { /*AbstractActor Owner = (AbstractActor)FOwner.Invoke(__instance, new object[0] { }); * List<Effect> all = Owner.Combat.EffectManager.GetAllEffectsCreatedBy(fromActor.GUID).FindAll((Predicate<Effect>)(x => x.targetID == Owner.GUID)); * for (int index = 0; index < auraComponent.componentDef.statusEffects.Length; ++index) { * if (__instance.ShouldAffectThisActor(fromActor, auraComponent.componentDef.statusEffects[index], triggerSource)) { * if (!skipECMCheck && (auraComponent.componentDef.statusEffects[index].targetingData.auraEffectType == AuraEffectType.ECM_GHOST || auraComponent.componentDef.statusEffects[index].targetingData.auraEffectType == AuraEffectType.ECM_GENERAL)) * Owner.Combat.FlagECMStateNeedsRefreshing(); * else if (__instance.AuraConditionsPassed(fromActor, auraComponent, auraComponent.componentDef.statusEffects[index], distSquared, triggerSource)) * __instance.AddEffectIfNotPresent(fromActor, movingActor, movingActorPos, auraComponent.componentDef.Description.Id, auraComponent.componentDef.statusEffects[index], ref auraComponent.createdEffectIDs, triggerSource); * else * __instance.RemoveEffectIfPresent(fromActor, auraComponent.componentDef.Description.Id, auraComponent.componentDef.statusEffects[index], all, triggerSource); * } * }*/ return(false); //Log.LogWrite("AuraCache.UpdateAura prefix owner:" + Owner.DisplayName + ":" + Owner.GUID + " from: " + fromActor.DisplayName + ":" + fromActor.GUID + " component:" + auraComponent.defId + "\n"); }
public static void Postfix(AuraCache __instance, AbstractActor fromActor, MechComponent auraComponent, EffectData effectData, float distSquared, EffectTriggerType triggerSource, ref bool __result) { /*AbstractActor Owner = (AbstractActor)FOwner.Invoke(__instance, new object[0] { }); * //Log.LogWrite("AuraCache.AuraConditionsPassed prefix owner:" + Owner.DisplayName + ":"+Owner.GUID+" from: "+fromActor.DisplayName+":"+fromActor.GUID+" component:"+auraComponent.defId+" effect:"+effectData.Description.Id+" res:"+__result+"\n"); * if (__result == false) { return; } * ActivatableComponent activatable = auraComponent.componentDef.GetComponent<ActivatableComponent>(); * if (activatable == null) { return; } * if (activatable.baseEffects.Contains(effectData)) { * //Log.LogWrite(" base effect\n"); * return; * }; * bool componentActive = ActivatableComponent.isComponentActivated(auraComponent); * if (activatable.onlineEffects.Contains(effectData) && (componentActive == false)) { * //Log.LogWrite(" online effect but not actiavted\n"); * __result = false; * } else * if (activatable.offlineEffects.Contains(effectData) && (componentActive == true)) { * //Log.LogWrite(" offline effect but actiavted\n"); * __result = false; * };*/ }
public static void Postfix(AuraCache __instance, AbstractActor fromActor, EffectData effect, EffectTriggerType triggerSource, ref bool __result) { //AbstractActor Owner = (AbstractActor)FOwner.Invoke(__instance, new object[0] { }); //Log.LogWrite("AuraCache.ShouldAffectThisActor postfix owner:" + Owner.DisplayName + ":" + Owner.GUID + " from: " + fromActor.DisplayName + ":" + fromActor.GUID + " Effect:" + effect.Description.Id + " result:" + __result + "\n"); }
public static bool Prefix(AuraCache __instance, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos, float distSquared, EffectTriggerType triggerSource, bool forceUpdate) { //AbstractActor Owner = (AbstractActor)FOwner.Invoke(__instance, new object[0] { }); //Log.LogWrite("AuraCache.UpdateAuras prefix owner:" + Owner.DisplayName + ":" + Owner.GUID + " from: " + fromActor.DisplayName + ":" + fromActor.GUID + " AuraComponents:" + fromActor.AuraComponents.Count + " forceUpdate:" + forceUpdate + "\n"); return(false); }
public static void Prefix(AuraCache __instance, ref bool __result, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos, string effectCreatorId, EffectData effect, ref List <string> existingEffectIDs, EffectTriggerType triggerSource) { Mod.Log.Trace("AC:AEINP:pre entered"); Traverse ownerT = Traverse.Create(__instance).Property("Owner"); AbstractActor Owner = ownerT.GetValue <AbstractActor>(); // 1. When the same effectId is added, record every actor that contributes the same effect id. Only remove the effect if all actors have removed the effect string sourcesStat = $"{effect.Description.Id}_AH_SOURCES"; string sourceValue = CombatantUtils.Label(fromActor); Mod.Log.Debug($" sourceValue: ({sourceValue})"); if (!Owner.StatCollection.ContainsStatistic(sourcesStat)) { Owner.StatCollection.AddStatistic <string>(sourcesStat, ""); Owner.StatCollection.Set <string>(sourcesStat, sourceValue); //Mod.Log.Debug($" new sources statistic: ({sourcesStat}) value: ({sourceValue})"); } else { string statSources = Owner.StatCollection.GetStatistic(sourcesStat).Value <string>(); HashSet <string> sources = new HashSet <string>(); foreach (string value in statSources.Split(',')) { if (value != null && !value.Equals(sourceValue)) { sources.Add(value); } } sources.Add(sourceValue); string newValue = string.Join(",", new List <string>(sources).ToArray()); Owner.StatCollection.Set <string>(sourcesStat, newValue); //Mod.Log.Debug($" sources statistic: ({sourcesStat}) value: ({newValue})"); } // 2. When multiple effects add to the same statistic, record each value as an array if (effect.effectType == EffectType.StatisticEffect) { Mod.Log.Debug($"Tracking statEffect vs statistic: {effect.statisticData.statName} fromActor: {CombatantUtils.Label(fromActor)} effectCreatorId: {effectCreatorId} " + $"vs. movingActor: {CombatantUtils.Label(movingActor)}"); // Create a tracking stat, denoting effectId:fromActorGUID:strength string valuesStat = $"{effect.Description.Id}_AH_VALUES"; string effectValue = $"{effect.Description.Id}:{CombatantUtils.Label(fromActor)}:{effectCreatorId}:{effect.statisticData.modValue}"; Mod.Log.Debug($" effectValue: ({effectValue})"); if (!Owner.StatCollection.ContainsStatistic(valuesStat)) { Owner.StatCollection.AddStatistic <string>(valuesStat, ""); Owner.StatCollection.Set <string>(valuesStat, effectValue); //Mod.Log.Debug($" new values statistic: ({valuesStat}) value: ({effectValue})"); } else { string statValues = Owner.StatCollection.GetStatistic(valuesStat).Value <string>(); HashSet <string> values = new HashSet <string>(); foreach (string value in statValues.Split(',')) { if (value != null && !value.Equals(effectValue)) { values.Add(value); } } values.Add(effectValue); string newValue = string.Join(",", new List <string>(values).ToArray()); Owner.StatCollection.Set <string>(valuesStat, newValue); //Mod.Log.Debug($" values statistic: ({valuesStat}) value: ({newValue})"); } } }
public static void Postfix(AuraCache __instance, bool __result, AbstractActor fromActor, float distSquared) { Mod.Log.Trace($"-- AuraCache:AuraConditionsPassed:MechComponent result: {__result} for actor: {CombatantUtils.Label(fromActor)} at range: {distSquared}"); }
public static void Postfix(AuraCache __instance, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos, MechComponent auraComponent, float distSquared, EffectTriggerType triggerSource, bool skipECMCheck) { Mod.Log.Trace("AC:UA:MC entered"); }
public static bool Prefix(AuraCache __instance, ref int __result) { __result = 0; return(false); }
public static void Postfix(ActorMovementSequence __instance) { AuraCache.RefreshECMStates(__instance.Combat.AllActors, EffectTriggerType.Passive); }
public static bool Prefix(AuraCache __instance, ref AbstractActor __result) { __result = null; return(false); }
public static bool Prefix(AuraCache __instance) { return(false); }
public static bool Prefix(AuraCache __instance, ref List <EffectData> __result) { __result = new List <EffectData>(); return(false); }
public static bool Prefix(AuraCache __instance, ref bool __result) { __result = true; return(false); }
public static bool Prefix(AuraCache __instance, AbstractActor fromActor, string effectCreatorId, EffectData effect, List <Effect> existingEffects, EffectTriggerType triggerSource) { Mod.Log.Trace("AC:REIP entered"); bool allowMethod = true; Traverse ownerT = Traverse.Create(__instance).Property("Owner"); AbstractActor Owner = ownerT.GetValue <AbstractActor>(); // 1. When the same effectId is added, record every actor that contributes the same effect id. Only remove the effect if all actors have removed the effect string sourcesStat = $"{effect.Description.Id}_AH_SOURCES"; string sourceValue = CombatantUtils.Label(fromActor); if (Owner.StatCollection.ContainsStatistic(sourcesStat)) { Mod.Log.Debug($" Removing effectSource: {sourceValue} from Owner: ({CombatantUtils.Label(Owner)}"); string statSources = Owner.StatCollection.GetStatistic(sourcesStat).Value <string>(); Mod.Log.Debug($" -- statSources: ({statSources})"); HashSet <string> newValues = new HashSet <string>(); foreach (string value in statSources.Split(',')) { if (value != null && value != "") { newValues.Add(value); } } if (newValues.Contains(sourceValue)) { newValues.Remove(sourceValue); } if (newValues.Count > 0) { string newValue = string.Join(",", new List <string>(newValues).ToArray()); Mod.Log.Debug($" changing effectSources on actor: ({CombatantUtils.Label(Owner)}) from: ({statSources}) to: ({newValue})"); Owner.StatCollection.Set(sourcesStat, newValue); allowMethod = false; } else { Mod.Log.Debug($" No effectSources remaining on actor: ({CombatantUtils.Label(Owner)}), removing statistic: {sourcesStat}"); Owner.StatCollection.RemoveStatistic(sourcesStat); } } // 2. When multiple effects add to the same statistic, record each value as an array if (effect != null && effect.effectType == EffectType.StatisticEffect) { string valuesStat = $"{effect.Description.Id}_AH_VALUES"; string effectValue = $"{effect.Description.Id}:{CombatantUtils.Label(fromActor)}:{effectCreatorId}:{effect.statisticData.modValue}"; if (Owner.StatCollection.ContainsStatistic(valuesStat)) { Mod.Log.Debug($" Removing effectValue: {effectValue} from Owner: ({CombatantUtils.Label(Owner)}"); string statValues = Owner.StatCollection.GetStatistic(valuesStat).Value <string>(); Mod.Log.Debug($" -- statValues: ({statValues})"); HashSet <string> newValues = new HashSet <string>(); foreach (string value in statValues.Split(',')) { if (value != null || value != "") { newValues.Add(value); } } if (newValues.Contains(effectValue)) { newValues.Remove(effectValue); } if (newValues.Count > 0) { string newValue = string.Join(",", new List <string>(newValues).ToArray()); Mod.Log.Debug($" changing statValues from: ({statValues}) to: ({newValue})"); Owner.StatCollection.Set(valuesStat, newValue); allowMethod = false; } else { Mod.Log.Debug($" No effects remaining on actor: ({CombatantUtils.Label(Owner)}), removing all values"); Owner.StatCollection.RemoveStatistic(valuesStat); } } } return(allowMethod); }
public static bool Prefix(AuraCache __instance, ref Dictionary <string, List <EffectData> > __result) { __result = new Dictionary <string, List <EffectData> >(); return(false); }