void SetValue(TData v, bool resetting) { // Auto-bound SmartRefs get bound first time value changes after they're queued if (_binder.hasRefsToBind) { _binder.AutoBind(); } if (_hasDecorators) { TData temp = v; temp = ExecuteDecoratorsOnUpdate(_decorators, _runtimeValue, temp, resetting); if (_multiDecorators.Count > 0) { foreach (var a in _multiDecorators) { temp = ExecuteDecoratorsOnUpdate(a.Value, _runtimeValue, temp, resetting); } } _runtimeValue = temp; } else { _runtimeValue = v; } _relay.Dispatch(_runtimeValue); }
public TData this[int index] { get { return(_runtimeSet[index]); } set { _runtimeSet[index] = value; _relay.Dispatch(value, true); } }
public void Add(T item) { if (!Items.Contains(item)) { Items.Add(item); OnSetChanged.Dispatch(); OnAddedItem.Dispatch(item); } }
/// <summary> Fire event. </summary> public void Dispatch() { _relay.Dispatch(); #if UNITY_EDITOR && !SMARTDATA_NO_GRAPH_HOOKS SmartData.Editors.SmartDataRegistry.OnRefCallToSmart(null, this); #endif }
/// <summary>Fire event.</summary> /// <returns>Any block flags generated by decorators.</returns> public BlockFlags Dispatch() { BlockFlags block = BlockFlags.NONE; if (_hasDecorators) { for (int i = 0; i < _decorators.Length; ++i) { if (_decorators[i].active) { (_decorators[i] as SmartEventDecoratorBase).OnDispatched(ref block); if (block.Contains(BlockFlags.DECORATORS)) { break; } } } } if (!block.Contains(BlockFlags.DISPATCH)) { _relay.Dispatch(); #if UNITY_EDITOR && !SMARTDATA_NO_GRAPH_HOOKS SmartData.Editors.SmartDataRegistry.OnRefCallToSmart(null, this); #endif } return(block); }
public void Dispatch() { if (_event) { var b = _event.Dispatch(); if (!unityEventOnReceive && !b.Contains(BlockFlags.DISPATCH)) { InvokeUnityEvent(); } } else { _localEvent.Dispatch(); InvokeUnityEvent(); } #if UNITY_EDITOR && !SMARTDATA_NO_GRAPH_HOOKS if (_useMulti) { Editors.SmartDataRegistry.OnRefCallToSmart(this, _smartMulti, _event); } else { Editors.SmartDataRegistry.OnRefCallToSmart(this, _smartEvent); } #endif }
void SetValue(TData v, RestoreMode restore) { // When setting initial value, don't dispatch anything or use decorators if (restore == RestoreMode.INIT) { _runtimeValue = v; return; } // Auto-bound SmartRefs get bound first time value changes after they're queued if (_binder.hasRefsToBind) { _binder.AutoBind(); } BlockFlags block = BlockFlags.NONE; if (_hasDecorators) { TData temp = v; temp = ExecuteDecoratorsOnUpdate(_decorators, _runtimeValue, temp, restore, ref block); // If decorators blocked, do not continue to other decorators if (!block.Contains(BlockFlags.DECORATORS) && _multiDecorators.Count > 0) { foreach (var a in _multiDecorators) { temp = ExecuteDecoratorsOnUpdate(a.Value, _runtimeValue, temp, restore, ref block); } } // If data blocked, do not update runtime value if (!block.Contains(BlockFlags.DATA)) { _runtimeValue = temp; } } else { _runtimeValue = v; } // If dispatch blocked, do not dispatch relay if (!block.Contains(BlockFlags.DISPATCH)) { _relay.Dispatch(_runtimeValue); } }
public virtual void Raise() { onRaiseRelay.Dispatch(); for (int i = eventListeners.Count - 1; i >= 0; i--) { eventListeners[i].OnRaiseEvents(); } }
public void Remove(T item) { if (Items.Contains(item)) { Items.Remove(item); OnSetChanged.Dispatch(); OnRemovedItem.Dispatch(item); } }
public override float OnUpdated(float oldValue, float newValue, RestoreMode restoreMode, ref BlockFlags block) { float result = Mathf.Clamp(newValue, _min, _max); if (result != newValue) { _onRangeClamped.Dispatch(this, result, newValue); } return(result); }
public override float OnUpdated(float newValue) { float result = Mathf.Clamp(newValue, _min, _max); if (result != newValue) { _onRangeClamped.Dispatch(this, result, newValue); } return(result); }
public TData this[int index] { get { return(_runtimeSet[index]); } set { // Auto-bound SmartRefs get bound first time value added/removed after they're queued if (_binder.hasRefsToBind) { _binder.AutoBind(); } var data = new SetEventData <TData>(value, _runtimeSet[index], SetOperation.CHANGED, index); if (_hasDecorators) { var temp = data; temp = ExecuteDecoratorsOnChanged(temp); data = temp; value = temp.value; } _runtimeSet[index] = value; _relay.Dispatch(data); } }
public void EndTurn() { //SaveVision(); if (selectedObject) { selectedObject.Unselect(); } currentPlayer++; if (currentPlayer >= players.Length) { currentPlayer = 0; } //LoadVision(); turnDisplay.text = "PLAYER " + CastleTools.NumberWords(currentPlayer + 1); endTurn.Dispatch(); }
/// <summary> /// Force a dispatch if value object doesn't change, e.g. when changing an element from a List. /// </summary> public void Dispatch() { _relay.Dispatch(value); }
/// <summary> Fire event. </summary> public void Dispatch() { _relay.Dispatch(); }
static void CallRelay(Relay <int, float, string> rly) { sw.Start(); rly.Dispatch(0, 1, "TEST"); sw.Stop(); }
/// <summary> /// Intercepts SmartRef calls to SmartObjects to animate graph. /// </summary> /// <param name="r">Writer ref caller.</param> /// <param name="smart">Direct callee. May be a Multi.</param> /// <param name="leaf">Final callee. If Multi, this will be the Var element.</param> public static void OnRefCallToSmart(SmartRefBase r, SmartBindableBase smart, SmartBindableBase leaf=null){ if (graphIsOpen){ _onRefCallToSmart.Dispatch(r, smart, leaf); } }