public static void TriggerEffects(GameEffectCollection effects, DynamicObject caster, Vector3 pos, DynamicObject obj, bool isCast, bool isFromRadiusRecast = false) { ModifierEntryPoints casterEntryPoints = null; if (caster != null) { casterEntryPoints = caster.GetObjectScript <ModifierEntryPoints>(); } EffectContext context = isCast ? effects.cast : effects.dispell; float radius = context.radius; if (!isFromRadiusRecast && radius > 0) { if (casterEntryPoints != null) { radius = casterEntryPoints.ModifyValue("EffectRadius", radius, new Dictionary <string, object>() { { "Caster", caster }, { "EffectCollection", effects } }); } RetriggerEffectsForArea(effects, caster, pos, radius, context.mask, context.checkLOSOnRadiusCast, isCast); return; } if (obj == null) { return; } GameEffectsHandler targetEffectsHandler = obj.GetObjectScript <GameEffectsHandler>(); if (targetEffectsHandler != null && targetEffectsHandler.IsAffectedBy(effects)) { return; } Dictionary <string, object> epRunSubjects = new Dictionary <string, object>() { { "Caster", caster }, { "AffectedObject", obj }, { "EffectCollection", effects }, { "Effect", null } }; Dictionary <string, object> runSubjects = new Dictionary <string, object>() { { "Caster", caster }, { "AffectedObject", obj } }; List <GameEffect> effectsToHold = new List <GameEffect>(); List <float> magnitudes = new List <float>(); List <float> durations = new List <float>(); for (int i = 0; i < context.effects.Length; i++) { GameEffectItem effectItem = context.effects[i]; GameEffect effect = effectItem.effect; if (effect.PlayerOnly() && !obj.isPlayer) { continue; } bool needsToBeAdded = effect.AddToEffectsList(); if (needsToBeAdded) { if (isCast) { if (targetEffectsHandler == null) { Debug.LogWarning("'" + obj.name + "' Doesnt have a GameEffectsHandler, and game effect '" + effect.name + " Needs To Be Kept In An Effect Handler List"); continue; } } else { Debug.LogWarning("Game effect '" + effect.name + " Needs To Be Kept In An Effect Handler List, So It Cant Be Used As a Dispell Effect...."); continue; } } if (!effect.EffectValid(caster, obj)) { continue; } if (!Conditions.ConditionsMet(effectItem.conditions, runSubjects)) { continue; } if (!Conditions.ConditionsMet(effect.conditions, runSubjects)) { continue; } float magnitude = effectItem.magnitude; float duration = effectItem.duration; if (casterEntryPoints != null) { epRunSubjects["Effect"] = effectItem.effect; magnitude = casterEntryPoints.ModifyValue("EffectMagnitude", magnitude, epRunSubjects); if (duration > 0) { duration = casterEntryPoints.ModifyValue("EffectDuration", duration, epRunSubjects); } } /* * TODO: figure out garbage created by create copy */ // if dispell we should already be out by now if needsToBeAdded... if (needsToBeAdded && effect.CreateCopy()) { effect = Object.Instantiate(effect); } // in case there was a problem with the effect start // return out before we add the effect possibly if (!effect.OnEffectStart(caster, obj, magnitude, duration)) { continue; } if (needsToBeAdded) { effectsToHold.Add(effect); magnitudes.Add(magnitude); durations.Add(duration); } } if (effectsToHold.Count > 0) { targetEffectsHandler.AddEffectsToList(effects, caster, effectsToHold, magnitudes, durations); } // TODO: choose scheme for msg... if (obj.isPlayer) { if (!string.IsNullOrEmpty(context.message)) { UIEvents.ShowMessage(0, context.message, false, UIColorScheme.Normal, false); } } }