//[Space] //public FloatOutput RemainingDuration; //public FloatOutput TotalDuration; protected override void OnSetup(IBehaviourContext context) { EventEntry applyOutput = Apply[context]; EventEntry removeOutput = Remove[context]; ConnectionEntry <RPGCharacter> targetOutput = Target[context]; ConnectionEntry <int> ticksOutput = Ticks[context]; //ConnectionEntry<float> totalDurationOutput = TotalDuration[context]; //ConnectionEntry<float> remainingDurationOutput = RemainingDuration[context] targetOutput.OnBeforeChanged += () => { if (targetOutput.Value != null) { removeOutput.Invoke(); } }; targetOutput.OnAfterChanged += () => { if (targetOutput.Value != null) { applyOutput.Invoke(); } }; }
protected override void OnRemove(IBehaviourContext context) { EventEntry removeOutput = Remove[context]; ConnectionEntry <RPGCharacter> targetOutput = Target[context]; targetOutput.Value = null; EventEntry applyOutput = Apply[context]; applyOutput.Invoke(); }
protected override void OnSetup(IBehaviourContext context) { ConnectionEntry <int> firesInput = Fires[context]; ConnectionEntry <float> perSecondsInput = PerSeconds.GetEntry(context); ConnectionEntry <float> spacingInput = Spacing.GetEntry(context); EventEntry eventInput = Event[context]; EventEntry limitedtOutput = Limited[context]; Queue <float> FiringTimes = new Queue <float> (); float lastFiringTime = float.MinValue; eventInput.OnEventFired += () => { if (Time.time < lastFiringTime + spacingInput.Value) { return; } if (FiringTimes.Count < firesInput.Value) { FiringTimes.Enqueue(Time.time); lastFiringTime = Time.time; limitedtOutput.Invoke(); } else { float lastTime = FiringTimes.Peek(); if (Time.time > lastTime + perSecondsInput.Value) { FiringTimes.Dequeue(); FiringTimes.Enqueue(Time.time); lastFiringTime = Time.time; limitedtOutput.Invoke(); } } }; }
protected override void OnSetup(IBehaviourContext context) { ConnectionEntry <RPGCharacter> targetInput = Target[context]; ConnectionEntry <int> damageTakenOutput = DamageTaken[context]; EventEntry onHitOutput = OnHit[context]; bool isActive = false; Action eventHandler = () => { if (targetInput.Value.States.CurrentHealth.Delta >= 1.0f) { damageTakenOutput.Value = (int)targetInput.Value.States.CurrentHealth.Delta; onHitOutput.Invoke(); } }; Action subscriber = () => { if (targetInput.Value == null) { isActive = false; return; } if (!isActive) { targetInput.Value.States.CurrentHealth.OnValueChanged += eventHandler; } isActive = true; }; subscriber(); targetInput.OnBeforeChanged += () => { if (targetInput.Value == null) { return; } if (isActive) { targetInput.Value.States.CurrentHealth.OnValueChanged -= eventHandler; } }; targetInput.OnAfterChanged += subscriber; }
protected override void OnSetup(IBehaviourContext context) { object fieldInputObject = Field.GetConnectionObject(context); // Debug.Log (fieldInputObject); ConnectionEntry fieldInput = (ConnectionEntry)fieldInputObject; EventEntry onChangedOutput = onChanged.GetEntry(context); Action eventHandler = () => { onChangedOutput.Invoke(); }; fieldInput.OnAfterChanged += eventHandler; }
protected override void OnSetup(IBehaviourContext context) { ConnectionEntry <RPGCharacter> targetInput = Target.GetEntry(context); ConnectionEntry <RPGCharacter> hitTargetOutput = HitTarget.GetEntry(context); EventEntry onHitOutput = OnHit.GetEntry(context); bool isActive = false; Action <RPGCharacter> eventHandler = (RPGCharacter target) => { hitTargetOutput.Value = target; onHitOutput.Invoke(); }; Action subscriber = () => { if (targetInput.Value == null) { isActive = false; return; } if (!isActive) { targetInput.Value.OnHit += eventHandler; } isActive = true; }; subscriber(); targetInput.OnBeforeChanged += () => { if (targetInput.Value == null) { return; } if (isActive) { targetInput.Value.OnHit -= eventHandler; } }; targetInput.OnAfterChanged += subscriber; }
protected override void OnSetup(IBehaviourContext context) { ConnectionEntry <bool> conditionInput = Condition[context]; EventEntry trueOutput = True[context]; EventEntry falseOutput = False[context]; Action eventHandler = () => { if (conditionInput.Value) { trueOutput.Invoke(); } else { falseOutput.Invoke(); } }; conditionInput.OnAfterChanged += eventHandler; }
protected override void OnSetup(IBehaviourContext context) { ConnectionEntry <RPGCharacter> equippedOutput = Owner[context]; EventEntry onReceiveOutput = OnReceive[context]; EventEntry onLooseOutput = OnLoose[context]; ConnectionEntry <int> stackSizeOutput = StackSize[context]; //equippedOutput.Value = character; equippedOutput.OnBeforeChanged += () => { if (equippedOutput.Value != null) { onLooseOutput.Invoke(); } }; equippedOutput.OnAfterChanged += () => { if (equippedOutput.Value != null) { onReceiveOutput.Invoke(); } }; }