Exemplo n.º 1
0
        private void BindConnections(IUniNode node, INodePort sourcePort, IContext publisher)
        {
            //data source connections allowed only for input ports
            if (sourcePort.Direction != PortIO.Input)
            {
                return;
            }

            var connections = sourcePort.Connections;

            for (var i = 0; i < connections.Count; i++)
            {
                var connection = connections[i];
                var port       = connection.Port;
                if (port == null || port.Direction == PortIO.Input || port.NodeId == Id)
                {
                    continue;
                }

                var disposable = port.Broadcast(publisher).
                                 AddTo(LifeTime);

                LifeTime.AddDispose(disposable);
            }
        }
 protected sealed override void OnExecute()
 {
     foreach (var reference in sources)
     {
         LifeTime.AddDispose(reference);
     }
 }
        protected override async UniTask OnExecute()
        {
            if (_localContextContainer == null)
            {
                return;
            }

            var localContextContainer = await _localContextContainer.LoadAssetTaskAsync(LifeTime);

            LifeTime.AddDispose(localContextContainer);
            localContextContainer.SetValue(_contextConnection);
        }
Exemplo n.º 4
0
        protected sealed override UniTask OnExecute()
        {
            LifeTime.AddDispose(_graphContext);
            LifeTime.AddCleanUpAction(() => _graphContext = new EntityContext());

            graphProcessor?.ExecuteAsync(this)
            .AttachExternalCancellation(LifeTime.TokenSource)
            .Forget();

            LoadDataSources()
            .AttachExternalCancellation(LifeTime.TokenSource)
            .Forget();

            return(UniTask.CompletedTask);
        }
Exemplo n.º 5
0
        public void Execute()
        {
            if (IsActive || _behaviour == null)
            {
                return;
            }

            IsActive = true;

            //activate state
            var routine        = _behaviour.Execute(_entity);
            var disposableItem = routine.RunWithSubRoutines();

            //add lifetime cleanup actions
            LifeTime.AddDispose(disposableItem);
            LifeTime.AddCleanUpAction(_behaviour.Exit);
        }
Exemplo n.º 6
0
        protected override void UpdateCommands(List <ILifeTimeCommand> nodeCommands)
        {
            base.UpdateCommands(nodeCommands);

            _context ??= new EntityContext();
            LifeTime.AddDispose(_context);

            var port          = UniTask.FromResult <IContext>(PortPair.OutputPort);
            var contextSource = UniTask.FromResult <IContext>(_context);

            var bindContextToOutput = new MessageBroadcastCommand(_context, PortPair.OutputPort);
            //register all Context Sources Data into target context asset
            var registerDataSourceIntoContext = new RegisterDataSourceCommand(contextSource, dataSources);
            //Register context to output port
            var contextToOutputPortCommand = new DataSourceTaskCommand <IContext>(contextSource, port);

            nodeCommands.Add(bindContextToOutput);
            nodeCommands.Add(registerDataSourceIntoContext);
            nodeCommands.Add(contextToOutputPortCommand);
        }
Exemplo n.º 7
0
        private IStateToken CreateToken()
        {
            if (_token != null)
            {
                return(_token);
            }

            _token = new FlowStateToken()
                     .AddTo(TokenLifeTime);

            if (connectWithGrphContext)
            {
                _token.Context
                .Connect(this.Context)
                .AddTo(_token.LifeTime);
            }

            LifeTime.AddDispose(_token);
            LifeTime.AddCleanUpAction(() => _token = null);

            return(_token);
        }
Exemplo n.º 8
0
 protected sealed override void OnExecute()
 {
     //unload all source addressables
     LifeTime.AddDispose(contextAsset);
     LifeTime.AddDispose(contextDataSources);
 }