public EffectScripter(TimedEffect effect) { Effect = effect; // TODO(Ligh): Get the script name and script from the effect. // TODO(Ligh): Clean this up. foreach (var address in Settings.Game.MemoryAddresses) { ((IDictionary<string, object>)addresses).Add(address.Name, address); } // TODO(Ligh): Use the script code instead of these hardcoded debug methods. Effect.OnInit += new EventHandler(OnInit); Effect.OnActivate += new EventHandler(OnActivate); Effect.OnUpdate += new EventHandler(OnUpdate); Effect.OnDeactivate += new EventHandler(OnDeactivate); Effect.OnSuspend += new EventHandler(OnSuspend); }
public void Update() { // TODO(Ligh): Build in debug tools for manipulating the timed effects. // If the base limitations validate and no effect is active, get the next effect and activate it. if (CurrentEffect == null) { // TODO(Ligh): This needs to support gradual activations somehow. while (!ShouldSuspend && CurrentEffect == null) { var effect = DebugGetNextEffect(); // TODO(Ligh): Remove this debug bit. if (effect.EffectType == EffectType.Inline) { continue; } if (effect.CanActivate) { Debug.WriteLine($"Activating timed effect: {effect.Name}"); effect.Activate(); CurrentEffect = effect; effectTimer.SetDuration(effect.EffectLength); } } } else { // Do stuff when there's already an active effect. if (ShouldAbort || effectTimer.EndTimeHasPassed()) { if (ShouldAbort) { Debug.WriteLine($"Aborting timed effect: {CurrentEffect.Name}"); } else { Debug.WriteLine($"Deactivating timed effect: {CurrentEffect.Name}"); } CurrentEffect.Deactivate(); CurrentEffect = null; } else if (ShouldSuspend) { if (CurrentEffect.IsActive) { Debug.WriteLine($"Suspending timed effect: {CurrentEffect.Name}"); } if (!CurrentEffect.IsSuspended) { CurrentEffect.Suspend(); } } else { if (!CurrentEffect.IsActive) { Debug.WriteLine($"Reactivating timed effect: {CurrentEffect.Name}"); } if (!CurrentEffect.IsActive) { CurrentEffect.Activate(); } else { CurrentEffect.Update(); } } } }
public void Shutdown() { if (CurrentEffect != null) { Debug.WriteLine($"Deactivating timed effect for shutdown: {CurrentEffect.Name}"); } CurrentEffect?.Deactivate(); CurrentEffect = null; }