<?xml version="1.0" encoding="utf-8" ?>
<ThinkTrees>

	<ThinkTreeDef>
		<defName>Humanoid</defName>
		<thinkRoot Class="ThinkNode_Priority">
			<subNodes>

				<!-- Burning response -->
				<li Class="ThinkNode_Subtree">
					<treeDef>BurningResponse</treeDef>
				</li>
        
        <!-- Mind broken - psychotic -->
				<li Class="ThinkNode_Subtree">
					<treeDef>Psychotic</treeDef>
				</li>

				<!-- Self-defense only if not drafted -->
				<li Class="ThinkNode_ConditionalNotDrafted">
					<subNodes>
						<li Class="ThinkNode_Subtree">
							<treeDef>SelfDefense</treeDef>
						</li>
					</subNodes>
				</li>


				<!-- Mind broken - Give up and leave -->
				<li Class="ThinkNode_ConditionalSanityState">
					<sanityState>GiveUpExit</sanityState>
					<subNodes>
						<li Class="JobGiver_ExitMapWalkRandom" />
					</subNodes>
				</li>

				<!-- Mind broken - Panic flee -->
				<li Class="ThinkNode_ConditionalSanityState">
					<sanityState>PanicFlee</sanityState>
					<subNodes>
						<li Class="JobGiver_PanicFlee" />
					</subNodes>
				</li>

				<!-- Mind broken - Wander -->
				<li Class="ThinkNode_ConditionalSanityState">
					<sanityState>DazedWander</sanityState>
					<subNodes>
						<li Class="JobGiver_WanderAnywhere" />
					</subNodes>
				</li>

        <!-- Insertion hook for modders -->
        <li Class="ThinkNode_SubtreesByTag">
          <insertTag>Humanoid_PostBroken</insertTag>
        </li>
        
				<!-- Prisoner -->
				<li Class="ThinkNode_ConditionalPrisoner">
					<subNodes>
						<li Class="JobGiver_PrisonerEscape" />
						<li Class="ThinkNode_SatisfyNeeds" />
						<li Class="JobGiver_WanderCurrentRoom" />
						<li Class="JobGiver_IdleError" />
					</subNodes>
				</li>

				<!-- Squad brain directives -->
        <li Class="ThinkNode_Subtree">
          <treeDef>SquadBrainDuty</treeDef>
        </li>

        <!-- Insertion hook for modders -->
        <li Class="ThinkNode_SubtreesByTag">
          <insertTag>Humanoid_PostDuty</insertTag>
        </li>

        <!-- If on colonist team, do forced and emergency work -->
				<li Class="ThinkNode_ConditionalColonist">
					<subNodes>
						<!-- Take direct orders when drafted -->
						<li Class="JobGiver_Orders" />

						<!-- Queue for forced work -->
						<li Class="JobGiver_JobQueue" />

						<!-- Do emergency work (supercedes satisfying needs) -->
						<li Class="JobGiver_WorkRoot">
              <onlyEmergencyWork>true</onlyEmergencyWork>
          </li>
					</subNodes>
				</li>

        <!-- Insertion hook for modders -->
        <li Class="ThinkNode_SubtreesByTag">
          <insertTag>Humanoid_PreSatisfyNeeds</insertTag>
        </li>

        <!-- Basic satisfy needs -->
				<li Class="ThinkNode_SatisfyNeeds"/>

        <!-- Insertion hook for modders -->
        <li Class="ThinkNode_SubtreesByTag">
          <insertTag>Humanoid_PostSatisfyNeeds</insertTag>
        </li>

				<!-- If on colonist team, do non-forced non-emergency work and idle -->
				<li Class="ThinkNode_ConditionalColonist">
					<subNodes>
						<li Class="JobGiver_WorkRoot">
							<onlyEmergencyWork>false</onlyEmergencyWork>
						</li>

						<li Class="ThinkNode_Tagger">
							<tagToGive>Idle</tagToGive>
							<subNodes>
								<li Class="JobGiver_WanderColony">
								</li>
							</subNodes>
						</li>

					</subNodes>
				</li>

        <!-- Insertion hook for modders -->
        <li Class="ThinkNode_SubtreesByTag">
          <insertTag>Humanoid_PreWander</insertTag>
        </li>

        <li Class="JobGiver_WanderAnywhere" />

				<li Class="JobGiver_IdleError"/>

			</subNodes>
		</thinkRoot>
	</ThinkTreeDef>
</ThinkTrees>