39_CrowdNavigation.as 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. // CrowdNavigation example.
  2. // This sample demonstrates:
  3. // - Generating a dynamic navigation mesh into the scene
  4. // - Performing path queries to the navigation mesh
  5. // - Adding and removing obstacles/agents at runtime
  6. // - Raycasting drawable components
  7. // - Crowd movement management
  8. // - Accessing crowd agents with the crowd manager
  9. // - Using off-mesh connections to make boxes climbable
  10. // - Using agents to simulate moving obstacles
  11. #include "Scripts/Utilities/Sample.as"
  12. const String INSTRUCTION("instructionText");
  13. void Start()
  14. {
  15. // Execute the common startup for samples
  16. SampleStart();
  17. // Create the scene content
  18. CreateScene();
  19. // Create the UI content
  20. CreateUI();
  21. // Setup the viewport for displaying the scene
  22. SetupViewport();
  23. // Hook up to the frame update and render post-update events
  24. SubscribeToEvents();
  25. }
  26. void CreateScene()
  27. {
  28. scene_ = Scene();
  29. // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
  30. // Also create a DebugRenderer component so that we can draw debug geometry
  31. scene_.CreateComponent("Octree");
  32. scene_.CreateComponent("DebugRenderer");
  33. // Create scene node & StaticModel component for showing a static plane
  34. Node@ planeNode = scene_.CreateChild("Plane");
  35. planeNode.scale = Vector3(100.0f, 1.0f, 100.0f);
  36. StaticModel@ planeObject = planeNode.CreateComponent("StaticModel");
  37. planeObject.model = cache.GetResource("Model", "Models/Plane.mdl");
  38. planeObject.material = cache.GetResource("Material", "Materials/StoneTiled.xml");
  39. // Create a Zone component for ambient lighting & fog control
  40. Node@ zoneNode = scene_.CreateChild("Zone");
  41. Zone@ zone = zoneNode.CreateComponent("Zone");
  42. zone.boundingBox = BoundingBox(-1000.0f, 1000.0f);
  43. zone.ambientColor = Color(0.15f, 0.15f, 0.15f);
  44. zone.fogColor = Color(0.5f, 0.5f, 0.7f);
  45. zone.fogStart = 100.0f;
  46. zone.fogEnd = 300.0f;
  47. // Create a directional light to the world. Enable cascaded shadows on it
  48. Node@ lightNode = scene_.CreateChild("DirectionalLight");
  49. lightNode.direction = Vector3(0.6f, -1.0f, 0.8f);
  50. Light@ light = lightNode.CreateComponent("Light");
  51. light.lightType = LIGHT_DIRECTIONAL;
  52. light.castShadows = true;
  53. light.shadowBias = BiasParameters(0.00025f, 0.5f);
  54. // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
  55. light.shadowCascade = CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);
  56. // Create randomly sized boxes. If boxes are big enough, make them occluders. Occluders will be software rasterized before
  57. // rendering to a low-resolution depth-only buffer to test the objects in the view frustum for visibility
  58. Node@ boxGroup = scene_.CreateChild("Boxes");
  59. for (uint i = 0; i < 20; ++i)
  60. {
  61. Node@ boxNode = boxGroup.CreateChild("Box");
  62. float size = 1.0f + Random(10.0f);
  63. boxNode.position = Vector3(Random(80.0f) - 40.0f, size * 0.5f, Random(80.0f) - 40.0f);
  64. boxNode.SetScale(size);
  65. StaticModel@ boxObject = boxNode.CreateComponent("StaticModel");
  66. boxObject.model = cache.GetResource("Model", "Models/Box.mdl");
  67. boxObject.material = cache.GetResource("Material", "Materials/Stone.xml");
  68. boxObject.castShadows = true;
  69. if (size >= 3.0f)
  70. boxObject.occluder = true;
  71. }
  72. // Create a DynamicNavigationMesh component to the scene root
  73. DynamicNavigationMesh@ navMesh = scene_.CreateComponent("DynamicNavigationMesh");
  74. // Enable drawing debug geometry for obstacles and off-mesh connections
  75. navMesh.drawObstacles = true;
  76. navMesh.drawOffMeshConnections = true;
  77. // Set the agent height large enough to exclude the layers under boxes
  78. navMesh.agentHeight = 10;
  79. // Set nav mesh cell height to minimum (allows agents to be grounded)
  80. navMesh.cellHeight = 0.05f;
  81. // Create a Navigable component to the scene root. This tags all of the geometry in the scene as being part of the
  82. // navigation mesh. By default this is recursive, but the recursion could be turned off from Navigable
  83. scene_.CreateComponent("Navigable");
  84. // Add padding to the navigation mesh in Y-direction so that we can add objects on top of the tallest boxes
  85. // in the scene and still update the mesh correctly
  86. navMesh.padding = Vector3(0.0f, 10.0f, 0.0f);
  87. // Now build the navigation geometry. This will take some time. Note that the navigation mesh will prefer to use
  88. // physics geometry from the scene nodes, as it often is simpler, but if it can not find any (like in this example)
  89. // it will use renderable geometry instead
  90. navMesh.Build();
  91. // Create an off-mesh connection to each box to make it climbable (tiny boxes are skipped). A connection is built from 2 nodes.
  92. // Note that OffMeshConnections must be added before building the navMesh, but as we are adding Obstacles next, tiles will be automatically rebuilt.
  93. // Creating connections post-build here allows us to use FindNearestPoint() to procedurally set accurate positions for the connection
  94. CreateBoxOffMeshConnections(navMesh, boxGroup);
  95. // Create some mushrooms as obstacles. Note that obstacles are non-walkable areas
  96. for (uint i = 0; i < 100; ++i)
  97. CreateMushroom(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
  98. // Create a DetourCrowdManager component to the scene root (mandatory for crowd agents)
  99. scene_.CreateComponent("DetourCrowdManager");
  100. // Create some movable barrels. We create them as crowd agents, as for moving entities it is less expensive and more convenient than using obstacles
  101. CreateMovingBarrels(navMesh);
  102. // Create Jack node as crowd agent
  103. SpawnJack(Vector3(-5.0f, 0, 20.0f));
  104. // Create the camera. Limit far clip distance to match the fog. Note: now we actually create the camera node outside
  105. // the scene, because we want it to be unaffected by scene load / save
  106. cameraNode = Node();
  107. Camera@ camera = cameraNode.CreateComponent("Camera");
  108. camera.farClip = 300.0f;
  109. // Set an initial position for the camera scene node above the plane and looking down
  110. cameraNode.position = Vector3(0.0f, 50.0f, 0.0f);
  111. pitch = 80.0f;
  112. cameraNode.rotation = Quaternion(pitch, yaw, 0.0f);
  113. }
  114. void CreateUI()
  115. {
  116. // Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will
  117. // control the camera, and when visible, it will point the raycast target
  118. XMLFile@ style = cache.GetResource("XMLFile", "UI/DefaultStyle.xml");
  119. Cursor@ cursor = Cursor();
  120. cursor.SetStyleAuto(style);
  121. ui.cursor = cursor;
  122. // Set starting position of the cursor at the rendering window center
  123. cursor.SetPosition(graphics.width / 2, graphics.height / 2);
  124. // Construct new Text object, set string to display and font to use
  125. Text@ instructionText = ui.root.CreateChild("Text", INSTRUCTION);
  126. instructionText.text =
  127. "Use WASD keys to move, RMB to rotate view\n"
  128. "LMB to set destination, SHIFT+LMB to spawn a Jack\n"
  129. "CTRL+LMB to teleport main agent\n"
  130. "MMB to add obstacles or remove obstacles/agents\n"
  131. "F5 to save scene, F7 to load\n"
  132. "Space to toggle debug geometry\n"
  133. "F12 to toggle this instruction text";
  134. instructionText.SetFont(cache.GetResource("Font", "Fonts/Anonymous Pro.ttf"), 15);
  135. // The text has multiple rows. Center them in relation to each other
  136. instructionText.textAlignment = HA_CENTER;
  137. // Position the text relative to the screen center
  138. instructionText.horizontalAlignment = HA_CENTER;
  139. instructionText.verticalAlignment = VA_CENTER;
  140. instructionText.SetPosition(0, ui.root.height / 4);
  141. }
  142. void SetupViewport()
  143. {
  144. // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
  145. Viewport@ viewport = Viewport(scene_, cameraNode.GetComponent("Camera"));
  146. renderer.viewports[0] = viewport;
  147. }
  148. void SubscribeToEvents()
  149. {
  150. // Subscribe HandleUpdate() function for processing update events
  151. SubscribeToEvent("Update", "HandleUpdate");
  152. // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request debug geometry
  153. SubscribeToEvent("PostRenderUpdate", "HandlePostRenderUpdate");
  154. // Subscribe HandleCrowdAgentFailure() function for resolving invalidation issues with agents, during which we
  155. // use a larger extents for finding a point on the navmesh to fix the agent's position
  156. SubscribeToEvent("CrowdAgentFailure", "HandleCrowdAgentFailure");
  157. // Subscribe HandleCrowdAgentReposition() function for controlling the animation
  158. SubscribeToEvent("CrowdAgentReposition", "HandleCrowdAgentReposition");
  159. }
  160. void CreateMushroom(const Vector3& pos)
  161. {
  162. Node@ mushroomNode = scene_.CreateChild("Mushroom");
  163. mushroomNode.position = pos;
  164. mushroomNode.rotation = Quaternion(0.0f, Random(360.0f), 0.0f);
  165. mushroomNode.SetScale(2.0f + Random(0.5f));
  166. StaticModel@ mushroomObject = mushroomNode.CreateComponent("StaticModel");
  167. mushroomObject.model = cache.GetResource("Model", "Models/Mushroom.mdl");
  168. mushroomObject.material = cache.GetResource("Material", "Materials/Mushroom.xml");
  169. mushroomObject.castShadows = true;
  170. // Create the navigation Obstacle component and set its height & radius proportional to scale
  171. Obstacle@ obstacle = mushroomNode.CreateComponent("Obstacle");
  172. obstacle.radius = mushroomNode.scale.x;
  173. obstacle.height = mushroomNode.scale.y;
  174. }
  175. void SpawnJack(const Vector3& pos)
  176. {
  177. Node@ jackNode = scene_.CreateChild("Jack");
  178. jackNode.position = pos;
  179. AnimatedModel@ modelObject = jackNode.CreateComponent("AnimatedModel");
  180. modelObject.model = cache.GetResource("Model", "Models/Jack.mdl");
  181. modelObject.material = cache.GetResource("Material", "Materials/Jack.xml");
  182. modelObject.castShadows = true;
  183. jackNode.CreateComponent("AnimationController");
  184. // Create a CrowdAgent component and set its height and realistic max speed/acceleration. Use default radius
  185. CrowdAgent@ agent = jackNode.CreateComponent("CrowdAgent");
  186. agent.height = 2.0f;
  187. agent.maxSpeed = 3.0f;
  188. agent.maxAccel = 3.0f;
  189. }
  190. void CreateBoxOffMeshConnections(DynamicNavigationMesh@ navMesh, Node@ boxGroup)
  191. {
  192. Array<Node@>@ boxes = boxGroup.GetChildren();
  193. for (uint i=0; i < boxes.length; ++i)
  194. {
  195. Node@ box = boxes[i];
  196. Vector3 boxPos = box.position;
  197. float boxHalfSize = box.scale.x / 2;
  198. // Create 2 empty nodes for the start & end points of the connection. Note that order matters only when using one-way/unidirectional connection.
  199. Node@ connectionStart = box.CreateChild("ConnectionStart");
  200. connectionStart.worldPosition = navMesh.FindNearestPoint(boxPos + Vector3(boxHalfSize, -boxHalfSize, 0)); // Base of box
  201. Node@ connectionEnd = connectionStart.CreateChild("ConnectionEnd");
  202. connectionEnd.worldPosition = navMesh.FindNearestPoint(boxPos + Vector3(boxHalfSize, boxHalfSize, 0)); // Top of box
  203. // Create the OffMeshConnection component to one node and link the other node
  204. OffMeshConnection@ connection = connectionStart.CreateComponent("OffMeshConnection");
  205. connection.endPoint = connectionEnd;
  206. }
  207. }
  208. void CreateMovingBarrels(DynamicNavigationMesh@ navMesh)
  209. {
  210. Node@ barrel = scene_.CreateChild("Barrel");
  211. StaticModel@ model = barrel.CreateComponent("StaticModel");
  212. model.model = cache.GetResource("Model", "Models/Cylinder.mdl");
  213. Material@ material = cache.GetResource("Material", "Materials/StoneTiled.xml");
  214. model.material = material;
  215. material.textures[TU_DIFFUSE] = cache.GetResource("Texture2D", "Textures/TerrainDetail2.dds");
  216. model.castShadows = true;
  217. for (uint i = 0; i < 20; ++i)
  218. {
  219. Node@ clone = barrel.Clone();
  220. float size = 0.5 + Random(1);
  221. clone.scale = Vector3(size / 1.5, size * 2.0, size / 1.5);
  222. clone.position = navMesh.FindNearestPoint(Vector3(Random(80.0) - 40.0, size * 0.5 , Random(80.0) - 40.0));
  223. CrowdAgent@ agent = clone.CreateComponent("CrowdAgent");
  224. agent.radius = clone.scale.x * 0.5f;
  225. agent.height = size;
  226. }
  227. barrel.Remove();
  228. }
  229. void SetPathPoint(bool spawning)
  230. {
  231. Vector3 hitPos;
  232. Drawable@ hitDrawable;
  233. if (Raycast(250.0f, hitPos, hitDrawable))
  234. {
  235. DynamicNavigationMesh@ navMesh = scene_.GetComponent("DynamicNavigationMesh");
  236. Vector3 pathPos = navMesh.FindNearestPoint(hitPos, Vector3(1.0f, 1.0f, 1.0f));
  237. if (spawning)
  238. // Spawn a jack at the target position
  239. SpawnJack(pathPos);
  240. else
  241. // Set crowd agents target position
  242. cast<DetourCrowdManager>(scene_.GetComponent("DetourCrowdManager")).SetCrowdTarget(pathPos);
  243. }
  244. }
  245. void AddOrRemoveObject()
  246. {
  247. // Raycast and check if we hit a mushroom node. If yes, remove it, if no, create a new one
  248. Vector3 hitPos;
  249. Drawable@ hitDrawable;
  250. if (Raycast(250.0f, hitPos, hitDrawable))
  251. {
  252. Node@ hitNode = hitDrawable.node;
  253. // Note that navmesh rebuild happens when the Obstacle component is removed
  254. if (hitNode.name == "Mushroom")
  255. hitNode.Remove();
  256. else if (hitNode.name == "Jack")
  257. hitNode.Remove();
  258. else
  259. CreateMushroom(hitPos);
  260. }
  261. }
  262. bool Raycast(float maxDistance, Vector3& hitPos, Drawable@& hitDrawable)
  263. {
  264. hitDrawable = null;
  265. IntVector2 pos = ui.cursorPosition;
  266. // Check the cursor is visible and there is no UI element in front of the cursor
  267. if (!ui.cursor.visible || ui.GetElementAt(pos, true) !is null)
  268. return false;
  269. Camera@ camera = cameraNode.GetComponent("Camera");
  270. Ray cameraRay = camera.GetScreenRay(float(pos.x) / graphics.width, float(pos.y) / graphics.height);
  271. // Pick only geometry objects, not eg. zones or lights, only get the first (closest) hit
  272. // Note the convenience accessor to scene's Octree component
  273. RayQueryResult result = scene_.octree.RaycastSingle(cameraRay, RAY_TRIANGLE, maxDistance, DRAWABLE_GEOMETRY);
  274. if (result.drawable !is null)
  275. {
  276. hitPos = result.position;
  277. hitDrawable = result.drawable;
  278. return true;
  279. }
  280. return false;
  281. }
  282. void MoveCamera(float timeStep)
  283. {
  284. // Right mouse button controls mouse cursor visibility: hide when pressed
  285. ui.cursor.visible = !input.mouseButtonDown[MOUSEB_RIGHT];
  286. // Do not move if the UI has a focused element (the console)
  287. if (ui.focusElement !is null)
  288. return;
  289. // Movement speed as world units per second
  290. const float MOVE_SPEED = 20.0f;
  291. // Mouse sensitivity as degrees per pixel
  292. const float MOUSE_SENSITIVITY = 0.1f;
  293. // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
  294. // Only move the camera when the cursor is hidden
  295. if (!ui.cursor.visible)
  296. {
  297. IntVector2 mouseMove = input.mouseMove;
  298. yaw += MOUSE_SENSITIVITY * mouseMove.x;
  299. pitch += MOUSE_SENSITIVITY * mouseMove.y;
  300. pitch = Clamp(pitch, -90.0f, 90.0f);
  301. // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
  302. cameraNode.rotation = Quaternion(pitch, yaw, 0.0f);
  303. }
  304. // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
  305. if (input.keyDown['W'])
  306. cameraNode.Translate(Vector3(0.0f, 0.0f, 1.0f) * MOVE_SPEED * timeStep);
  307. if (input.keyDown['S'])
  308. cameraNode.Translate(Vector3(0.0f, 0.0f, -1.0f) * MOVE_SPEED * timeStep);
  309. if (input.keyDown['A'])
  310. cameraNode.Translate(Vector3(-1.0f, 0.0f, 0.0f) * MOVE_SPEED * timeStep);
  311. if (input.keyDown['D'])
  312. cameraNode.Translate(Vector3(1.0f, 0.0f, 0.0f) * MOVE_SPEED * timeStep);
  313. // Set destination or spawn a jack with left mouse button
  314. if (input.mouseButtonPress[MOUSEB_LEFT])
  315. SetPathPoint(input.qualifierDown[QUAL_SHIFT]);
  316. // Add new obstacle or remove existing obstacle/agent with middle mouse button
  317. else if (input.mouseButtonPress[MOUSEB_MIDDLE])
  318. AddOrRemoveObject();
  319. // Check for loading/saving the scene from/to the file Data/Scenes/CrowdNavigation.xml relative to the executable directory
  320. if (input.keyPress[KEY_F5])
  321. {
  322. File saveFile(fileSystem.programDir + "Data/Scenes/CrowdNavigation.xml", FILE_WRITE);
  323. scene_.SaveXML(saveFile);
  324. }
  325. else if (input.keyPress[KEY_F7])
  326. {
  327. File loadFile(fileSystem.programDir + "Data/Scenes/CrowdNavigation.xml", FILE_READ);
  328. scene_.LoadXML(loadFile);
  329. }
  330. // Toggle debug geometry with space
  331. else if (input.keyPress[KEY_SPACE])
  332. drawDebug = !drawDebug;
  333. // Toggle instruction text with F12
  334. else if (input.keyPress[KEY_F12])
  335. {
  336. UIElement@ instruction = ui.root.GetChild(INSTRUCTION);
  337. instruction.visible = !instruction.visible;
  338. }
  339. }
  340. void HandleUpdate(StringHash eventType, VariantMap& eventData)
  341. {
  342. // Take the frame time step, which is stored as a float
  343. float timeStep = eventData["TimeStep"].GetFloat();
  344. // Move the camera, scale movement with time step
  345. MoveCamera(timeStep);
  346. }
  347. void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
  348. {
  349. if (drawDebug)
  350. {
  351. // Visualize navigation mesh, obstacles and off-mesh connections
  352. cast<DynamicNavigationMesh>(scene_.GetComponent("DynamicNavigationMesh")).DrawDebugGeometry(true);
  353. // Visualize agents' path and position to reach
  354. cast<DetourCrowdManager>(scene_.GetComponent("DetourCrowdManager")).DrawDebugGeometry(true);
  355. }
  356. }
  357. void HandleCrowdAgentFailure(StringHash eventType, VariantMap& eventData)
  358. {
  359. Node@ node = eventData["Node"].GetPtr();
  360. int state = eventData["CrowdAgentState"].GetInt();
  361. // If the agent's state is invalid, likely from spawning on the side of a box, find a point in a larger area
  362. if (state == CrowdAgentState::CROWD_AGENT_INVALID)
  363. {
  364. // Get a point on the navmesh using more generous extents
  365. Vector3 newPos = cast<DynamicNavigationMesh>(scene_.GetComponent("DynamicNavigationMesh")).FindNearestPoint(node.position, Vector3(5.0f,5.0f,5.0f));
  366. // Set the new node position, CrowdAgent component will automatically reset the state of the agent
  367. node.position = newPos;
  368. }
  369. }
  370. void HandleCrowdAgentReposition(StringHash eventType, VariantMap& eventData)
  371. {
  372. const String WALKING_ANI = "Models/Jack_Walk.ani";
  373. const Vector3 FORWARD(0.0f, 0.0f, 1.0f);
  374. Node@ node = eventData["Node"].GetPtr();
  375. CrowdAgent@ agent = eventData["CrowdAgent"].GetPtr();
  376. Vector3 velocity = eventData["Velocity"].GetVector3();
  377. // Only Jack agent has animation controller
  378. AnimationController@ animCtrl = node.GetComponent("AnimationController");
  379. if (animCtrl !is null)
  380. {
  381. float speed = velocity.length;
  382. if (animCtrl.IsPlaying(WALKING_ANI))
  383. {
  384. float speedRatio = speed / agent.maxSpeed;
  385. // Face the direction of its velocity but moderate the turning speed based on the speed ratio as we do not have timeStep here
  386. node.rotation = node.rotation.Slerp(Quaternion(FORWARD, velocity), 0.1f * speedRatio);
  387. // Throttle the animation speed based on agent speed ratio (ratio = 1 is full throttle)
  388. animCtrl.SetSpeed(WALKING_ANI, speedRatio);
  389. }
  390. else
  391. animCtrl.Play(WALKING_ANI, 0, true, 0.1f);
  392. // If speed is too low then stopping the animation
  393. if (speed < agent.radius)
  394. animCtrl.Stop(WALKING_ANI, 0.8f);
  395. }
  396. }
  397. // Create XML patch instructions for screen joystick layout specific to this sample app
  398. String patchInstructions =
  399. "<patch>" +
  400. " <add sel=\"/element\">" +
  401. " <element type=\"Button\">" +
  402. " <attribute name=\"Name\" value=\"Button3\" />" +
  403. " <attribute name=\"Position\" value=\"-120 -120\" />" +
  404. " <attribute name=\"Size\" value=\"96 96\" />" +
  405. " <attribute name=\"Horiz Alignment\" value=\"Right\" />" +
  406. " <attribute name=\"Vert Alignment\" value=\"Bottom\" />" +
  407. " <attribute name=\"Texture\" value=\"Texture2D;Textures/TouchInput.png\" />" +
  408. " <attribute name=\"Image Rect\" value=\"96 0 192 96\" />" +
  409. " <attribute name=\"Hover Image Offset\" value=\"0 0\" />" +
  410. " <attribute name=\"Pressed Image Offset\" value=\"0 0\" />" +
  411. " <element type=\"Text\">" +
  412. " <attribute name=\"Name\" value=\"Label\" />" +
  413. " <attribute name=\"Horiz Alignment\" value=\"Center\" />" +
  414. " <attribute name=\"Vert Alignment\" value=\"Center\" />" +
  415. " <attribute name=\"Color\" value=\"0 0 0 1\" />" +
  416. " <attribute name=\"Text\" value=\"Spawn A jack\" />" +
  417. " </element>" +
  418. " <element type=\"Text\">" +
  419. " <attribute name=\"Name\" value=\"KeyBinding\" />" +
  420. " <attribute name=\"Text\" value=\"LSHIFT\" />" +
  421. " </element>" +
  422. " <element type=\"Text\">" +
  423. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" +
  424. " <attribute name=\"Text\" value=\"LEFT\" />" +
  425. " </element>" +
  426. " </element>" +
  427. " <element type=\"Button\">" +
  428. " <attribute name=\"Name\" value=\"Button4\" />" +
  429. " <attribute name=\"Position\" value=\"-120 -12\" />" +
  430. " <attribute name=\"Size\" value=\"96 96\" />" +
  431. " <attribute name=\"Horiz Alignment\" value=\"Right\" />" +
  432. " <attribute name=\"Vert Alignment\" value=\"Bottom\" />" +
  433. " <attribute name=\"Texture\" value=\"Texture2D;Textures/TouchInput.png\" />" +
  434. " <attribute name=\"Image Rect\" value=\"96 0 192 96\" />" +
  435. " <attribute name=\"Hover Image Offset\" value=\"0 0\" />" +
  436. " <attribute name=\"Pressed Image Offset\" value=\"0 0\" />" +
  437. " <element type=\"Text\">" +
  438. " <attribute name=\"Name\" value=\"Label\" />" +
  439. " <attribute name=\"Horiz Alignment\" value=\"Center\" />" +
  440. " <attribute name=\"Vert Alignment\" value=\"Center\" />" +
  441. " <attribute name=\"Color\" value=\"0 0 0 1\" />" +
  442. " <attribute name=\"Text\" value=\"Obstacles\" />" +
  443. " </element>" +
  444. " <element type=\"Text\">" +
  445. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" +
  446. " <attribute name=\"Text\" value=\"MIDDLE\" />" +
  447. " </element>" +
  448. " </element>" +
  449. " </add>" +
  450. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/attribute[@name='Is Visible']\" />" +
  451. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Set</replace>" +
  452. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]\">" +
  453. " <element type=\"Text\">" +
  454. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" +
  455. " <attribute name=\"Text\" value=\"LEFT\" />" +
  456. " </element>" +
  457. " </add>" +
  458. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />" +
  459. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Debug</replace>" +
  460. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">" +
  461. " <element type=\"Text\">" +
  462. " <attribute name=\"Name\" value=\"KeyBinding\" />" +
  463. " <attribute name=\"Text\" value=\"SPACE\" />" +
  464. " </element>" +
  465. " </add>" +
  466. "</patch>";