public override void OnInspectorGUI() { DrawDefaultInspector(); RPGCharacter character = (RPGCharacter)target; if (character.Buffs != null && character.Buffs.Count != 0) { foreach (Buff buff in character.Buffs) { if (buff == null) { continue; } EditorGUI.indentLevel++; EditorGUILayout.LabelField(buff.StackSize.Value.ToString() + " " + buff.buffTemplate.name, EditorStyles.boldLabel); Rect iconRect = GUILayoutUtility.GetLastRect(); iconRect = EditorGUI.IndentedRect(iconRect); iconRect.xMax = iconRect.xMin + iconRect.height; iconRect.x -= iconRect.height; DrawCustomIcon(iconRect, buff.buffTemplate.Icon); EditorGUI.indentLevel++; foreach (BuffClock clock in buff.Clocks) { Rect rect = GUILayoutUtility.GetRect(0, 16); rect = EditorGUI.IndentedRect(rect); if (typeof(BuffClockDecaying).IsAssignableFrom(clock.GetType())) { BuffClockDecaying decayingClock = (BuffClockDecaying)clock; EditorGUI.ProgressBar(rect, decayingClock.TimeRemaining / decayingClock.Duration, decayingClock.StackSize.Value.ToString()); } else if (typeof(BuffClockFixed).IsAssignableFrom(clock.GetType())) { BuffClockFixed fixedClock = (BuffClockFixed)clock; EditorGUI.ProgressBar(rect, 1.0f, fixedClock.StackSize.Value.ToString()); } } EditorGUI.indentLevel--; EditorGUI.indentLevel--; } GUILayout.Space(20); } }
protected override void OnSetup(IBehaviourContext context) { EventEntry applyInput = Apply[context]; ConnectionEntry <RPGCharacter> targetInput = Target[context]; ConnectionEntry <int> stackSizeInput = StackSize[context]; applyInput.OnEventFired += () => { if (Mode == ApplyMode.Add) { Buff buff = new Buff(this, context); BuffClock buffClock = new BuffClockFixed(this, context); buffClock.StackSize.AddFlatModifier(stackSizeInput.Value); buff.AddClock(buffClock); targetInput.Value.Buffs.Add(buff); } else if (Mode == ApplyMode.Stack) { Buff buff = targetInput.Value.Buffs.Find(BuffToApply); Debug.Log(BuffToApply.name); if (buff == null) { buff = new Buff(this, context); BuffClock buffClock = new BuffClockFixed(this, context); buffClock.StackSize.AddFlatModifier(0); buff.AddClock(buffClock); targetInput.Value.Buffs.Add(buff); } buff.BaseStackSize.Value += stackSizeInput.Value; } }; stackSizeInput.OnAfterChanged += () => { return; // if (modifier != null) // modifier.Value = stackSizeInput.Value; }; }
protected override void OnSetup(IBehaviourContext context) { var targetInput = Target[context]; var whilstInput = Whilst[context]; ConnectionEntry <int> stackSizeInput = StackSize[context]; bool isActive = false; Buff buff = null; IntegerStack.Modifier modifier = null; Action changeHandler = () => { if (targetInput.Value == null) { return; } if (whilstInput.Value) { if (!isActive) { if (Mode == ApplyMode.Add) { buff = new Buff(this, context); BuffClock buffClock = new BuffClockFixed(this, context); modifier = buffClock.StackSize.AddFlatModifier(stackSizeInput.Value); buff.AddClock(buffClock); targetInput.Value.Buffs.Add(buff); } else { buff = targetInput.Value.Buffs.Find(BuffToApply); if (buff == null) { buff = new Buff(this, context); targetInput.Value.Buffs.Add(buff); } BuffClock buffClock = new BuffClockFixed(this, context); modifier = buffClock.StackSize.AddFlatModifier(stackSizeInput.Value); buff.AddClock(buffClock); } isActive = true; } } else if (isActive) { targetInput.Value.Buffs.Remove(buff); isActive = false; } ; }; targetInput.OnBeforeChanged += () => { if (targetInput.Value == null) { isActive = false; return; } if (!isActive) { return; } Debug.Log("Ending"); targetInput.Value.Buffs.Remove(buff); isActive = false; }; stackSizeInput.OnAfterChanged += () => { if (modifier != null) { modifier.Value = stackSizeInput.Value; } }; targetInput.OnAfterChanged += changeHandler; whilstInput.OnAfterChanged += changeHandler; changeHandler(); }