public override MyBehaviorTreeState Tick(IMyBot bot, MyPerTreeBotMemory botTreeMemory) { MyBehaviorTreeDecoratorNodeMemory nodeMemoryByIndex = botTreeMemory.GetNodeMemoryByIndex(base.MemoryIndex) as MyBehaviorTreeDecoratorNodeMemory; if (this.m_child != null) { if (nodeMemoryByIndex.ChildState == MyBehaviorTreeState.RUNNING) { return(this.TickChild(bot, botTreeMemory, nodeMemoryByIndex)); } this.m_decoratorLogic.Update(nodeMemoryByIndex.DecoratorLogicMemory); if (this.m_decoratorLogic.CanRun(nodeMemoryByIndex.DecoratorLogicMemory)) { return(this.TickChild(bot, botTreeMemory, nodeMemoryByIndex)); } if (this.IsRunningStateSource) { bot.BotMemory.ProcessLastRunningNode(this); } botTreeMemory.GetNodeMemoryByIndex(base.MemoryIndex).NodeState = this.m_defaultReturnValue; if (MyDebugDrawSettings.DEBUG_DRAW_BOTS && (this.m_defaultReturnValue == MyBehaviorTreeState.RUNNING)) { base.m_runningActionName = "Par_N" + this.m_decoratorLogicName; } } return(this.m_defaultReturnValue); }
public override MyBehaviorTreeNodeMemory GetNewMemoryObject() { MyBehaviorTreeDecoratorNodeMemory newMemoryObject = base.GetNewMemoryObject() as MyBehaviorTreeDecoratorNodeMemory; newMemoryObject.DecoratorLogicMemory = this.m_decoratorLogic.GetNewMemoryObject(); return(newMemoryObject); }
public void Update(MyBehaviorTreeDecoratorNodeMemory.LogicMemory logicMemory) { var memory = logicMemory as MyBehaviorTreeDecoratorNodeMemory.CounterLogicMemory; if (memory.CurrentCount == CounterLimit) memory.CurrentCount = 0; else ++memory.CurrentCount; }
public void Update(MyBehaviorTreeDecoratorNodeMemory.LogicMemory logicMemory) { var memory = logicMemory as MyBehaviorTreeDecoratorNodeMemory.TimerLogicMemory; if (((Stopwatch.GetTimestamp() - memory.CurrentTime) / Stopwatch.Frequency) * 1000 > TimeInMs) { memory.CurrentTime = Stopwatch.GetTimestamp(); memory.TimeLimitReached = true; } else memory.TimeLimitReached = false; }
private MyBehaviorTreeState TickChild(IMyBot bot, MyPerTreeBotMemory botTreeMemory, MyBehaviorTreeDecoratorNodeMemory thisMemory) { bot.BotMemory.RememberNode(m_child.MemoryIndex); var state = m_child.Tick(bot, botTreeMemory); thisMemory.NodeState = state; thisMemory.ChildState = state; if (state != MyBehaviorTreeState.RUNNING) { bot.BotMemory.ForgetNode(); } return state; }
public override void PostTick(IMyBot bot, MyPerTreeBotMemory botTreeMemory) { base.PostTick(bot, botTreeMemory); MyBehaviorTreeDecoratorNodeMemory nodeMemoryByIndex = botTreeMemory.GetNodeMemoryByIndex(base.MemoryIndex) as MyBehaviorTreeDecoratorNodeMemory; if (nodeMemoryByIndex.ChildState == MyBehaviorTreeState.NOT_TICKED) { if (this.IsRunningStateSource) { nodeMemoryByIndex.PostTickMemory(); } } else { nodeMemoryByIndex.PostTickMemory(); if (this.m_child != null) { this.m_child.PostTick(bot, botTreeMemory); } } }
public bool CanRun(MyBehaviorTreeDecoratorNodeMemory.LogicMemory logicMemory) { var memory = logicMemory as MyBehaviorTreeDecoratorNodeMemory.CounterLogicMemory; return memory.CurrentCount == CounterLimit; }
private MyBehaviorTreeState TickChild(IMyBot bot, MyPerTreeBotMemory botTreeMemory, MyBehaviorTreeDecoratorNodeMemory thisMemory) { bot.BotMemory.RememberNode(m_child.MemoryIndex); var state = m_child.Tick(bot, botTreeMemory); thisMemory.NodeState = state; thisMemory.ChildState = state; if (state != MyBehaviorTreeState.RUNNING) { bot.BotMemory.ForgetNode(); } return(state); }
public bool CanRun(MyBehaviorTreeDecoratorNodeMemory.LogicMemory logicMemory) { var memory = logicMemory as MyBehaviorTreeDecoratorNodeMemory.TimerLogicMemory; return memory.TimeLimitReached; }