public static IReadOnlyEventField <B> Watch <T, B> (this IReadOnlyEventField <T> field, Func <T, IReadOnlyEventField <B> > chain) { var watcher = new EventField <B> (); field.Handlers[watcher].Add(new EventFieldChainHandler <T, B> (field, watcher, chain)); return(watcher); }
public EventFieldChainHandler(IReadOnlyEventField <T> source, IEventField <B> target, Func <T, IReadOnlyEventField <B> > chain) { SourceField = source; TargetField = target; Chain = chain; ChainedField = Chain(SourceField.Value); }
public void OnAfterChanged() { ChainedField = Chain(SourceField.Value); if (ChainedField == null) { TargetField.Value = default(B); return; } ChainedField.Handlers[this].Add(new EventFieldMirrorHandler <B> (ChainedField, TargetField)); TargetField.Value = ChainedField.Value; }
void IHandlerUsedCallback.OnUse(IReadOnlyEventField field) { if (field == null) { throw new ArgumentNullException(nameof(field), $"{nameof(field)} is null"); } if (eventField != null) { throw new InvalidOperationException($"Event handler of type {GetType()} cannot be used on multiple EventFields."); } if (field is IReadOnlyEventField <TValue> castedField) { eventField = castedField; } else { throw new InvalidOperationException($"Event handler for type {typeof(TValue)} cannot be used on event field of type {field.GetType()}."); } }
public void StartMirroring(IReadOnlyEventField <T> target) { Connection.StartMirroring(target); }
public AddToListEventHandler(IReadOnlyEventField <T> source, List <T> target) { this.source = source; this.target = target; }
public EventFieldMirrorHandler(IReadOnlyEventField <T> source, IEventField <T> target) { SourceField = source; Target = target; }
public StatModifier(StatModificationPhase phase, StatModificationType type, IReadOnlyEventField <float> currentValue) { Phase = phase; Type = type; CurrentValue = currentValue ?? throw new ArgumentNullException(nameof(currentValue)); }
public ContextWrapped(IReadOnlyEventField field, object context) { this.field = field; this.context = context; }