Esempio n. 1
0
        public void Reinitialize()
        {
            //TODO: Change to runner extension
            Runner = BehaviorTreeFile.LoadFromJSON(this);

            if (spliceNewIntoTree)
            {
                SpliceIntoRunner();
            }

            TreeElementUtility.TreeToList(Runner, treeList);

            var treeQuery = treeList.AsEnumerable();

            TreeSubject = new Subject <BehaviorTreeElement>();
            TreeSubject.Subscribe(xr =>
            {
                var logEntry = new BehaviorLogEntry(
                    loggerName: BehaviorLogger.Name,
                    logType: LogType.Log,
                    timestamp: DateTime.Now,
                    message: "Ticked!",
                    behaviorID: xr.ID,
                    newState: xr.CurrentState,
                    ticknum: xr.NumberOfTicksReceived.Value,
                    context: this,
                    state: xr);
                BehaviorLogger.Raw(logEntry);
                Debug.Log("xr debug initialize");
            }).AddTo(this);

            initialized = true;
        }
        public void Reinitialize()
        {
            //TODO: Change to runner extension
            Runner = BehaviorTreeFile.LoadFromJSON(this);

            if (spliceNewIntoTree)
            {
                SpliceIntoRunner();
            }

            List <BehaviorTreeElement> treeList = new List <BehaviorTreeElement>();

            TreeElementUtility.TreeToList(Runner, treeList);

            var treeQuery = from el in treeList
                            select el;

            TreeStream =
                treeQuery
                .ToObservable()
                .Do(xr =>
            {
                xr.ObserveEveryValueChanged(x => x.NumberOfTicksReceived)
                .Do(x =>
                {
                    var logEntry = new BehaviorLogEntry(
                        loggerName: BehaviorLogger.Name,
                        logType: LogType.Log,
                        timestamp: DateTime.Now,
                        message: "Ticked!",
                        behaviorID: xr.ID,
                        newState: xr.CurrentState,
                        ticknum: xr.NumberOfTicksReceived.Value,
                        context: this,
                        state: xr);
                    BehaviorLogger.Raw(logEntry);
                })

                .Subscribe()
                .AddTo(this);
            });

            TreeStream.Subscribe().AddTo(this);

            initialized = true;
        }