protected T GetUserContextData <T>(BtWorkingData workData) where T : class, new() { BtActionLeafContext actionLeafContext = GetContext <BtActionLeafContext>(workData); T t = actionLeafContext.GetUserData <T>(); return(t); }
protected override void OnTransition(BtWorkingData workData) { BtActionLeafContext leafContext = GetContext <BtActionLeafContext>(workData); if (leafContext._needExit) { OnExit(workData, BtRunningStatus.TRANSITION); } leafContext.ResetData(); }
protected override int OnUpdate(BtWorkingData workData) { int runningState = BtRunningStatus.FINISHED; BtActionLeafContext leafContext = GetContext <BtActionLeafContext>(workData); int currStatus = leafContext._status; if (currStatus == ACTION_READY) { OnEnter(workData); leafContext.OnEnter(); } if (currStatus == ACTION_RUNNING) { runningState = OnExecute(workData); if (BtRunningStatus.IsFinished(runningState)) { leafContext.OnFinish(); } } if (currStatus == ACTION_FINISHED) { if (leafContext._needExit) { OnExit(workData, runningState); } else { LogManager.Error("节点退出错误,[{0}]", TbName); } leafContext.OnExit(); } return(runningState); }