protected sealed override UniTask OnExecute() { if (!Application.isPlaying) { return(UniTask.CompletedTask); } _isStateActive = false; _state = new RxStateProxy <IContext>(this, this, this, this); _inputPort = GetPortValue(nameof(input)); LifeTime.AddCleanUpAction(StopState); LogNodeExecutionState(); //get all actual stat tokens and try to run state _inputPort.Receive <IStateToken>() .Where(x => !_isStateActive) .Select(x => (token: x, owned: OwnToken(x))) .Where(x => x.owned) .Do(x => OnActivateState(x.token)) .Subscribe() .AddTo(LifeTime); return(UniTask.CompletedTask); }
protected override void OnInitialize() { base.OnInitialize(); inputPort = this.UpdatePortValue(nameof(input), PortIO.Input); outputPort = this.UpdatePortValue(nameof(output), PortIO.Output); inputPort.Broadcast(outputPort).AddTo(LifeTime); }
protected sealed override UniTask OnExecute() { if (!Application.isPlaying) { return(UniTask.CompletedTask); } _isStateActive = false; _asyncStateProxy = new AsyncContextStateProxy(this, this, this, this); _inputPort = GetPortValue(nameof(input)); LifeTime.AddCleanUpAction(async() => await _asyncStateProxy.ExitAsync() .AttachExternalCancellation(LifeTime.TokenSource)); LogNodeExecutionState(); //get all actual stat tokens and try to run state _inputPort.Receive <IStateToken>() .Where(x => _isStateActive == false) .Select(async x => await OwnToken(x)) .Subscribe() .AddTo(LifeTime); return(UniTask.CompletedTask); }
public void ShowPortContextValues(IPortValue port) { ContextContentWindow.Open(new ContextDescription() { Data = port, Label = port.ItemName }); }
public NodeDataActionCommand( IPortValue port, Action onAddData, Action onRemove = null) { this.port = port; this.onAddData = onAddData; this.onRemove = onRemove; }
public static void UpdateSerializedCommands(INode node, IPortValue port, object value) { switch (value) { case IReactiveSource reactiveSource: reactiveSource.Bind(node, port.ItemName); return; } }
public void Initialize(IUniNode node, string input, string output, bool connect = true) { var ports = node.CreatePortPair(input, output, connect); inputPort = ports.inputValue; outputPort = ports.outputValue; }
protected override void UpdateCommands(List <ILifeTimeCommand> nodeCommands) { base.UpdateCommands(nodeCommands); var portPairCommand = new ConnectedFormatedPairCommand(this, portName, bindInOut); input = portPairCommand.InputPort; output = portPairCommand.OutputPort; nodeCommands.Add(portPairCommand); }
protected override void UpdateCommands(List <ILifeTimeCommand> nodeCommands) { base.UpdateCommands(nodeCommands); portPairCommand = new ConnectedFormatedPairCommand(this, "data", bindInOut); PortValue = Direction == PortIO.Input ? portPairCommand.InputPort : portPairCommand.OutputPort; nodeCommands.Add(portPairCommand); }
public ConnectedFormatedPairCommand( IUniNode node, string input, bool connect = true) { var inputName = input.GetFormatedPortName(PortIO.Input); var outputName = input.GetFormatedPortName(PortIO.Output); var ports = node.CreatePortPair(inputName, outputName, connect); InputPort = ports.inputValue; OutputPort = ports.outputValue; }
protected override void UpdateCommands(List <ILifeTimeCommand> nodeCommands) { base.UpdateCommands(nodeCommands); var portCommand = new ConnectedFormatedPairCommand(this, DefaultPortName, true); nodeCommands.Add(portCommand); PortPair = portCommand; inputPort = portCommand.InputPort; outputPort = portCommand.OutputPort; }
protected sealed override void UpdateCommands(List <ILifeTimeCommand> nodeCommands) { base.UpdateCommands(nodeCommands); _valueData = new RecycleReactiveProperty <TData>().AddTo(LifeTime); _isReady = new RecycleReactiveProperty <bool>().AddTo(LifeTime); var inputName = portName.GetFormatedPortName(PortIO.Input); var outputName = portName.GetFormatedPortName(PortIO.Output); var bridgePorts = this.CreatePortPair(inputName, outputName, false); input = bridgePorts.inputValue; output = bridgePorts.outputValue; }
protected override void UpdateCommands(List <ILifeTimeCommand> nodeCommands) { base.UpdateCommands(nodeCommands); var command = new PortTypeDataBridgeCommand <TData>(this, portName, defaultValue, distinctInput); input = command.InputPort; output = command.OutputPort; valueSource = command; valueData = valueSource.Value; nodeCommands.Add(valueSource); }
public static void RegisterPortHandler <TValue>( this IUniNode node, IPortValue portValue, IObserver <TValue> observer, bool oneShot = false) { //subscribe to port value observable portValue.Receive <TValue>(). Finally(() => { //if node stoped or if (!oneShot || !node.IsActive) { return; } //resubscribe to port values node.RegisterPortHandler(portValue, observer, true); }). Subscribe(observer). //subscribe to port value changes AddTo(node.LifeTime); //stop all subscriptions when node deactivated }
protected override void UpdateCommands(List <ILifeTimeCommand> nodeCommands) { base.UpdateCommands(nodeCommands); _outputPortValue = this.UpdatePortValue(nameof(outputValue), PortIO.Input); }
protected override void OnInitialize() { base.OnInitialize(); outputPortValue = this.UpdatePortValue(OutputPortName, PortIO.Output); }
public PortActionCommand(Action <TTarget> action, IPortValue port) { this.action = action; this.port = port; }
protected override void UpdateCommands(List <ILifeTimeCommand> nodeCommands) { base.UpdateCommands(nodeCommands); logPort = this.UpdatePortValue(logPortName, PortIO.Input); }
public PortValueTransferDelayCommand(IPortValue input, IPortValue output, float delay) { this.delay = delay; transferCommand = new PortValuePreTransferCommand(DelayAction, input, input, output); }