@nice2dev/game-engine 1.3.15 → 1.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (434) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/accessibility/Accessibility.js +152 -165
  3. package/dist/cjs/ai/AI.js +292 -294
  4. package/dist/cjs/ai/BehaviorTree.js +1029 -1113
  5. package/dist/cjs/ai/StateMachine.js +694 -756
  6. package/dist/cjs/animation/Animation.js +232 -241
  7. package/dist/cjs/audio/AudioAdvanced.js +221 -236
  8. package/dist/cjs/audio/AudioBridge.js +441 -435
  9. package/dist/cjs/audio/AudioManager.js +242 -259
  10. package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
  11. package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
  12. package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
  13. package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
  14. package/dist/cjs/core/EventBus.js +51 -56
  15. package/dist/cjs/core/GameClock.js +62 -66
  16. package/dist/cjs/core/GameConfig.js +72 -79
  17. package/dist/cjs/core/GameLoop.js +80 -89
  18. package/dist/cjs/core/ServiceLocator.js +61 -65
  19. package/dist/cjs/core/Validation.js +72 -82
  20. package/dist/cjs/core/math.js +108 -112
  21. package/dist/cjs/devtools/DevTools.js +542 -563
  22. package/dist/cjs/devtools/DeveloperExperience.js +521 -559
  23. package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
  24. package/dist/cjs/dialogue/DialogueSystem.js +984 -986
  25. package/dist/cjs/docs/DocGenerator.js +339 -364
  26. package/dist/cjs/ecs/World.js +355 -371
  27. package/dist/cjs/editor/AchievementEditor.js +580 -636
  28. package/dist/cjs/editor/AdvancedEditor.js +184 -191
  29. package/dist/cjs/editor/AnimationRetargeting.js +696 -741
  30. package/dist/cjs/editor/AssetBrowser.js +1072 -1160
  31. package/dist/cjs/editor/AssetManager.js +187 -192
  32. package/dist/cjs/editor/ConsolePro.js +971 -1061
  33. package/dist/cjs/editor/CraftingEditor.js +680 -730
  34. package/dist/cjs/editor/DebugTools.js +187 -185
  35. package/dist/cjs/editor/DialogueSystem.js +844 -901
  36. package/dist/cjs/editor/LeaderboardSystem.js +429 -483
  37. package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
  38. package/dist/cjs/editor/PrefabSystem.js +772 -838
  39. package/dist/cjs/editor/ProfilerPanel.js +649 -700
  40. package/dist/cjs/editor/QuestEditor.js +792 -839
  41. package/dist/cjs/editor/ReplaySystem.js +585 -634
  42. package/dist/cjs/editor/SceneEditor.js +176 -200
  43. package/dist/cjs/editor/ScreenshotMode.js +621 -688
  44. package/dist/cjs/editor/ShaderGraph.js +1556 -1582
  45. package/dist/cjs/editor/TimelineEditor.js +715 -778
  46. package/dist/cjs/editor/UndoRedoPro.js +830 -904
  47. package/dist/cjs/editor/VRARMode.js +582 -645
  48. package/dist/cjs/engine/NiceGameEngine.js +141 -164
  49. package/dist/cjs/engine/SaveSystem.js +441 -495
  50. package/dist/cjs/enterprise/Enterprise.js +254 -261
  51. package/dist/cjs/export/BevyExporter.js +927 -967
  52. package/dist/cjs/export/CocosExporter.js +644 -673
  53. package/dist/cjs/export/Construct3Exporter.js +783 -794
  54. package/dist/cjs/export/DefoldExporter.js +1028 -1069
  55. package/dist/cjs/export/GDevelopExporter.js +674 -708
  56. package/dist/cjs/export/GameMakerExporter.js +791 -805
  57. package/dist/cjs/export/GodotExporter.js +1003 -1045
  58. package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
  59. package/dist/cjs/export/MonoGameExporter.js +1265 -1293
  60. package/dist/cjs/export/Pico8Exporter.js +766 -812
  61. package/dist/cjs/export/PlatformExporter.js +188 -206
  62. package/dist/cjs/export/RPGMakerExporter.js +860 -879
  63. package/dist/cjs/export/RobloxExporter.js +883 -919
  64. package/dist/cjs/export/Solar2DExporter.js +1218 -1256
  65. package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
  66. package/dist/cjs/export/Tic80Exporter.js +1210 -1267
  67. package/dist/cjs/export/UnityExporter.js +1116 -1131
  68. package/dist/cjs/export/UnrealExporter.js +889 -919
  69. package/dist/cjs/export/WebExporter.js +931 -970
  70. package/dist/cjs/export/index.js +42 -65
  71. package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
  72. package/dist/cjs/godot-integration/GodotImport.js +929 -1027
  73. package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
  74. package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
  75. package/dist/cjs/i18n/I18n.js +860 -900
  76. package/dist/cjs/i18n/useTranslation.js +84 -89
  77. package/dist/cjs/import/AsepriteImporter.js +658 -716
  78. package/dist/cjs/import/DragonBonesImporter.js +437 -461
  79. package/dist/cjs/import/GameMakerImporter.js +511 -521
  80. package/dist/cjs/import/GodotSceneImporter.js +788 -822
  81. package/dist/cjs/import/LDtkImporter.js +436 -454
  82. package/dist/cjs/import/Live2DImporter.js +497 -518
  83. package/dist/cjs/import/NdgFormat.js +424 -457
  84. package/dist/cjs/import/OgmoImporter.js +466 -493
  85. package/dist/cjs/import/RPGMakerImporter.js +451 -477
  86. package/dist/cjs/import/SceneImporter.js +378 -423
  87. package/dist/cjs/import/SpineImporter.js +511 -546
  88. package/dist/cjs/import/SpriterImporter.js +590 -613
  89. package/dist/cjs/import/TiledMapImporter.js +811 -846
  90. package/dist/cjs/import/UnitySceneImporter.js +687 -703
  91. package/dist/cjs/import/index.js +206 -251
  92. package/dist/cjs/index.js +275 -278
  93. package/dist/cjs/input/GamepadNavigation.js +185 -205
  94. package/dist/cjs/input/InputManager.js +397 -421
  95. package/dist/cjs/input/useGamepads.js +70 -81
  96. package/dist/cjs/integration/IconSprite.js +129 -256
  97. package/dist/cjs/inventory/InventorySystem.js +920 -995
  98. package/dist/cjs/kids/KidMode.js +997 -1022
  99. package/dist/cjs/kids/KidTools.js +570 -594
  100. package/dist/cjs/monetization/Monetization.js +170 -177
  101. package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
  102. package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
  103. package/dist/cjs/native-engine/AnimationSystem.js +731 -806
  104. package/dist/cjs/native-engine/AssetPipeline.js +454 -515
  105. package/dist/cjs/native-engine/AudioEngine.js +763 -804
  106. package/dist/cjs/native-engine/InputSystem.js +1075 -1145
  107. package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
  108. package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
  109. package/dist/cjs/native-engine/RenderingEngine.js +302 -350
  110. package/dist/cjs/native-engine/SceneGraph.js +769 -808
  111. package/dist/cjs/network/MultiplayerTransport.js +97 -132
  112. package/dist/cjs/network/Networking.js +549 -564
  113. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
  114. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
  115. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
  116. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
  117. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
  118. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
  119. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
  120. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
  121. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
  122. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
  123. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
  124. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
  125. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
  126. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
  127. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
  128. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
  129. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
  130. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
  131. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
  132. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
  133. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
  134. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
  135. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
  136. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
  137. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
  138. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
  139. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
  140. package/dist/cjs/pathfinding/Pathfinding.js +245 -263
  141. package/dist/cjs/performance/AssetStreaming.js +561 -635
  142. package/dist/cjs/performance/BenchmarkSuite.js +283 -311
  143. package/dist/cjs/performance/DeltaCompression.js +467 -526
  144. package/dist/cjs/performance/DeterministicPhysics.js +450 -498
  145. package/dist/cjs/performance/ECSOptimization.js +644 -695
  146. package/dist/cjs/performance/GameSaveSystem.js +509 -556
  147. package/dist/cjs/performance/HotReload.js +447 -500
  148. package/dist/cjs/performance/InputRecording.js +511 -561
  149. package/dist/cjs/performance/InterestManagement.js +453 -500
  150. package/dist/cjs/performance/LocalizationRuntime.js +376 -423
  151. package/dist/cjs/performance/MemoryManagement.js +410 -470
  152. package/dist/cjs/performance/ModSupport.js +445 -496
  153. package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
  154. package/dist/cjs/performance/NetworkPrediction.js +424 -482
  155. package/dist/cjs/performance/ObjectPooling.js +569 -617
  156. package/dist/cjs/performance/Performance.js +174 -190
  157. package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
  158. package/dist/cjs/performance/WebGPURenderer.js +656 -683
  159. package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
  160. package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
  161. package/dist/cjs/plugins/PluginSDK.js +432 -466
  162. package/dist/cjs/plugins/PluginTestKit.js +307 -330
  163. package/dist/cjs/procedural/Procedural.js +243 -254
  164. package/dist/cjs/procedural/WorldBuilding.js +297 -314
  165. package/dist/cjs/quest/QuestSystem.js +975 -932
  166. package/dist/cjs/release/MobileExport.js +157 -163
  167. package/dist/cjs/release/Release.js +225 -238
  168. package/dist/cjs/rendering/Camera2D.js +121 -124
  169. package/dist/cjs/rendering/Renderer2D.js +321 -335
  170. package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
  171. package/dist/cjs/runtime3d/Runtime3D.js +359 -378
  172. package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
  173. package/dist/cjs/scene/SceneManager.js +177 -193
  174. package/dist/cjs/scripting/GraphToAST.js +574 -547
  175. package/dist/cjs/scripting/LanguageExporter.js +254 -279
  176. package/dist/cjs/scripting/NodeGraph.js +546 -570
  177. package/dist/cjs/scripting/ScriptAST.js +31 -39
  178. package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
  179. package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
  180. package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
  181. package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
  182. package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
  183. package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
  184. package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
  185. package/dist/cjs/social/Social.js +72 -80
  186. package/dist/cjs/systems/LightingSystem.js +844 -931
  187. package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
  188. package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
  189. package/dist/cjs/systems/TerrainSystem.js +985 -1098
  190. package/dist/cjs/templates/ActionTemplates.js +296 -309
  191. package/dist/cjs/templates/FightingTemplate.js +417 -463
  192. package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
  193. package/dist/cjs/templates/PartyTemplates.js +190 -202
  194. package/dist/cjs/templates/PuzzleTemplates.js +245 -261
  195. package/dist/cjs/templates/RPGTemplates.js +160 -178
  196. package/dist/cjs/templates/SportsTemplates.js +237 -250
  197. package/dist/cjs/templates/StrategyTemplates.js +143 -153
  198. package/dist/cjs/templates/SurvivalTemplate.js +336 -380
  199. package/dist/cjs/templates/WaveDefense.js +499 -526
  200. package/dist/cjs/tilemap/Tilemap.js +207 -214
  201. package/dist/cjs/tutorials/TutorialBranching.js +396 -417
  202. package/dist/cjs/tutorials/TutorialEngine.js +888 -931
  203. package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
  204. package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
  205. package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
  206. package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
  207. package/dist/cjs/ui/GameUI.js +295 -312
  208. package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
  209. package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
  210. package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
  211. package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
  212. package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
  213. package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
  214. package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
  215. package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
  216. package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
  217. package/dist/cjs/xr/ARVR.js +167 -175
  218. package/dist/esm/accessibility/Accessibility.js +160 -164
  219. package/dist/esm/ai/AI.js +310 -293
  220. package/dist/esm/ai/BehaviorTree.js +1057 -1112
  221. package/dist/esm/ai/StateMachine.js +709 -755
  222. package/dist/esm/animation/Animation.js +237 -240
  223. package/dist/esm/audio/AudioAdvanced.js +239 -235
  224. package/dist/esm/audio/AudioBridge.js +448 -434
  225. package/dist/esm/audio/AudioManager.js +243 -258
  226. package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
  227. package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
  228. package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
  229. package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
  230. package/dist/esm/core/EventBus.js +52 -55
  231. package/dist/esm/core/GameClock.js +63 -65
  232. package/dist/esm/core/GameConfig.js +77 -78
  233. package/dist/esm/core/GameLoop.js +81 -88
  234. package/dist/esm/core/ServiceLocator.js +63 -64
  235. package/dist/esm/core/Validation.js +82 -81
  236. package/dist/esm/core/math.js +109 -111
  237. package/dist/esm/devtools/DevTools.js +546 -562
  238. package/dist/esm/devtools/DeveloperExperience.js +535 -558
  239. package/dist/esm/devtools/GameplayAnalytics.js +647 -645
  240. package/dist/esm/dialogue/DialogueSystem.js +998 -985
  241. package/dist/esm/docs/DocGenerator.js +342 -363
  242. package/dist/esm/ecs/World.js +358 -370
  243. package/dist/esm/editor/AchievementEditor.js +584 -635
  244. package/dist/esm/editor/AdvancedEditor.js +191 -190
  245. package/dist/esm/editor/AnimationRetargeting.js +700 -740
  246. package/dist/esm/editor/AssetBrowser.js +1078 -1159
  247. package/dist/esm/editor/AssetManager.js +188 -191
  248. package/dist/esm/editor/ConsolePro.js +977 -1060
  249. package/dist/esm/editor/CraftingEditor.js +684 -729
  250. package/dist/esm/editor/DebugTools.js +194 -184
  251. package/dist/esm/editor/DialogueSystem.js +849 -900
  252. package/dist/esm/editor/LeaderboardSystem.js +433 -482
  253. package/dist/esm/editor/NiceGameEditor.js +1908 -1200
  254. package/dist/esm/editor/PrefabSystem.js +777 -837
  255. package/dist/esm/editor/ProfilerPanel.js +654 -699
  256. package/dist/esm/editor/QuestEditor.js +795 -838
  257. package/dist/esm/editor/ReplaySystem.js +591 -633
  258. package/dist/esm/editor/SceneEditor.js +189 -199
  259. package/dist/esm/editor/ScreenshotMode.js +628 -687
  260. package/dist/esm/editor/ShaderGraph.js +1565 -1581
  261. package/dist/esm/editor/TimelineEditor.js +733 -777
  262. package/dist/esm/editor/UndoRedoPro.js +835 -903
  263. package/dist/esm/editor/VRARMode.js +586 -644
  264. package/dist/esm/engine/NiceGameEngine.js +142 -163
  265. package/dist/esm/engine/SaveSystem.js +447 -494
  266. package/dist/esm/enterprise/Enterprise.js +265 -260
  267. package/dist/esm/export/BevyExporter.js +929 -966
  268. package/dist/esm/export/CocosExporter.js +646 -672
  269. package/dist/esm/export/Construct3Exporter.js +785 -793
  270. package/dist/esm/export/DefoldExporter.js +1030 -1068
  271. package/dist/esm/export/GDevelopExporter.js +676 -707
  272. package/dist/esm/export/GameMakerExporter.js +793 -804
  273. package/dist/esm/export/GodotExporter.js +1004 -1044
  274. package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
  275. package/dist/esm/export/MonoGameExporter.js +1267 -1292
  276. package/dist/esm/export/Pico8Exporter.js +768 -811
  277. package/dist/esm/export/PlatformExporter.js +193 -205
  278. package/dist/esm/export/RPGMakerExporter.js +862 -878
  279. package/dist/esm/export/RobloxExporter.js +885 -918
  280. package/dist/esm/export/Solar2DExporter.js +1220 -1255
  281. package/dist/esm/export/ThreeJSExporter.js +1007 -1072
  282. package/dist/esm/export/Tic80Exporter.js +1212 -1266
  283. package/dist/esm/export/UnityExporter.js +1117 -1130
  284. package/dist/esm/export/UnrealExporter.js +891 -918
  285. package/dist/esm/export/WebExporter.js +933 -969
  286. package/dist/esm/export/index.js +86 -71
  287. package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
  288. package/dist/esm/godot-integration/GodotImport.js +935 -1026
  289. package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
  290. package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
  291. package/dist/esm/i18n/I18n.js +871 -899
  292. package/dist/esm/i18n/useTranslation.js +88 -88
  293. package/dist/esm/import/AsepriteImporter.js +637 -715
  294. package/dist/esm/import/DragonBonesImporter.js +417 -460
  295. package/dist/esm/import/GameMakerImporter.js +491 -520
  296. package/dist/esm/import/GodotSceneImporter.js +767 -821
  297. package/dist/esm/import/LDtkImporter.js +415 -453
  298. package/dist/esm/import/Live2DImporter.js +477 -517
  299. package/dist/esm/import/NdgFormat.js +410 -456
  300. package/dist/esm/import/OgmoImporter.js +446 -492
  301. package/dist/esm/import/RPGMakerImporter.js +431 -476
  302. package/dist/esm/import/SceneImporter.js +385 -422
  303. package/dist/esm/import/SpineImporter.js +491 -545
  304. package/dist/esm/import/SpriterImporter.js +570 -612
  305. package/dist/esm/import/TiledMapImporter.js +790 -845
  306. package/dist/esm/import/UnitySceneImporter.js +666 -702
  307. package/dist/esm/import/index.js +247 -258
  308. package/dist/esm/index.js +1332 -188
  309. package/dist/esm/input/GamepadNavigation.js +187 -204
  310. package/dist/esm/input/InputManager.js +401 -420
  311. package/dist/esm/input/useGamepads.js +72 -80
  312. package/dist/esm/integration/IconSprite.js +143 -255
  313. package/dist/esm/inventory/InventorySystem.js +925 -994
  314. package/dist/esm/kids/KidMode.js +1003 -1021
  315. package/dist/esm/kids/KidTools.js +573 -593
  316. package/dist/esm/monetization/Monetization.js +180 -176
  317. package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
  318. package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
  319. package/dist/esm/native-engine/AnimationSystem.js +735 -805
  320. package/dist/esm/native-engine/AssetPipeline.js +456 -514
  321. package/dist/esm/native-engine/AudioEngine.js +765 -803
  322. package/dist/esm/native-engine/InputSystem.js +1079 -1144
  323. package/dist/esm/native-engine/NetworkingSystem.js +740 -792
  324. package/dist/esm/native-engine/PhysicsEngine.js +585 -606
  325. package/dist/esm/native-engine/RenderingEngine.js +304 -349
  326. package/dist/esm/native-engine/SceneGraph.js +773 -807
  327. package/dist/esm/network/MultiplayerTransport.js +99 -131
  328. package/dist/esm/network/Networking.js +556 -563
  329. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
  330. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
  331. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
  332. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
  333. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
  334. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
  335. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
  336. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
  337. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
  338. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
  339. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
  340. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
  341. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
  342. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
  343. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
  344. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
  345. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
  346. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
  347. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
  348. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
  349. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
  350. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
  351. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
  352. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
  353. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
  354. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
  355. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
  356. package/dist/esm/pathfinding/Pathfinding.js +249 -262
  357. package/dist/esm/performance/AssetStreaming.js +567 -634
  358. package/dist/esm/performance/BenchmarkSuite.js +285 -310
  359. package/dist/esm/performance/DeltaCompression.js +478 -525
  360. package/dist/esm/performance/DeterministicPhysics.js +479 -497
  361. package/dist/esm/performance/ECSOptimization.js +653 -694
  362. package/dist/esm/performance/GameSaveSystem.js +515 -555
  363. package/dist/esm/performance/HotReload.js +454 -499
  364. package/dist/esm/performance/InputRecording.js +520 -560
  365. package/dist/esm/performance/InterestManagement.js +460 -499
  366. package/dist/esm/performance/LocalizationRuntime.js +382 -422
  367. package/dist/esm/performance/MemoryManagement.js +415 -469
  368. package/dist/esm/performance/ModSupport.js +455 -495
  369. package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
  370. package/dist/esm/performance/NetworkPrediction.js +436 -481
  371. package/dist/esm/performance/ObjectPooling.js +582 -616
  372. package/dist/esm/performance/Performance.js +182 -189
  373. package/dist/esm/performance/PerformanceAdvanced.js +621 -636
  374. package/dist/esm/performance/WebGPURenderer.js +660 -682
  375. package/dist/esm/physics/PhysicsAdvanced.js +359 -378
  376. package/dist/esm/physics/PhysicsEngine2D.js +393 -426
  377. package/dist/esm/plugins/PluginSDK.js +435 -465
  378. package/dist/esm/plugins/PluginTestKit.js +315 -329
  379. package/dist/esm/procedural/Procedural.js +248 -253
  380. package/dist/esm/procedural/WorldBuilding.js +316 -313
  381. package/dist/esm/quest/QuestSystem.js +982 -931
  382. package/dist/esm/release/MobileExport.js +163 -162
  383. package/dist/esm/release/Release.js +234 -237
  384. package/dist/esm/rendering/Camera2D.js +122 -123
  385. package/dist/esm/rendering/Renderer2D.js +323 -334
  386. package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
  387. package/dist/esm/runtime3d/Runtime3D.js +368 -377
  388. package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
  389. package/dist/esm/scene/SceneManager.js +178 -192
  390. package/dist/esm/scripting/GraphToAST.js +576 -546
  391. package/dist/esm/scripting/LanguageExporter.js +263 -278
  392. package/dist/esm/scripting/NodeGraph.js +550 -569
  393. package/dist/esm/scripting/ScriptAST.js +45 -38
  394. package/dist/esm/scripting/VisualScripting2.js +1025 -1064
  395. package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
  396. package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
  397. package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
  398. package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
  399. package/dist/esm/scripting/exporters/RustExporter.js +460 -511
  400. package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
  401. package/dist/esm/social/Social.js +77 -79
  402. package/dist/esm/systems/LightingSystem.js +855 -930
  403. package/dist/esm/systems/ParticleSystem2.js +1453 -1450
  404. package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
  405. package/dist/esm/systems/TerrainSystem.js +996 -1097
  406. package/dist/esm/templates/ActionTemplates.js +307 -308
  407. package/dist/esm/templates/FightingTemplate.js +439 -462
  408. package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
  409. package/dist/esm/templates/PartyTemplates.js +206 -201
  410. package/dist/esm/templates/PuzzleTemplates.js +260 -260
  411. package/dist/esm/templates/RPGTemplates.js +172 -177
  412. package/dist/esm/templates/SportsTemplates.js +251 -249
  413. package/dist/esm/templates/StrategyTemplates.js +158 -152
  414. package/dist/esm/templates/SurvivalTemplate.js +367 -379
  415. package/dist/esm/templates/WaveDefense.js +501 -525
  416. package/dist/esm/tilemap/Tilemap.js +209 -213
  417. package/dist/esm/tutorials/TutorialBranching.js +399 -416
  418. package/dist/esm/tutorials/TutorialEngine.js +893 -930
  419. package/dist/esm/tutorials/TutorialOverlay.js +603 -639
  420. package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
  421. package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
  422. package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
  423. package/dist/esm/ui/GameUI.js +296 -311
  424. package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
  425. package/dist/esm/unity-integration/UnityImport.js +1071 -1175
  426. package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
  427. package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
  428. package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
  429. package/dist/esm/unreal-integration/UnrealImport.js +395 -411
  430. package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
  431. package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
  432. package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
  433. package/dist/esm/xr/ARVR.js +181 -174
  434. package/package.json +7 -12
@@ -1,1333 +1,1305 @@
1
- 'use strict';
2
-
3
- /* ────────────────────────────────────────────────────────────────
4
- MonoGame/FNA Exporter — .NET Game Framework
5
-
6
- Exports NiceToDev game projects to MonoGame 3.8+ / FNA:
7
- - Content pipeline integration
8
- - C# classes for entities/components
9
- - Game states and screens
10
- - SpriteBatch rendering
11
- - Content.mgcb generation
12
- ──────────────────────────────────────────────────────────────── */
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
13
3
  const DEFAULT_MONOGAME_CONFIG = {
14
- outputPath: 'monogame_export',
15
- assetPath: 'Content',
16
- platform: 'pc',
17
- framework: 'monogame',
18
- monogameVersion: '3.8.2',
19
- targetPlatform: 'DesktopGL',
20
- extendedPipeline: true,
21
- designTimeContent: true,
22
- useECS: true,
23
- useNez: false,
24
- useTilemaps: true,
25
- namespace: 'MyGame',
26
- solutionName: 'MyGame',
4
+ outputPath: "monogame_export",
5
+ assetPath: "Content",
6
+ platform: "pc",
7
+ framework: "monogame",
8
+ monogameVersion: "3.8.2",
9
+ targetPlatform: "DesktopGL",
10
+ extendedPipeline: true,
11
+ designTimeContent: true,
12
+ useECS: true,
13
+ useNez: false,
14
+ useTilemaps: true,
15
+ namespace: "MyGame",
16
+ solutionName: "MyGame"
27
17
  };
28
- /* ══════════════════════════════════════════════════════════════
29
- C# CODE GENERATION
30
- ══════════════════════════════════════════════════════════════ */
31
18
  class MonoGameExporter {
32
- constructor(config) {
33
- this.csharpFiles = new Map();
34
- this.contentFiles = [];
35
- this.assets = [];
36
- this.config = { ...DEFAULT_MONOGAME_CONFIG, ...config };
19
+ constructor(config) {
20
+ this.csharpFiles = /* @__PURE__ */ new Map();
21
+ this.contentFiles = [];
22
+ this.assets = [];
23
+ this.config = { ...DEFAULT_MONOGAME_CONFIG, ...config };
24
+ }
25
+ /** Export game project to MonoGame */
26
+ async export(project) {
27
+ const startTime = performance.now();
28
+ try {
29
+ if (project.name) {
30
+ this.config.namespace = this.toPascalCase(project.name);
31
+ this.config.solutionName = this.toPascalCase(project.name);
32
+ }
33
+ this.generateSolution(project);
34
+ this.generateCsproj(project);
35
+ this.generateGame1(project);
36
+ this.generateComponents(project);
37
+ this.generateEntities(project);
38
+ if (this.config.useECS) {
39
+ this.generateSystems(project);
40
+ }
41
+ this.generateScreens(project);
42
+ this.generateContentMgcb(project);
43
+ this.collectAssets(project);
44
+ return {
45
+ success: true,
46
+ outputPath: this.config.outputPath,
47
+ files: Array.from(this.csharpFiles.entries()).map(([path, content]) => ({
48
+ path,
49
+ content,
50
+ type: "source"
51
+ })),
52
+ assets: this.assets.map((a) => ({
53
+ path: `${this.config.assetPath}/${a.name}`,
54
+ type: "asset",
55
+ originalPath: a.path
56
+ })),
57
+ stats: {
58
+ duration: performance.now() - startTime,
59
+ fileCount: this.csharpFiles.size,
60
+ assetCount: this.assets.length
61
+ }
62
+ };
63
+ } catch (error) {
64
+ return {
65
+ success: false,
66
+ errors: [error.message]
67
+ };
37
68
  }
38
- /** Export game project to MonoGame */
39
- async export(project) {
40
- const startTime = performance.now();
41
- try {
42
- // Update config with project info
43
- if (project.name) {
44
- this.config.namespace = this.toPascalCase(project.name);
45
- this.config.solutionName = this.toPascalCase(project.name);
46
- }
47
- // Generate solution and project files
48
- this.generateSolution(project);
49
- this.generateCsproj(project);
50
- // Generate main game class
51
- this.generateGame1(project);
52
- // Generate components
53
- this.generateComponents(project);
54
- // Generate entities
55
- this.generateEntities(project);
56
- // Generate systems (if using ECS)
57
- if (this.config.useECS) {
58
- this.generateSystems(project);
69
+ }
70
+ generateSolution(_project) {
71
+ const projectGuid = this.generateGuid();
72
+ const solutionGuid = this.generateGuid();
73
+ const sln = `
74
+ Microsoft Visual Studio Solution File, Format Version 12.00
75
+ # Visual Studio Version 17
76
+ VisualStudioVersion = 17.0.31903.59
77
+ MinimumVisualStudioVersion = 10.0.40219.1
78
+ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "${this.config.solutionName}", "${this.config.solutionName}\\${this.config.solutionName}.csproj", "{${projectGuid}}"
79
+ EndProject
80
+ Global
81
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
82
+ Debug|Any CPU = Debug|Any CPU
83
+ Release|Any CPU = Release|Any CPU
84
+ EndGlobalSection
85
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
86
+ {${projectGuid}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87
+ {${projectGuid}}.Debug|Any CPU.Build.0 = Debug|Any CPU
88
+ {${projectGuid}}.Release|Any CPU.ActiveCfg = Release|Any CPU
89
+ {${projectGuid}}.Release|Any CPU.Build.0 = Release|Any CPU
90
+ EndGlobalSection
91
+ GlobalSection(SolutionProperties) = preSolution
92
+ HideSolutionNode = FALSE
93
+ EndGlobalSection
94
+ GlobalSection(ExtensibilityGlobals) = postSolution
95
+ SolutionGuid = {${solutionGuid}}
96
+ EndGlobalSection
97
+ EndGlobal
98
+ `;
99
+ this.csharpFiles.set(`${this.config.solutionName}.sln`, sln.trim());
100
+ }
101
+ generateCsproj(_project) {
102
+ const { framework, monogameVersion, targetPlatform, useECS, useNez, extendedPipeline } = this.config;
103
+ const packageRefs = [];
104
+ if (framework === "monogame") {
105
+ packageRefs.push(
106
+ `<PackageReference Include="MonoGame.Framework.${targetPlatform}" Version="${monogameVersion}" />`
107
+ );
108
+ packageRefs.push(
109
+ `<PackageReference Include="MonoGame.Content.Builder.Task" Version="${monogameVersion}" />`
110
+ );
111
+ } else {
112
+ packageRefs.push(`<PackageReference Include="FNA" Version="24.01" />`);
113
+ }
114
+ if (extendedPipeline) {
115
+ packageRefs.push(`<PackageReference Include="MonoGame.Extended" Version="4.0.0" />`);
116
+ packageRefs.push(
117
+ `<PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="4.0.0" />`
118
+ );
119
+ }
120
+ if (useECS) {
121
+ packageRefs.push(`<PackageReference Include="MonoGame.Extended.Entities" Version="4.0.0" />`);
122
+ }
123
+ if (useNez) {
124
+ packageRefs.push(`<PackageReference Include="Nez" Version="1.0.1" />`);
125
+ }
126
+ const csproj = `<Project Sdk="Microsoft.NET.Sdk">
127
+ <PropertyGroup>
128
+ <OutputType>WinExe</OutputType>
129
+ <TargetFramework>net8.0</TargetFramework>
130
+ <RollForward>Major</RollForward>
131
+ <PublishReadyToRun>false</PublishReadyToRun>
132
+ <TieredCompilation>false</TieredCompilation>
133
+ <RootNamespace>${this.config.namespace}</RootNamespace>
134
+ <AssemblyName>${this.config.solutionName}</AssemblyName>
135
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
136
+ </PropertyGroup>
137
+
138
+ <ItemGroup>
139
+ ${packageRefs.map((r) => ` ${r}`).join("\n")}
140
+ </ItemGroup>
141
+
142
+ <ItemGroup>
143
+ <None Remove="**\\*.mgcb" />
144
+ <MonoGameContentReference Include="Content\\Content.mgcb" />
145
+ </ItemGroup>
146
+
147
+ <ItemGroup>
148
+ <Compile Update="**\\*.cs" />
149
+ </ItemGroup>
150
+ </Project>
151
+ `;
152
+ this.csharpFiles.set(`${this.config.solutionName}/${this.config.solutionName}.csproj`, csproj);
153
+ }
154
+ generateGame1(_project) {
155
+ const { namespace, useECS, useNez } = this.config;
156
+ const usings = [
157
+ "using Microsoft.Xna.Framework;",
158
+ "using Microsoft.Xna.Framework.Graphics;",
159
+ "using Microsoft.Xna.Framework.Input;"
160
+ ];
161
+ if (useECS) {
162
+ usings.push("using MonoGame.Extended.Entities;");
163
+ }
164
+ if (useNez) {
165
+ usings.push("using Nez;");
166
+ }
167
+ usings.push(`using ${namespace}.Screens;`);
168
+ usings.push(`using ${namespace}.Components;`);
169
+ const game1 = `${usings.join("\n")}
170
+
171
+ namespace ${namespace}
172
+ {
173
+ public class Game1 : Game
174
+ {
175
+ private GraphicsDeviceManager _graphics;
176
+ private SpriteBatch _spriteBatch;
177
+ private ScreenManager _screenManager;
178
+ ${useECS ? "private World _world;" : ""}
179
+
180
+ public static Game1 Instance { get; private set; }
181
+ public static int ScreenWidth => 1280;
182
+ public static int ScreenHeight => 720;
183
+
184
+ public Game1()
185
+ {
186
+ Instance = this;
187
+ _graphics = new GraphicsDeviceManager(this);
188
+ Content.RootDirectory = "Content";
189
+ IsMouseVisible = true;
190
+
191
+ _graphics.PreferredBackBufferWidth = ScreenWidth;
192
+ _graphics.PreferredBackBufferHeight = ScreenHeight;
193
+ _graphics.ApplyChanges();
194
+ }
195
+
196
+ protected override void Initialize()
197
+ {
198
+ _screenManager = new ScreenManager(this);
199
+ Components.Add(_screenManager);
200
+
201
+ ${useECS ? this.generateECSInitialization() : ""}
202
+
203
+ base.Initialize();
204
+ }
205
+
206
+ protected override void LoadContent()
207
+ {
208
+ _spriteBatch = new SpriteBatch(GraphicsDevice);
209
+
210
+ // Load global content
211
+ Assets.Load(Content);
212
+
213
+ // Start with menu screen
214
+ _screenManager.AddScreen(new MenuScreen());
215
+ }
216
+
217
+ protected override void Update(GameTime gameTime)
218
+ {
219
+ if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
220
+ Keyboard.GetState().IsKeyDown(Keys.Escape))
221
+ {
222
+ Exit();
59
223
  }
60
- // Generate screens/states
61
- this.generateScreens(project);
62
- // Generate content pipeline
63
- this.generateContentMgcb(project);
64
- // Collect assets
65
- this.collectAssets(project);
66
- return {
67
- success: true,
68
- outputPath: this.config.outputPath,
69
- files: Array.from(this.csharpFiles.entries()).map(([path, content]) => ({
70
- path,
71
- content,
72
- type: 'source',
73
- })),
74
- assets: this.assets.map((a) => ({
75
- path: `${this.config.assetPath}/${a.name}`,
76
- type: 'asset',
77
- originalPath: a.path,
78
- })),
79
- stats: {
80
- duration: performance.now() - startTime,
81
- fileCount: this.csharpFiles.size,
82
- assetCount: this.assets.length,
83
- },
84
- };
224
+
225
+ ${useECS ? "_world?.Update(gameTime);" : ""}
226
+
227
+ base.Update(gameTime);
85
228
  }
86
- catch (error) {
87
- return {
88
- success: false,
89
- errors: [error.message],
90
- };
229
+
230
+ protected override void Draw(GameTime gameTime)
231
+ {
232
+ GraphicsDevice.Clear(Color.CornflowerBlue);
233
+
234
+ ${useECS ? "_world?.Draw(gameTime);" : ""}
235
+
236
+ base.Draw(gameTime);
91
237
  }
92
238
  }
93
- generateSolution(_project) {
94
- const projectGuid = this.generateGuid();
95
- const solutionGuid = this.generateGuid();
96
- const sln = `
97
- Microsoft Visual Studio Solution File, Format Version 12.00
98
- # Visual Studio Version 17
99
- VisualStudioVersion = 17.0.31903.59
100
- MinimumVisualStudioVersion = 10.0.40219.1
101
- Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "${this.config.solutionName}", "${this.config.solutionName}\\${this.config.solutionName}.csproj", "{${projectGuid}}"
102
- EndProject
103
- Global
104
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
105
- Debug|Any CPU = Debug|Any CPU
106
- Release|Any CPU = Release|Any CPU
107
- EndGlobalSection
108
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
109
- {${projectGuid}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
110
- {${projectGuid}}.Debug|Any CPU.Build.0 = Debug|Any CPU
111
- {${projectGuid}}.Release|Any CPU.ActiveCfg = Release|Any CPU
112
- {${projectGuid}}.Release|Any CPU.Build.0 = Release|Any CPU
113
- EndGlobalSection
114
- GlobalSection(SolutionProperties) = preSolution
115
- HideSolutionNode = FALSE
116
- EndGlobalSection
117
- GlobalSection(ExtensibilityGlobals) = postSolution
118
- SolutionGuid = {${solutionGuid}}
119
- EndGlobalSection
120
- EndGlobal
239
+ }
121
240
  `;
122
- this.csharpFiles.set(`${this.config.solutionName}.sln`, sln.trim());
241
+ this.csharpFiles.set(`${this.config.solutionName}/Game1.cs`, game1);
242
+ }
243
+ generateECSInitialization() {
244
+ return `
245
+ _world = new WorldBuilder()
246
+ .AddSystem(new MovementSystem())
247
+ .AddSystem(new CollisionSystem())
248
+ .AddSystem(new RenderSystem(_spriteBatch))
249
+ .AddSystem(new AnimationSystem())
250
+ .Build();`;
251
+ }
252
+ generateComponents(_project) {
253
+ const { namespace } = this.config;
254
+ const componentsCs = `using Microsoft.Xna.Framework;
255
+ using Microsoft.Xna.Framework.Graphics;
256
+
257
+ namespace ${namespace}.Components
258
+ {
259
+ // ═══════════════════════════════════════════════════════════════
260
+ // TRANSFORM
261
+ // ═══════════════════════════════════════════════════════════════
262
+
263
+ public class Transform
264
+ {
265
+ public Vector2 Position { get; set; }
266
+ public float Rotation { get; set; }
267
+ public Vector2 Scale { get; set; } = Vector2.One;
268
+ public Vector2 Origin { get; set; }
269
+
270
+ public Transform() { }
271
+
272
+ public Transform(Vector2 position)
273
+ {
274
+ Position = position;
275
+ }
276
+
277
+ public Transform(float x, float y)
278
+ {
279
+ Position = new Vector2(x, y);
280
+ }
281
+
282
+ public Matrix TransformMatrix =>
283
+ Matrix.CreateTranslation(-Origin.X, -Origin.Y, 0) *
284
+ Matrix.CreateScale(Scale.X, Scale.Y, 1) *
285
+ Matrix.CreateRotationZ(Rotation) *
286
+ Matrix.CreateTranslation(Position.X, Position.Y, 0);
123
287
  }
124
- generateCsproj(_project) {
125
- const { framework, monogameVersion, targetPlatform, useECS, useNez, extendedPipeline } = this.config;
126
- const packageRefs = [];
127
- if (framework === 'monogame') {
128
- packageRefs.push(`<PackageReference Include="MonoGame.Framework.${targetPlatform}" Version="${monogameVersion}" />`);
129
- packageRefs.push(`<PackageReference Include="MonoGame.Content.Builder.Task" Version="${monogameVersion}" />`);
288
+
289
+ // ═══════════════════════════════════════════════════════════════
290
+ // SPRITE
291
+ // ═══════════════════════════════════════════════════════════════
292
+
293
+ public class Sprite
294
+ {
295
+ public Texture2D Texture { get; set; }
296
+ public Rectangle? SourceRectangle { get; set; }
297
+ public Color Color { get; set; } = Color.White;
298
+ public SpriteEffects Effects { get; set; } = SpriteEffects.None;
299
+ public float LayerDepth { get; set; } = 0.5f;
300
+
301
+ public Sprite() { }
302
+
303
+ public Sprite(Texture2D texture)
304
+ {
305
+ Texture = texture;
306
+ }
307
+
308
+ public Vector2 Size => SourceRectangle.HasValue
309
+ ? new Vector2(SourceRectangle.Value.Width, SourceRectangle.Value.Height)
310
+ : (Texture != null ? new Vector2(Texture.Width, Texture.Height) : Vector2.Zero);
311
+ }
312
+
313
+ // ═══════════════════════════════════════════════════════════════
314
+ // VELOCITY
315
+ // ═══════════════════════════════════════════════════════════════
316
+
317
+ public class Velocity
318
+ {
319
+ public Vector2 Linear { get; set; }
320
+ public float Angular { get; set; }
321
+
322
+ public Velocity() { }
323
+
324
+ public Velocity(Vector2 linear)
325
+ {
326
+ Linear = linear;
130
327
  }
131
- else {
132
- packageRefs.push(`<PackageReference Include="FNA" Version="24.01" />`);
328
+
329
+ public Velocity(float x, float y)
330
+ {
331
+ Linear = new Vector2(x, y);
332
+ }
333
+ }
334
+
335
+ // ═══════════════════════════════════════════════════════════════
336
+ // COLLIDER
337
+ // ═══════════════════════════════════════════════════════════════
338
+
339
+ public class Collider
340
+ {
341
+ public ColliderType Type { get; set; } = ColliderType.Rectangle;
342
+ public Vector2 Size { get; set; }
343
+ public float Radius { get; set; }
344
+ public Vector2 Offset { get; set; }
345
+ public bool IsTrigger { get; set; }
346
+ public int CollisionLayer { get; set; } = 1;
347
+ public int CollisionMask { get; set; } = -1;
348
+
349
+ public Rectangle Bounds(Vector2 position) => new Rectangle(
350
+ (int)(position.X + Offset.X - Size.X / 2),
351
+ (int)(position.Y + Offset.Y - Size.Y / 2),
352
+ (int)Size.X,
353
+ (int)Size.Y
354
+ );
355
+ }
356
+
357
+ public enum ColliderType
358
+ {
359
+ Rectangle,
360
+ Circle,
361
+ Capsule
362
+ }
363
+
364
+ // ═══════════════════════════════════════════════════════════════
365
+ // ANIMATION
366
+ // ═══════════════════════════════════════════════════════════════
367
+
368
+ public class AnimatedSprite
369
+ {
370
+ public Texture2D SpriteSheet { get; set; }
371
+ public int FrameWidth { get; set; }
372
+ public int FrameHeight { get; set; }
373
+ public int CurrentFrame { get; set; }
374
+ public int FrameCount { get; set; }
375
+ public float FrameTime { get; set; } = 0.1f;
376
+ public float Timer { get; set; }
377
+ public bool IsPlaying { get; set; } = true;
378
+ public bool Loop { get; set; } = true;
379
+ public int Row { get; set; } // For multi-row spritesheets
380
+
381
+ public Rectangle SourceRectangle => new Rectangle(
382
+ CurrentFrame * FrameWidth,
383
+ Row * FrameHeight,
384
+ FrameWidth,
385
+ FrameHeight
386
+ );
387
+
388
+ public void Update(float deltaTime)
389
+ {
390
+ if (!IsPlaying) return;
391
+
392
+ Timer += deltaTime;
393
+ if (Timer >= FrameTime)
394
+ {
395
+ Timer -= FrameTime;
396
+ CurrentFrame++;
397
+
398
+ if (CurrentFrame >= FrameCount)
399
+ {
400
+ if (Loop)
401
+ CurrentFrame = 0;
402
+ else
403
+ {
404
+ CurrentFrame = FrameCount - 1;
405
+ IsPlaying = false;
406
+ }
407
+ }
408
+ }
133
409
  }
134
- if (extendedPipeline) {
135
- packageRefs.push(`<PackageReference Include="MonoGame.Extended" Version="4.0.0" />`);
136
- packageRefs.push(`<PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="4.0.0" />`);
410
+ }
411
+
412
+ // ═══════════════════════════════════════════════════════════════
413
+ // GAMEPLAY
414
+ // ═══════════════════════════════════════════════════════════════
415
+
416
+ public class Health
417
+ {
418
+ public float Current { get; set; }
419
+ public float Max { get; set; }
420
+
421
+ public Health(float max)
422
+ {
423
+ Max = max;
424
+ Current = max;
137
425
  }
138
- if (useECS) {
139
- packageRefs.push(`<PackageReference Include="MonoGame.Extended.Entities" Version="4.0.0" />`);
426
+
427
+ public float Percentage => Current / Max;
428
+ public bool IsDead => Current <= 0;
429
+
430
+ public bool TakeDamage(float amount)
431
+ {
432
+ Current = MathHelper.Max(0, Current - amount);
433
+ return IsDead;
140
434
  }
141
- if (useNez) {
142
- packageRefs.push(`<PackageReference Include="Nez" Version="1.0.1" />`);
435
+
436
+ public void Heal(float amount)
437
+ {
438
+ Current = MathHelper.Min(Max, Current + amount);
143
439
  }
144
- const csproj = `<Project Sdk="Microsoft.NET.Sdk">
145
- <PropertyGroup>
146
- <OutputType>WinExe</OutputType>
147
- <TargetFramework>net8.0</TargetFramework>
148
- <RollForward>Major</RollForward>
149
- <PublishReadyToRun>false</PublishReadyToRun>
150
- <TieredCompilation>false</TieredCompilation>
151
- <RootNamespace>${this.config.namespace}</RootNamespace>
152
- <AssemblyName>${this.config.solutionName}</AssemblyName>
153
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
154
- </PropertyGroup>
155
-
156
- <ItemGroup>
157
- ${packageRefs.map((r) => ` ${r}`).join('\n')}
158
- </ItemGroup>
159
-
160
- <ItemGroup>
161
- <None Remove="**\\*.mgcb" />
162
- <MonoGameContentReference Include="Content\\Content.mgcb" />
163
- </ItemGroup>
164
-
165
- <ItemGroup>
166
- <Compile Update="**\\*.cs" />
167
- </ItemGroup>
168
- </Project>
440
+ }
441
+
442
+ public class Player
443
+ {
444
+ public int PlayerId { get; set; }
445
+ public int Score { get; set; }
446
+ public float Speed { get; set; } = 200f;
447
+ public bool CanJump { get; set; } = true;
448
+ }
449
+
450
+ public class Enemy
451
+ {
452
+ public EnemyType Type { get; set; }
453
+ public AIState State { get; set; } = AIState.Idle;
454
+ public float DetectionRange { get; set; } = 200f;
455
+ public float AttackRange { get; set; } = 50f;
456
+ }
457
+
458
+ public enum EnemyType
459
+ {
460
+ Basic,
461
+ Fast,
462
+ Tank,
463
+ Boss
464
+ }
465
+
466
+ public enum AIState
467
+ {
468
+ Idle,
469
+ Patrol,
470
+ Chase,
471
+ Attack,
472
+ Flee,
473
+ Dead
474
+ }
475
+ }
169
476
  `;
170
- this.csharpFiles.set(`${this.config.solutionName}/${this.config.solutionName}.csproj`, csproj);
477
+ this.csharpFiles.set(`${this.config.solutionName}/Components/Components.cs`, componentsCs);
478
+ }
479
+ generateEntities(_project) {
480
+ const { namespace } = this.config;
481
+ const entitiesCs = `using Microsoft.Xna.Framework;
482
+ using Microsoft.Xna.Framework.Graphics;
483
+ using ${namespace}.Components;
484
+
485
+ namespace ${namespace}.Entities
486
+ {
487
+ // ═══════════════════════════════════════════════════════════════
488
+ // BASE ENTITY
489
+ // ═══════════════════════════════════════════════════════════════
490
+
491
+ public abstract class Entity
492
+ {
493
+ public int Id { get; protected set; }
494
+ public bool IsActive { get; set; } = true;
495
+ public bool IsDestroyed { get; private set; }
496
+
497
+ public Transform Transform { get; set; } = new Transform();
498
+ public Sprite Sprite { get; set; }
499
+ public Velocity Velocity { get; set; }
500
+ public Collider Collider { get; set; }
501
+
502
+ private static int _nextId = 0;
503
+
504
+ protected Entity()
505
+ {
506
+ Id = _nextId++;
507
+ }
508
+
509
+ public virtual void Update(GameTime gameTime) { }
510
+
511
+ public virtual void Draw(SpriteBatch spriteBatch)
512
+ {
513
+ if (Sprite?.Texture == null) return;
514
+
515
+ spriteBatch.Draw(
516
+ Sprite.Texture,
517
+ Transform.Position,
518
+ Sprite.SourceRectangle,
519
+ Sprite.Color,
520
+ Transform.Rotation,
521
+ Transform.Origin,
522
+ Transform.Scale,
523
+ Sprite.Effects,
524
+ Sprite.LayerDepth
525
+ );
526
+ }
527
+
528
+ public void Destroy()
529
+ {
530
+ IsDestroyed = true;
531
+ OnDestroy();
532
+ }
533
+
534
+ protected virtual void OnDestroy() { }
171
535
  }
172
- generateGame1(_project) {
173
- const { namespace, useECS, useNez } = this.config;
174
- const usings = [
175
- 'using Microsoft.Xna.Framework;',
176
- 'using Microsoft.Xna.Framework.Graphics;',
177
- 'using Microsoft.Xna.Framework.Input;',
178
- ];
179
- if (useECS) {
180
- usings.push('using MonoGame.Extended.Entities;');
536
+
537
+ // ═══════════════════════════════════════════════════════════════
538
+ // PLAYER ENTITY
539
+ // ═══════════════════════════════════════════════════════════════
540
+
541
+ public class PlayerEntity : Entity
542
+ {
543
+ public Player PlayerComponent { get; } = new Player();
544
+ public Health HealthComponent { get; } = new Health(100);
545
+ public AnimatedSprite AnimatedSprite { get; set; }
546
+
547
+ private bool _isGrounded;
548
+ private const float Gravity = 980f;
549
+ private const float JumpForce = -400f;
550
+
551
+ public PlayerEntity(Vector2 position)
552
+ {
553
+ Transform = new Transform(position);
554
+ Velocity = new Velocity();
555
+ Collider = new Collider
556
+ {
557
+ Type = ColliderType.Rectangle,
558
+ Size = new Vector2(32, 48),
559
+ CollisionLayer = 1
560
+ };
181
561
  }
182
- if (useNez) {
183
- usings.push('using Nez;');
562
+
563
+ public override void Update(GameTime gameTime)
564
+ {
565
+ float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
566
+
567
+ // Gravity
568
+ if (!_isGrounded)
569
+ {
570
+ Velocity.Linear = new Vector2(Velocity.Linear.X, Velocity.Linear.Y + Gravity * dt);
571
+ }
572
+
573
+ // Apply velocity
574
+ Transform.Position += Velocity.Linear * dt;
575
+
576
+ // Update animation
577
+ AnimatedSprite?.Update(dt);
578
+ }
579
+
580
+ public void Move(Vector2 direction)
581
+ {
582
+ Velocity.Linear = new Vector2(direction.X * PlayerComponent.Speed, Velocity.Linear.Y);
583
+ }
584
+
585
+ public void Jump()
586
+ {
587
+ if (_isGrounded && PlayerComponent.CanJump)
588
+ {
589
+ Velocity.Linear = new Vector2(Velocity.Linear.X, JumpForce);
590
+ _isGrounded = false;
591
+ }
592
+ }
593
+
594
+ public void OnGrounded()
595
+ {
596
+ _isGrounded = true;
597
+ Velocity.Linear = new Vector2(Velocity.Linear.X, 0);
184
598
  }
185
- usings.push(`using ${namespace}.Screens;`);
186
- usings.push(`using ${namespace}.Components;`);
187
- const game1 = `${usings.join('\n')}
188
-
189
- namespace ${namespace}
190
- {
191
- public class Game1 : Game
192
- {
193
- private GraphicsDeviceManager _graphics;
194
- private SpriteBatch _spriteBatch;
195
- private ScreenManager _screenManager;
196
- ${useECS ? 'private World _world;' : ''}
197
-
198
- public static Game1 Instance { get; private set; }
199
- public static int ScreenWidth => 1280;
200
- public static int ScreenHeight => 720;
201
-
202
- public Game1()
203
- {
204
- Instance = this;
205
- _graphics = new GraphicsDeviceManager(this);
206
- Content.RootDirectory = "Content";
207
- IsMouseVisible = true;
208
-
209
- _graphics.PreferredBackBufferWidth = ScreenWidth;
210
- _graphics.PreferredBackBufferHeight = ScreenHeight;
211
- _graphics.ApplyChanges();
212
- }
213
-
214
- protected override void Initialize()
215
- {
216
- _screenManager = new ScreenManager(this);
217
- Components.Add(_screenManager);
218
-
219
- ${useECS ? this.generateECSInitialization() : ''}
220
-
221
- base.Initialize();
222
- }
223
-
224
- protected override void LoadContent()
225
- {
226
- _spriteBatch = new SpriteBatch(GraphicsDevice);
227
-
228
- // Load global content
229
- Assets.Load(Content);
230
-
231
- // Start with menu screen
232
- _screenManager.AddScreen(new MenuScreen());
233
- }
234
-
235
- protected override void Update(GameTime gameTime)
236
- {
237
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
238
- Keyboard.GetState().IsKeyDown(Keys.Escape))
239
- {
240
- Exit();
241
- }
242
-
243
- ${useECS ? '_world?.Update(gameTime);' : ''}
244
-
245
- base.Update(gameTime);
246
- }
247
-
248
- protected override void Draw(GameTime gameTime)
249
- {
250
- GraphicsDevice.Clear(Color.CornflowerBlue);
251
-
252
- ${useECS ? '_world?.Draw(gameTime);' : ''}
253
-
254
- base.Draw(gameTime);
255
- }
256
- }
257
- }
258
- `;
259
- this.csharpFiles.set(`${this.config.solutionName}/Game1.cs`, game1);
260
599
  }
261
- generateECSInitialization() {
262
- return `
263
- _world = new WorldBuilder()
264
- .AddSystem(new MovementSystem())
265
- .AddSystem(new CollisionSystem())
266
- .AddSystem(new RenderSystem(_spriteBatch))
267
- .AddSystem(new AnimationSystem())
268
- .Build();`;
600
+
601
+ // ═══════════════════════════════════════════════════════════════
602
+ // ENEMY ENTITY
603
+ // ═══════════════════════════════════════════════════════════════
604
+
605
+ public class EnemyEntity : Entity
606
+ {
607
+ public Enemy EnemyComponent { get; } = new Enemy();
608
+ public Health HealthComponent { get; }
609
+
610
+ private Entity _target;
611
+ private float _stateTimer;
612
+
613
+ public EnemyEntity(Vector2 position, EnemyType type = EnemyType.Basic)
614
+ {
615
+ Transform = new Transform(position);
616
+ Velocity = new Velocity();
617
+ EnemyComponent.Type = type;
618
+
619
+ // Configure based on type
620
+ switch (type)
621
+ {
622
+ case EnemyType.Fast:
623
+ HealthComponent = new Health(50);
624
+ break;
625
+ case EnemyType.Tank:
626
+ HealthComponent = new Health(200);
627
+ break;
628
+ case EnemyType.Boss:
629
+ HealthComponent = new Health(500);
630
+ break;
631
+ default:
632
+ HealthComponent = new Health(100);
633
+ break;
634
+ }
635
+
636
+ Collider = new Collider
637
+ {
638
+ Type = ColliderType.Rectangle,
639
+ Size = new Vector2(32, 32),
640
+ CollisionLayer = 2
641
+ };
642
+ }
643
+
644
+ public void SetTarget(Entity target)
645
+ {
646
+ _target = target;
647
+ }
648
+
649
+ public override void Update(GameTime gameTime)
650
+ {
651
+ float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
652
+
653
+ UpdateAI(dt);
654
+ Transform.Position += Velocity.Linear * dt;
655
+ }
656
+
657
+ private void UpdateAI(float dt)
658
+ {
659
+ if (_target == null) return;
660
+
661
+ float distance = Vector2.Distance(Transform.Position, _target.Transform.Position);
662
+
663
+ switch (EnemyComponent.State)
664
+ {
665
+ case AIState.Idle:
666
+ if (distance < EnemyComponent.DetectionRange)
667
+ {
668
+ EnemyComponent.State = AIState.Chase;
669
+ }
670
+ break;
671
+
672
+ case AIState.Chase:
673
+ if (distance > EnemyComponent.DetectionRange * 1.5f)
674
+ {
675
+ EnemyComponent.State = AIState.Idle;
676
+ Velocity.Linear = Vector2.Zero;
677
+ }
678
+ else if (distance < EnemyComponent.AttackRange)
679
+ {
680
+ EnemyComponent.State = AIState.Attack;
681
+ }
682
+ else
683
+ {
684
+ Vector2 direction = Vector2.Normalize(_target.Transform.Position - Transform.Position);
685
+ float speed = EnemyComponent.Type == EnemyType.Fast ? 150f : 100f;
686
+ Velocity.Linear = direction * speed;
687
+ }
688
+ break;
689
+
690
+ case AIState.Attack:
691
+ if (distance > EnemyComponent.AttackRange * 1.2f)
692
+ {
693
+ EnemyComponent.State = AIState.Chase;
694
+ }
695
+ // Attack logic
696
+ break;
697
+ }
698
+ }
269
699
  }
270
- generateComponents(_project) {
271
- const { namespace } = this.config;
272
- const componentsCs = `using Microsoft.Xna.Framework;
273
- using Microsoft.Xna.Framework.Graphics;
274
-
275
- namespace ${namespace}.Components
276
- {
277
- // ═══════════════════════════════════════════════════════════════
278
- // TRANSFORM
279
- // ═══════════════════════════════════════════════════════════════
280
-
281
- public class Transform
282
- {
283
- public Vector2 Position { get; set; }
284
- public float Rotation { get; set; }
285
- public Vector2 Scale { get; set; } = Vector2.One;
286
- public Vector2 Origin { get; set; }
287
-
288
- public Transform() { }
289
-
290
- public Transform(Vector2 position)
291
- {
292
- Position = position;
293
- }
294
-
295
- public Transform(float x, float y)
296
- {
297
- Position = new Vector2(x, y);
298
- }
299
-
300
- public Matrix TransformMatrix =>
301
- Matrix.CreateTranslation(-Origin.X, -Origin.Y, 0) *
302
- Matrix.CreateScale(Scale.X, Scale.Y, 1) *
303
- Matrix.CreateRotationZ(Rotation) *
304
- Matrix.CreateTranslation(Position.X, Position.Y, 0);
305
- }
306
-
307
- // ═══════════════════════════════════════════════════════════════
308
- // SPRITE
309
- // ═══════════════════════════════════════════════════════════════
310
-
311
- public class Sprite
312
- {
313
- public Texture2D Texture { get; set; }
314
- public Rectangle? SourceRectangle { get; set; }
315
- public Color Color { get; set; } = Color.White;
316
- public SpriteEffects Effects { get; set; } = SpriteEffects.None;
317
- public float LayerDepth { get; set; } = 0.5f;
318
-
319
- public Sprite() { }
320
-
321
- public Sprite(Texture2D texture)
322
- {
323
- Texture = texture;
324
- }
325
-
326
- public Vector2 Size => SourceRectangle.HasValue
327
- ? new Vector2(SourceRectangle.Value.Width, SourceRectangle.Value.Height)
328
- : (Texture != null ? new Vector2(Texture.Width, Texture.Height) : Vector2.Zero);
329
- }
330
-
331
- // ═══════════════════════════════════════════════════════════════
332
- // VELOCITY
333
- // ═══════════════════════════════════════════════════════════════
334
-
335
- public class Velocity
336
- {
337
- public Vector2 Linear { get; set; }
338
- public float Angular { get; set; }
339
-
340
- public Velocity() { }
341
-
342
- public Velocity(Vector2 linear)
343
- {
344
- Linear = linear;
345
- }
346
-
347
- public Velocity(float x, float y)
348
- {
349
- Linear = new Vector2(x, y);
350
- }
351
- }
352
-
353
- // ═══════════════════════════════════════════════════════════════
354
- // COLLIDER
355
- // ═══════════════════════════════════════════════════════════════
356
-
357
- public class Collider
358
- {
359
- public ColliderType Type { get; set; } = ColliderType.Rectangle;
360
- public Vector2 Size { get; set; }
361
- public float Radius { get; set; }
362
- public Vector2 Offset { get; set; }
363
- public bool IsTrigger { get; set; }
364
- public int CollisionLayer { get; set; } = 1;
365
- public int CollisionMask { get; set; } = -1;
366
-
367
- public Rectangle Bounds(Vector2 position) => new Rectangle(
368
- (int)(position.X + Offset.X - Size.X / 2),
369
- (int)(position.Y + Offset.Y - Size.Y / 2),
370
- (int)Size.X,
371
- (int)Size.Y
372
- );
373
- }
374
-
375
- public enum ColliderType
376
- {
377
- Rectangle,
378
- Circle,
379
- Capsule
380
- }
381
-
382
- // ═══════════════════════════════════════════════════════════════
383
- // ANIMATION
384
- // ═══════════════════════════════════════════════════════════════
385
-
386
- public class AnimatedSprite
387
- {
388
- public Texture2D SpriteSheet { get; set; }
389
- public int FrameWidth { get; set; }
390
- public int FrameHeight { get; set; }
391
- public int CurrentFrame { get; set; }
392
- public int FrameCount { get; set; }
393
- public float FrameTime { get; set; } = 0.1f;
394
- public float Timer { get; set; }
395
- public bool IsPlaying { get; set; } = true;
396
- public bool Loop { get; set; } = true;
397
- public int Row { get; set; } // For multi-row spritesheets
398
-
399
- public Rectangle SourceRectangle => new Rectangle(
400
- CurrentFrame * FrameWidth,
401
- Row * FrameHeight,
402
- FrameWidth,
403
- FrameHeight
404
- );
405
-
406
- public void Update(float deltaTime)
407
- {
408
- if (!IsPlaying) return;
409
-
410
- Timer += deltaTime;
411
- if (Timer >= FrameTime)
412
- {
413
- Timer -= FrameTime;
414
- CurrentFrame++;
415
-
416
- if (CurrentFrame >= FrameCount)
417
- {
418
- if (Loop)
419
- CurrentFrame = 0;
420
- else
421
- {
422
- CurrentFrame = FrameCount - 1;
423
- IsPlaying = false;
424
- }
425
- }
426
- }
427
- }
428
- }
429
-
430
- // ═══════════════════════════════════════════════════════════════
431
- // GAMEPLAY
432
- // ═══════════════════════════════════════════════════════════════
433
-
434
- public class Health
435
- {
436
- public float Current { get; set; }
437
- public float Max { get; set; }
438
-
439
- public Health(float max)
440
- {
441
- Max = max;
442
- Current = max;
443
- }
444
-
445
- public float Percentage => Current / Max;
446
- public bool IsDead => Current <= 0;
447
-
448
- public bool TakeDamage(float amount)
449
- {
450
- Current = MathHelper.Max(0, Current - amount);
451
- return IsDead;
452
- }
453
-
454
- public void Heal(float amount)
455
- {
456
- Current = MathHelper.Min(Max, Current + amount);
457
- }
458
- }
459
-
460
- public class Player
461
- {
462
- public int PlayerId { get; set; }
463
- public int Score { get; set; }
464
- public float Speed { get; set; } = 200f;
465
- public bool CanJump { get; set; } = true;
466
- }
467
-
468
- public class Enemy
469
- {
470
- public EnemyType Type { get; set; }
471
- public AIState State { get; set; } = AIState.Idle;
472
- public float DetectionRange { get; set; } = 200f;
473
- public float AttackRange { get; set; } = 50f;
474
- }
475
-
476
- public enum EnemyType
477
- {
478
- Basic,
479
- Fast,
480
- Tank,
481
- Boss
482
- }
483
-
484
- public enum AIState
485
- {
486
- Idle,
487
- Patrol,
488
- Chase,
489
- Attack,
490
- Flee,
491
- Dead
492
- }
493
- }
700
+ }
494
701
  `;
495
- this.csharpFiles.set(`${this.config.solutionName}/Components/Components.cs`, componentsCs);
702
+ this.csharpFiles.set(`${this.config.solutionName}/Entities/Entities.cs`, entitiesCs);
703
+ }
704
+ generateSystems(_project) {
705
+ const { namespace } = this.config;
706
+ const systemsCs = `using Microsoft.Xna.Framework;
707
+ using Microsoft.Xna.Framework.Graphics;
708
+ using MonoGame.Extended.Entities;
709
+ using MonoGame.Extended.Entities.Systems;
710
+ using ${namespace}.Components;
711
+
712
+ namespace ${namespace}.Systems
713
+ {
714
+ // ═══════════════════════════════════════════════════════════════
715
+ // MOVEMENT SYSTEM
716
+ // ═══════════════════════════════════════════════════════════════
717
+
718
+ public class MovementSystem : EntityUpdateSystem
719
+ {
720
+ private ComponentMapper<Transform> _transformMapper;
721
+ private ComponentMapper<Velocity> _velocityMapper;
722
+
723
+ public MovementSystem()
724
+ : base(Aspect.All(typeof(Transform), typeof(Velocity)))
725
+ {
726
+ }
727
+
728
+ public override void Initialize(IComponentMapperService mapperService)
729
+ {
730
+ _transformMapper = mapperService.GetMapper<Transform>();
731
+ _velocityMapper = mapperService.GetMapper<Velocity>();
732
+ }
733
+
734
+ public override void Update(GameTime gameTime)
735
+ {
736
+ float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
737
+
738
+ foreach (int entityId in ActiveEntities)
739
+ {
740
+ var transform = _transformMapper.Get(entityId);
741
+ var velocity = _velocityMapper.Get(entityId);
742
+
743
+ transform.Position += velocity.Linear * dt;
744
+ transform.Rotation += velocity.Angular * dt;
745
+ }
746
+ }
496
747
  }
497
- generateEntities(_project) {
498
- const { namespace } = this.config;
499
- const entitiesCs = `using Microsoft.Xna.Framework;
500
- using Microsoft.Xna.Framework.Graphics;
501
- using ${namespace}.Components;
502
-
503
- namespace ${namespace}.Entities
504
- {
505
- // ═══════════════════════════════════════════════════════════════
506
- // BASE ENTITY
507
- // ═══════════════════════════════════════════════════════════════
508
-
509
- public abstract class Entity
510
- {
511
- public int Id { get; protected set; }
512
- public bool IsActive { get; set; } = true;
513
- public bool IsDestroyed { get; private set; }
514
-
515
- public Transform Transform { get; set; } = new Transform();
516
- public Sprite Sprite { get; set; }
517
- public Velocity Velocity { get; set; }
518
- public Collider Collider { get; set; }
519
-
520
- private static int _nextId = 0;
521
-
522
- protected Entity()
523
- {
524
- Id = _nextId++;
525
- }
526
-
527
- public virtual void Update(GameTime gameTime) { }
528
-
529
- public virtual void Draw(SpriteBatch spriteBatch)
530
- {
531
- if (Sprite?.Texture == null) return;
532
-
533
- spriteBatch.Draw(
534
- Sprite.Texture,
535
- Transform.Position,
536
- Sprite.SourceRectangle,
537
- Sprite.Color,
538
- Transform.Rotation,
539
- Transform.Origin,
540
- Transform.Scale,
541
- Sprite.Effects,
542
- Sprite.LayerDepth
543
- );
544
- }
545
-
546
- public void Destroy()
547
- {
548
- IsDestroyed = true;
549
- OnDestroy();
550
- }
551
-
552
- protected virtual void OnDestroy() { }
553
- }
554
-
555
- // ═══════════════════════════════════════════════════════════════
556
- // PLAYER ENTITY
557
- // ═══════════════════════════════════════════════════════════════
558
-
559
- public class PlayerEntity : Entity
560
- {
561
- public Player PlayerComponent { get; } = new Player();
562
- public Health HealthComponent { get; } = new Health(100);
563
- public AnimatedSprite AnimatedSprite { get; set; }
564
-
565
- private bool _isGrounded;
566
- private const float Gravity = 980f;
567
- private const float JumpForce = -400f;
568
-
569
- public PlayerEntity(Vector2 position)
570
- {
571
- Transform = new Transform(position);
572
- Velocity = new Velocity();
573
- Collider = new Collider
574
- {
575
- Type = ColliderType.Rectangle,
576
- Size = new Vector2(32, 48),
577
- CollisionLayer = 1
578
- };
579
- }
580
-
581
- public override void Update(GameTime gameTime)
582
- {
583
- float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
584
-
585
- // Gravity
586
- if (!_isGrounded)
587
- {
588
- Velocity.Linear = new Vector2(Velocity.Linear.X, Velocity.Linear.Y + Gravity * dt);
589
- }
590
-
591
- // Apply velocity
592
- Transform.Position += Velocity.Linear * dt;
593
-
594
- // Update animation
595
- AnimatedSprite?.Update(dt);
596
- }
597
-
598
- public void Move(Vector2 direction)
599
- {
600
- Velocity.Linear = new Vector2(direction.X * PlayerComponent.Speed, Velocity.Linear.Y);
601
- }
602
-
603
- public void Jump()
604
- {
605
- if (_isGrounded && PlayerComponent.CanJump)
606
- {
607
- Velocity.Linear = new Vector2(Velocity.Linear.X, JumpForce);
608
- _isGrounded = false;
609
- }
610
- }
611
-
612
- public void OnGrounded()
613
- {
614
- _isGrounded = true;
615
- Velocity.Linear = new Vector2(Velocity.Linear.X, 0);
616
- }
617
- }
618
-
619
- // ═══════════════════════════════════════════════════════════════
620
- // ENEMY ENTITY
621
- // ═══════════════════════════════════════════════════════════════
622
-
623
- public class EnemyEntity : Entity
624
- {
625
- public Enemy EnemyComponent { get; } = new Enemy();
626
- public Health HealthComponent { get; }
627
-
628
- private Entity _target;
629
- private float _stateTimer;
630
-
631
- public EnemyEntity(Vector2 position, EnemyType type = EnemyType.Basic)
632
- {
633
- Transform = new Transform(position);
634
- Velocity = new Velocity();
635
- EnemyComponent.Type = type;
636
-
637
- // Configure based on type
638
- switch (type)
639
- {
640
- case EnemyType.Fast:
641
- HealthComponent = new Health(50);
642
- break;
643
- case EnemyType.Tank:
644
- HealthComponent = new Health(200);
645
- break;
646
- case EnemyType.Boss:
647
- HealthComponent = new Health(500);
648
- break;
649
- default:
650
- HealthComponent = new Health(100);
651
- break;
652
- }
653
-
654
- Collider = new Collider
655
- {
656
- Type = ColliderType.Rectangle,
657
- Size = new Vector2(32, 32),
658
- CollisionLayer = 2
659
- };
660
- }
661
-
662
- public void SetTarget(Entity target)
663
- {
664
- _target = target;
665
- }
666
-
667
- public override void Update(GameTime gameTime)
668
- {
669
- float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
670
-
671
- UpdateAI(dt);
672
- Transform.Position += Velocity.Linear * dt;
673
- }
674
-
675
- private void UpdateAI(float dt)
676
- {
677
- if (_target == null) return;
678
-
679
- float distance = Vector2.Distance(Transform.Position, _target.Transform.Position);
680
-
681
- switch (EnemyComponent.State)
682
- {
683
- case AIState.Idle:
684
- if (distance < EnemyComponent.DetectionRange)
685
- {
686
- EnemyComponent.State = AIState.Chase;
687
- }
688
- break;
689
-
690
- case AIState.Chase:
691
- if (distance > EnemyComponent.DetectionRange * 1.5f)
692
- {
693
- EnemyComponent.State = AIState.Idle;
694
- Velocity.Linear = Vector2.Zero;
695
- }
696
- else if (distance < EnemyComponent.AttackRange)
697
- {
698
- EnemyComponent.State = AIState.Attack;
699
- }
700
- else
701
- {
702
- Vector2 direction = Vector2.Normalize(_target.Transform.Position - Transform.Position);
703
- float speed = EnemyComponent.Type == EnemyType.Fast ? 150f : 100f;
704
- Velocity.Linear = direction * speed;
705
- }
706
- break;
707
-
708
- case AIState.Attack:
709
- if (distance > EnemyComponent.AttackRange * 1.2f)
710
- {
711
- EnemyComponent.State = AIState.Chase;
712
- }
713
- // Attack logic
714
- break;
715
- }
716
- }
717
- }
718
- }
719
- `;
720
- this.csharpFiles.set(`${this.config.solutionName}/Entities/Entities.cs`, entitiesCs);
748
+
749
+ // ═══════════════════════════════════════════════════════════════
750
+ // COLLISION SYSTEM
751
+ // ═══════════════════════════════════════════════════════════════
752
+
753
+ public class CollisionSystem : EntityUpdateSystem
754
+ {
755
+ private ComponentMapper<Transform> _transformMapper;
756
+ private ComponentMapper<Collider> _colliderMapper;
757
+
758
+ public CollisionSystem()
759
+ : base(Aspect.All(typeof(Transform), typeof(Collider)))
760
+ {
761
+ }
762
+
763
+ public override void Initialize(IComponentMapperService mapperService)
764
+ {
765
+ _transformMapper = mapperService.GetMapper<Transform>();
766
+ _colliderMapper = mapperService.GetMapper<Collider>();
767
+ }
768
+
769
+ public override void Update(GameTime gameTime)
770
+ {
771
+ var entities = ActiveEntities.ToArray();
772
+
773
+ for (int i = 0; i < entities.Length; i++)
774
+ {
775
+ var transformA = _transformMapper.Get(entities[i]);
776
+ var colliderA = _colliderMapper.Get(entities[i]);
777
+ var boundsA = colliderA.Bounds(transformA.Position);
778
+
779
+ for (int j = i + 1; j < entities.Length; j++)
780
+ {
781
+ var transformB = _transformMapper.Get(entities[j]);
782
+ var colliderB = _colliderMapper.Get(entities[j]);
783
+ var boundsB = colliderB.Bounds(transformB.Position);
784
+
785
+ // Check layer/mask
786
+ if ((colliderA.CollisionLayer & colliderB.CollisionMask) == 0 ||
787
+ (colliderB.CollisionLayer & colliderA.CollisionMask) == 0)
788
+ continue;
789
+
790
+ if (boundsA.Intersects(boundsB))
791
+ {
792
+ OnCollision(entities[i], entities[j], colliderA, colliderB);
793
+ }
794
+ }
795
+ }
796
+ }
797
+
798
+ private void OnCollision(int entityA, int entityB, Collider colliderA, Collider colliderB)
799
+ {
800
+ if (colliderA.IsTrigger || colliderB.IsTrigger)
801
+ {
802
+ // Trigger event
803
+ }
804
+ else
805
+ {
806
+ // Physical collision
807
+ }
808
+ }
721
809
  }
722
- generateSystems(_project) {
723
- const { namespace } = this.config;
724
- const systemsCs = `using Microsoft.Xna.Framework;
725
- using Microsoft.Xna.Framework.Graphics;
726
- using MonoGame.Extended.Entities;
727
- using MonoGame.Extended.Entities.Systems;
728
- using ${namespace}.Components;
729
-
730
- namespace ${namespace}.Systems
731
- {
732
- // ═══════════════════════════════════════════════════════════════
733
- // MOVEMENT SYSTEM
734
- // ═══════════════════════════════════════════════════════════════
735
-
736
- public class MovementSystem : EntityUpdateSystem
737
- {
738
- private ComponentMapper<Transform> _transformMapper;
739
- private ComponentMapper<Velocity> _velocityMapper;
740
-
741
- public MovementSystem()
742
- : base(Aspect.All(typeof(Transform), typeof(Velocity)))
743
- {
744
- }
745
-
746
- public override void Initialize(IComponentMapperService mapperService)
747
- {
748
- _transformMapper = mapperService.GetMapper<Transform>();
749
- _velocityMapper = mapperService.GetMapper<Velocity>();
750
- }
751
-
752
- public override void Update(GameTime gameTime)
753
- {
754
- float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
755
-
756
- foreach (int entityId in ActiveEntities)
757
- {
758
- var transform = _transformMapper.Get(entityId);
759
- var velocity = _velocityMapper.Get(entityId);
760
-
761
- transform.Position += velocity.Linear * dt;
762
- transform.Rotation += velocity.Angular * dt;
763
- }
764
- }
765
- }
766
-
767
- // ═══════════════════════════════════════════════════════════════
768
- // COLLISION SYSTEM
769
- // ═══════════════════════════════════════════════════════════════
770
-
771
- public class CollisionSystem : EntityUpdateSystem
772
- {
773
- private ComponentMapper<Transform> _transformMapper;
774
- private ComponentMapper<Collider> _colliderMapper;
775
-
776
- public CollisionSystem()
777
- : base(Aspect.All(typeof(Transform), typeof(Collider)))
778
- {
779
- }
780
-
781
- public override void Initialize(IComponentMapperService mapperService)
782
- {
783
- _transformMapper = mapperService.GetMapper<Transform>();
784
- _colliderMapper = mapperService.GetMapper<Collider>();
785
- }
786
-
787
- public override void Update(GameTime gameTime)
788
- {
789
- var entities = ActiveEntities.ToArray();
790
-
791
- for (int i = 0; i < entities.Length; i++)
792
- {
793
- var transformA = _transformMapper.Get(entities[i]);
794
- var colliderA = _colliderMapper.Get(entities[i]);
795
- var boundsA = colliderA.Bounds(transformA.Position);
796
-
797
- for (int j = i + 1; j < entities.Length; j++)
798
- {
799
- var transformB = _transformMapper.Get(entities[j]);
800
- var colliderB = _colliderMapper.Get(entities[j]);
801
- var boundsB = colliderB.Bounds(transformB.Position);
802
-
803
- // Check layer/mask
804
- if ((colliderA.CollisionLayer & colliderB.CollisionMask) == 0 ||
805
- (colliderB.CollisionLayer & colliderA.CollisionMask) == 0)
806
- continue;
807
-
808
- if (boundsA.Intersects(boundsB))
809
- {
810
- OnCollision(entities[i], entities[j], colliderA, colliderB);
811
- }
812
- }
813
- }
814
- }
815
-
816
- private void OnCollision(int entityA, int entityB, Collider colliderA, Collider colliderB)
817
- {
818
- if (colliderA.IsTrigger || colliderB.IsTrigger)
819
- {
820
- // Trigger event
821
- }
822
- else
823
- {
824
- // Physical collision
825
- }
826
- }
827
- }
828
-
829
- // ═══════════════════════════════════════════════════════════════
830
- // RENDER SYSTEM
831
- // ═══════════════════════════════════════════════════════════════
832
-
833
- public class RenderSystem : EntityDrawSystem
834
- {
835
- private SpriteBatch _spriteBatch;
836
- private ComponentMapper<Transform> _transformMapper;
837
- private ComponentMapper<Sprite> _spriteMapper;
838
-
839
- public RenderSystem(SpriteBatch spriteBatch)
840
- : base(Aspect.All(typeof(Transform), typeof(Sprite)))
841
- {
842
- _spriteBatch = spriteBatch;
843
- }
844
-
845
- public override void Initialize(IComponentMapperService mapperService)
846
- {
847
- _transformMapper = mapperService.GetMapper<Transform>();
848
- _spriteMapper = mapperService.GetMapper<Sprite>();
849
- }
850
-
851
- public override void Draw(GameTime gameTime)
852
- {
853
- _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
854
-
855
- foreach (int entityId in ActiveEntities)
856
- {
857
- var transform = _transformMapper.Get(entityId);
858
- var sprite = _spriteMapper.Get(entityId);
859
-
860
- if (sprite.Texture == null) continue;
861
-
862
- _spriteBatch.Draw(
863
- sprite.Texture,
864
- transform.Position,
865
- sprite.SourceRectangle,
866
- sprite.Color,
867
- transform.Rotation,
868
- transform.Origin,
869
- transform.Scale,
870
- sprite.Effects,
871
- sprite.LayerDepth
872
- );
873
- }
874
-
875
- _spriteBatch.End();
876
- }
877
- }
878
-
879
- // ═══════════════════════════════════════════════════════════════
880
- // ANIMATION SYSTEM
881
- // ═══════════════════════════════════════════════════════════════
882
-
883
- public class AnimationSystem : EntityUpdateSystem
884
- {
885
- private ComponentMapper<AnimatedSprite> _animationMapper;
886
- private ComponentMapper<Sprite> _spriteMapper;
887
-
888
- public AnimationSystem()
889
- : base(Aspect.All(typeof(AnimatedSprite), typeof(Sprite)))
890
- {
891
- }
892
-
893
- public override void Initialize(IComponentMapperService mapperService)
894
- {
895
- _animationMapper = mapperService.GetMapper<AnimatedSprite>();
896
- _spriteMapper = mapperService.GetMapper<Sprite>();
897
- }
898
-
899
- public override void Update(GameTime gameTime)
900
- {
901
- float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
902
-
903
- foreach (int entityId in ActiveEntities)
904
- {
905
- var animation = _animationMapper.Get(entityId);
906
- var sprite = _spriteMapper.Get(entityId);
907
-
908
- animation.Update(dt);
909
- sprite.SourceRectangle = animation.SourceRectangle;
910
- }
911
- }
912
- }
913
- }
914
- `;
915
- this.csharpFiles.set(`${this.config.solutionName}/Systems/Systems.cs`, systemsCs);
810
+
811
+ // ═══════════════════════════════════════════════════════════════
812
+ // RENDER SYSTEM
813
+ // ═══════════════════════════════════════════════════════════════
814
+
815
+ public class RenderSystem : EntityDrawSystem
816
+ {
817
+ private SpriteBatch _spriteBatch;
818
+ private ComponentMapper<Transform> _transformMapper;
819
+ private ComponentMapper<Sprite> _spriteMapper;
820
+
821
+ public RenderSystem(SpriteBatch spriteBatch)
822
+ : base(Aspect.All(typeof(Transform), typeof(Sprite)))
823
+ {
824
+ _spriteBatch = spriteBatch;
825
+ }
826
+
827
+ public override void Initialize(IComponentMapperService mapperService)
828
+ {
829
+ _transformMapper = mapperService.GetMapper<Transform>();
830
+ _spriteMapper = mapperService.GetMapper<Sprite>();
831
+ }
832
+
833
+ public override void Draw(GameTime gameTime)
834
+ {
835
+ _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
836
+
837
+ foreach (int entityId in ActiveEntities)
838
+ {
839
+ var transform = _transformMapper.Get(entityId);
840
+ var sprite = _spriteMapper.Get(entityId);
841
+
842
+ if (sprite.Texture == null) continue;
843
+
844
+ _spriteBatch.Draw(
845
+ sprite.Texture,
846
+ transform.Position,
847
+ sprite.SourceRectangle,
848
+ sprite.Color,
849
+ transform.Rotation,
850
+ transform.Origin,
851
+ transform.Scale,
852
+ sprite.Effects,
853
+ sprite.LayerDepth
854
+ );
855
+ }
856
+
857
+ _spriteBatch.End();
858
+ }
916
859
  }
917
- generateScreens(_project) {
918
- const { namespace } = this.config;
919
- const screensCs = `using Microsoft.Xna.Framework;
920
- using Microsoft.Xna.Framework.Content;
921
- using Microsoft.Xna.Framework.Graphics;
922
- using Microsoft.Xna.Framework.Input;
923
-
924
- namespace ${namespace}.Screens
925
- {
926
- // ═══════════════════════════════════════════════════════════════
927
- // SCREEN BASE
928
- // ═══════════════════════════════════════════════════════════════
929
-
930
- public abstract class Screen
931
- {
932
- public ScreenManager ScreenManager { get; internal set; }
933
- public bool IsActive { get; set; } = true;
934
- public bool IsPopup { get; protected set; }
935
-
936
- protected ContentManager Content => ScreenManager.Game.Content;
937
- protected GraphicsDevice GraphicsDevice => ScreenManager.GraphicsDevice;
938
-
939
- public virtual void LoadContent() { }
940
- public virtual void UnloadContent() { }
941
- public virtual void Update(GameTime gameTime) { }
942
- public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch) { }
943
-
944
- public virtual void HandleInput(InputState input) { }
945
-
946
- public void ExitScreen()
947
- {
948
- ScreenManager.RemoveScreen(this);
949
- }
950
- }
951
-
952
- // ═══════════════════════════════════════════════════════════════
953
- // SCREEN MANAGER
954
- // ═══════════════════════════════════════════════════════════════
955
-
956
- public class ScreenManager : DrawableGameComponent
957
- {
958
- private readonly List<Screen> _screens = new();
959
- private readonly List<Screen> _screensToAdd = new();
960
- private readonly List<Screen> _screensToRemove = new();
961
- private SpriteBatch _spriteBatch;
962
- private InputState _input = new();
963
-
964
- public new Game Game { get; }
965
-
966
- public ScreenManager(Game game) : base(game)
967
- {
968
- Game = game;
969
- }
970
-
971
- protected override void LoadContent()
972
- {
973
- _spriteBatch = new SpriteBatch(GraphicsDevice);
974
- }
975
-
976
- public override void Update(GameTime gameTime)
977
- {
978
- _input.Update();
979
-
980
- // Add pending screens
981
- foreach (var screen in _screensToAdd)
982
- {
983
- screen.LoadContent();
984
- _screens.Add(screen);
985
- }
986
- _screensToAdd.Clear();
987
-
988
- // Remove pending screens
989
- foreach (var screen in _screensToRemove)
990
- {
991
- screen.UnloadContent();
992
- _screens.Remove(screen);
993
- }
994
- _screensToRemove.Clear();
995
-
996
- // Update screens
997
- foreach (var screen in _screens)
998
- {
999
- if (screen.IsActive)
1000
- {
1001
- screen.HandleInput(_input);
1002
- screen.Update(gameTime);
1003
- }
1004
- }
1005
- }
1006
-
1007
- public override void Draw(GameTime gameTime)
1008
- {
1009
- foreach (var screen in _screens)
1010
- {
1011
- if (screen.IsActive)
1012
- {
1013
- screen.Draw(gameTime, _spriteBatch);
1014
- }
1015
- }
1016
- }
1017
-
1018
- public void AddScreen(Screen screen)
1019
- {
1020
- screen.ScreenManager = this;
1021
- _screensToAdd.Add(screen);
1022
- }
1023
-
1024
- public void RemoveScreen(Screen screen)
1025
- {
1026
- _screensToRemove.Add(screen);
1027
- }
1028
- }
1029
-
1030
- // ═══════════════════════════════════════════════════════════════
1031
- // INPUT STATE
1032
- // ═══════════════════════════════════════════════════════════════
1033
-
1034
- public class InputState
1035
- {
1036
- public KeyboardState CurrentKeyboardState { get; private set; }
1037
- public KeyboardState PreviousKeyboardState { get; private set; }
1038
- public MouseState CurrentMouseState { get; private set; }
1039
- public MouseState PreviousMouseState { get; private set; }
1040
- public GamePadState CurrentGamePadState { get; private set; }
1041
- public GamePadState PreviousGamePadState { get; private set; }
1042
-
1043
- public void Update()
1044
- {
1045
- PreviousKeyboardState = CurrentKeyboardState;
1046
- PreviousMouseState = CurrentMouseState;
1047
- PreviousGamePadState = CurrentGamePadState;
1048
-
1049
- CurrentKeyboardState = Keyboard.GetState();
1050
- CurrentMouseState = Mouse.GetState();
1051
- CurrentGamePadState = GamePad.GetState(PlayerIndex.One);
1052
- }
1053
-
1054
- public bool IsKeyPressed(Keys key) =>
1055
- CurrentKeyboardState.IsKeyDown(key) && PreviousKeyboardState.IsKeyUp(key);
1056
-
1057
- public bool IsKeyHeld(Keys key) =>
1058
- CurrentKeyboardState.IsKeyDown(key);
1059
-
1060
- public bool IsKeyReleased(Keys key) =>
1061
- CurrentKeyboardState.IsKeyUp(key) && PreviousKeyboardState.IsKeyDown(key);
1062
-
1063
- public Vector2 GetMovement()
1064
- {
1065
- Vector2 movement = Vector2.Zero;
1066
-
1067
- if (IsKeyHeld(Keys.W) || IsKeyHeld(Keys.Up)) movement.Y -= 1;
1068
- if (IsKeyHeld(Keys.S) || IsKeyHeld(Keys.Down)) movement.Y += 1;
1069
- if (IsKeyHeld(Keys.A) || IsKeyHeld(Keys.Left)) movement.X -= 1;
1070
- if (IsKeyHeld(Keys.D) || IsKeyHeld(Keys.Right)) movement.X += 1;
1071
-
1072
- if (movement != Vector2.Zero)
1073
- movement = Vector2.Normalize(movement);
1074
-
1075
- return movement;
1076
- }
1077
- }
1078
-
1079
- // ═══════════════════════════════════════════════════════════════
1080
- // MENU SCREEN
1081
- // ═══════════════════════════════════════════════════════════════
1082
-
1083
- public class MenuScreen : Screen
1084
- {
1085
- private SpriteFont _font;
1086
- private int _selectedIndex;
1087
- private string[] _menuItems = { "Play", "Options", "Exit" };
1088
-
1089
- public override void LoadContent()
1090
- {
1091
- _font = Content.Load<SpriteFont>("Fonts/MenuFont");
1092
- }
1093
-
1094
- public override void HandleInput(InputState input)
1095
- {
1096
- if (input.IsKeyPressed(Keys.Up))
1097
- {
1098
- _selectedIndex--;
1099
- if (_selectedIndex < 0) _selectedIndex = _menuItems.Length - 1;
1100
- }
1101
-
1102
- if (input.IsKeyPressed(Keys.Down))
1103
- {
1104
- _selectedIndex++;
1105
- if (_selectedIndex >= _menuItems.Length) _selectedIndex = 0;
1106
- }
1107
-
1108
- if (input.IsKeyPressed(Keys.Enter))
1109
- {
1110
- switch (_selectedIndex)
1111
- {
1112
- case 0: // Play
1113
- ScreenManager.AddScreen(new GameplayScreen());
1114
- ExitScreen();
1115
- break;
1116
- case 1: // Options
1117
- // Options screen
1118
- break;
1119
- case 2: // Exit
1120
- ScreenManager.Game.Exit();
1121
- break;
1122
- }
1123
- }
1124
- }
1125
-
1126
- public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
1127
- {
1128
- spriteBatch.Begin();
1129
-
1130
- for (int i = 0; i < _menuItems.Length; i++)
1131
- {
1132
- Color color = i == _selectedIndex ? Color.Yellow : Color.White;
1133
- Vector2 position = new Vector2(640 - _font.MeasureString(_menuItems[i]).X / 2, 300 + i * 50);
1134
- spriteBatch.DrawString(_font, _menuItems[i], position, color);
1135
- }
1136
-
1137
- spriteBatch.End();
1138
- }
1139
- }
1140
-
1141
- // ═══════════════════════════════════════════════════════════════
1142
- // GAMEPLAY SCREEN
1143
- // ═══════════════════════════════════════════════════════════════
1144
-
1145
- public class GameplayScreen : Screen
1146
- {
1147
- public override void LoadContent()
1148
- {
1149
- // Load level content
1150
- }
1151
-
1152
- public override void HandleInput(InputState input)
1153
- {
1154
- if (input.IsKeyPressed(Keys.Escape))
1155
- {
1156
- ScreenManager.AddScreen(new PauseScreen());
1157
- }
1158
-
1159
- Vector2 movement = input.GetMovement();
1160
- // Apply to player
1161
- }
1162
-
1163
- public override void Update(GameTime gameTime)
1164
- {
1165
- // Update game logic
1166
- }
1167
-
1168
- public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
1169
- {
1170
- spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
1171
-
1172
- // Draw game
1173
-
1174
- spriteBatch.End();
1175
- }
1176
- }
1177
-
1178
- // ═══════════════════════════════════════════════════════════════
1179
- // PAUSE SCREEN
1180
- // ═══════════════════════════════════════════════════════════════
1181
-
1182
- public class PauseScreen : Screen
1183
- {
1184
- public PauseScreen()
1185
- {
1186
- IsPopup = true;
1187
- }
1188
-
1189
- public override void HandleInput(InputState input)
1190
- {
1191
- if (input.IsKeyPressed(Keys.Escape))
1192
- {
1193
- ExitScreen();
1194
- }
1195
- }
1196
-
1197
- public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
1198
- {
1199
- spriteBatch.Begin();
1200
-
1201
- // Draw semi-transparent overlay
1202
- spriteBatch.Draw(
1203
- Assets.PixelTexture,
1204
- new Rectangle(0, 0, Game1.ScreenWidth, Game1.ScreenHeight),
1205
- new Color(0, 0, 0, 0.5f)
1206
- );
1207
-
1208
- // Draw pause text
1209
-
1210
- spriteBatch.End();
1211
- }
1212
- }
1213
- }
1214
- `;
1215
- this.csharpFiles.set(`${this.config.solutionName}/Screens/Screens.cs`, screensCs);
1216
- // Generate Assets class
1217
- const assetsCs = `using Microsoft.Xna.Framework;
1218
- using Microsoft.Xna.Framework.Content;
1219
- using Microsoft.Xna.Framework.Graphics;
1220
-
1221
- namespace ${namespace}
1222
- {
1223
- public static class Assets
1224
- {
1225
- // Textures
1226
- public static Texture2D PixelTexture { get; private set; }
1227
- public static Texture2D PlayerTexture { get; private set; }
1228
- public static Texture2D EnemyTexture { get; private set; }
1229
- public static Texture2D TilesetTexture { get; private set; }
1230
-
1231
- // Fonts
1232
- public static SpriteFont MenuFont { get; private set; }
1233
- public static SpriteFont GameFont { get; private set; }
1234
-
1235
- public static void Load(ContentManager content)
1236
- {
1237
- // Create pixel texture
1238
- PixelTexture = new Texture2D(Game1.Instance.GraphicsDevice, 1, 1);
1239
- PixelTexture.SetData(new[] { Color.White });
1240
-
1241
- // Load textures
1242
- PlayerTexture = content.Load<Texture2D>("Sprites/player");
1243
- EnemyTexture = content.Load<Texture2D>("Sprites/enemy");
1244
- TilesetTexture = content.Load<Texture2D>("Sprites/tileset");
1245
-
1246
- // Load fonts
1247
- MenuFont = content.Load<SpriteFont>("Fonts/MenuFont");
1248
- GameFont = content.Load<SpriteFont>("Fonts/GameFont");
1249
- }
1250
- }
1251
- }
1252
- `;
1253
- this.csharpFiles.set(`${this.config.solutionName}/Assets.cs`, assetsCs);
860
+
861
+ // ═══════════════════════════════════════════════════════════════
862
+ // ANIMATION SYSTEM
863
+ // ═══════════════════════════════════════════════════════════════
864
+
865
+ public class AnimationSystem : EntityUpdateSystem
866
+ {
867
+ private ComponentMapper<AnimatedSprite> _animationMapper;
868
+ private ComponentMapper<Sprite> _spriteMapper;
869
+
870
+ public AnimationSystem()
871
+ : base(Aspect.All(typeof(AnimatedSprite), typeof(Sprite)))
872
+ {
873
+ }
874
+
875
+ public override void Initialize(IComponentMapperService mapperService)
876
+ {
877
+ _animationMapper = mapperService.GetMapper<AnimatedSprite>();
878
+ _spriteMapper = mapperService.GetMapper<Sprite>();
879
+ }
880
+
881
+ public override void Update(GameTime gameTime)
882
+ {
883
+ float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
884
+
885
+ foreach (int entityId in ActiveEntities)
886
+ {
887
+ var animation = _animationMapper.Get(entityId);
888
+ var sprite = _spriteMapper.Get(entityId);
889
+
890
+ animation.Update(dt);
891
+ sprite.SourceRectangle = animation.SourceRectangle;
892
+ }
893
+ }
1254
894
  }
1255
- generateContentMgcb(project) {
1256
- let mgcb = `#----------------------------- Global Properties ----------------------------#
1257
-
1258
- /outputDir:bin/$(Platform)
1259
- /intermediateDir:obj/$(Platform)
1260
- /platform:DesktopGL
1261
- /config:
1262
- /profile:Reach
1263
- /compress:False
1264
-
1265
- #-------------------------------- References --------------------------------#
1266
-
1267
- /reference:..\\..\\packages\\MonoGame.Extended.Content.Pipeline\\4.0.0\\tools\\MonoGame.Extended.Content.Pipeline.dll
1268
-
1269
- #---------------------------------- Content ---------------------------------#
1270
-
1271
- #begin Fonts/MenuFont.spritefont
1272
- /importer:FontDescriptionImporter
1273
- /processor:FontDescriptionProcessor
1274
- /processorParam:PremultiplyAlpha=True
1275
- /processorParam:TextureFormat=Compressed
1276
- /build:Fonts/MenuFont.spritefont
1277
-
1278
- #begin Fonts/GameFont.spritefont
1279
- /importer:FontDescriptionImporter
1280
- /processor:FontDescriptionProcessor
1281
- /processorParam:PremultiplyAlpha=True
1282
- /processorParam:TextureFormat=Compressed
1283
- /build:Fonts/GameFont.spritefont
895
+ }
1284
896
  `;
1285
- // Add project assets
1286
- if (project.assets) {
1287
- for (const asset of project.assets) {
1288
- const ext = asset.name.split('.').pop()?.toLowerCase();
1289
- let processor = 'TextureProcessor';
1290
- let importer = 'TextureImporter';
1291
- if (ext === 'ogg' || ext === 'wav' || ext === 'mp3') {
1292
- processor = 'SoundEffectProcessor';
1293
- importer = 'OggImporter';
897
+ this.csharpFiles.set(`${this.config.solutionName}/Systems/Systems.cs`, systemsCs);
898
+ }
899
+ generateScreens(_project) {
900
+ const { namespace } = this.config;
901
+ const screensCs = `using Microsoft.Xna.Framework;
902
+ using Microsoft.Xna.Framework.Content;
903
+ using Microsoft.Xna.Framework.Graphics;
904
+ using Microsoft.Xna.Framework.Input;
905
+
906
+ namespace ${namespace}.Screens
907
+ {
908
+ // ═══════════════════════════════════════════════════════════════
909
+ // SCREEN BASE
910
+ // ═══════════════════════════════════════════════════════════════
911
+
912
+ public abstract class Screen
913
+ {
914
+ public ScreenManager ScreenManager { get; internal set; }
915
+ public bool IsActive { get; set; } = true;
916
+ public bool IsPopup { get; protected set; }
917
+
918
+ protected ContentManager Content => ScreenManager.Game.Content;
919
+ protected GraphicsDevice GraphicsDevice => ScreenManager.GraphicsDevice;
920
+
921
+ public virtual void LoadContent() { }
922
+ public virtual void UnloadContent() { }
923
+ public virtual void Update(GameTime gameTime) { }
924
+ public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch) { }
925
+
926
+ public virtual void HandleInput(InputState input) { }
927
+
928
+ public void ExitScreen()
929
+ {
930
+ ScreenManager.RemoveScreen(this);
931
+ }
932
+ }
933
+
934
+ // ═══════════════════════════════════════════════════════════════
935
+ // SCREEN MANAGER
936
+ // ═══════════════════════════════════════════════════════════════
937
+
938
+ public class ScreenManager : DrawableGameComponent
939
+ {
940
+ private readonly List<Screen> _screens = new();
941
+ private readonly List<Screen> _screensToAdd = new();
942
+ private readonly List<Screen> _screensToRemove = new();
943
+ private SpriteBatch _spriteBatch;
944
+ private InputState _input = new();
945
+
946
+ public new Game Game { get; }
947
+
948
+ public ScreenManager(Game game) : base(game)
949
+ {
950
+ Game = game;
951
+ }
952
+
953
+ protected override void LoadContent()
954
+ {
955
+ _spriteBatch = new SpriteBatch(GraphicsDevice);
956
+ }
957
+
958
+ public override void Update(GameTime gameTime)
959
+ {
960
+ _input.Update();
961
+
962
+ // Add pending screens
963
+ foreach (var screen in _screensToAdd)
964
+ {
965
+ screen.LoadContent();
966
+ _screens.Add(screen);
967
+ }
968
+ _screensToAdd.Clear();
969
+
970
+ // Remove pending screens
971
+ foreach (var screen in _screensToRemove)
972
+ {
973
+ screen.UnloadContent();
974
+ _screens.Remove(screen);
975
+ }
976
+ _screensToRemove.Clear();
977
+
978
+ // Update screens
979
+ foreach (var screen in _screens)
980
+ {
981
+ if (screen.IsActive)
982
+ {
983
+ screen.HandleInput(_input);
984
+ screen.Update(gameTime);
1294
985
  }
1295
- else if (ext === 'fx') {
1296
- processor = 'EffectProcessor';
1297
- importer = 'EffectImporter';
986
+ }
987
+ }
988
+
989
+ public override void Draw(GameTime gameTime)
990
+ {
991
+ foreach (var screen in _screens)
992
+ {
993
+ if (screen.IsActive)
994
+ {
995
+ screen.Draw(gameTime, _spriteBatch);
1298
996
  }
1299
- mgcb += `
1300
- #begin ${asset.name}
1301
- /importer:${importer}
1302
- /processor:${processor}
1303
- /build:${asset.name}
1304
- `;
1305
997
  }
1306
998
  }
1307
- this.csharpFiles.set(`${this.config.solutionName}/Content/Content.mgcb`, mgcb);
999
+
1000
+ public void AddScreen(Screen screen)
1001
+ {
1002
+ screen.ScreenManager = this;
1003
+ _screensToAdd.Add(screen);
1004
+ }
1005
+
1006
+ public void RemoveScreen(Screen screen)
1007
+ {
1008
+ _screensToRemove.Add(screen);
1009
+ }
1308
1010
  }
1309
- collectAssets(project) {
1310
- if (project.assets) {
1311
- this.assets = [...project.assets];
1011
+
1012
+ // ═══════════════════════════════════════════════════════════════
1013
+ // INPUT STATE
1014
+ // ═══════════════════════════════════════════════════════════════
1015
+
1016
+ public class InputState
1017
+ {
1018
+ public KeyboardState CurrentKeyboardState { get; private set; }
1019
+ public KeyboardState PreviousKeyboardState { get; private set; }
1020
+ public MouseState CurrentMouseState { get; private set; }
1021
+ public MouseState PreviousMouseState { get; private set; }
1022
+ public GamePadState CurrentGamePadState { get; private set; }
1023
+ public GamePadState PreviousGamePadState { get; private set; }
1024
+
1025
+ public void Update()
1026
+ {
1027
+ PreviousKeyboardState = CurrentKeyboardState;
1028
+ PreviousMouseState = CurrentMouseState;
1029
+ PreviousGamePadState = CurrentGamePadState;
1030
+
1031
+ CurrentKeyboardState = Keyboard.GetState();
1032
+ CurrentMouseState = Mouse.GetState();
1033
+ CurrentGamePadState = GamePad.GetState(PlayerIndex.One);
1034
+ }
1035
+
1036
+ public bool IsKeyPressed(Keys key) =>
1037
+ CurrentKeyboardState.IsKeyDown(key) && PreviousKeyboardState.IsKeyUp(key);
1038
+
1039
+ public bool IsKeyHeld(Keys key) =>
1040
+ CurrentKeyboardState.IsKeyDown(key);
1041
+
1042
+ public bool IsKeyReleased(Keys key) =>
1043
+ CurrentKeyboardState.IsKeyUp(key) && PreviousKeyboardState.IsKeyDown(key);
1044
+
1045
+ public Vector2 GetMovement()
1046
+ {
1047
+ Vector2 movement = Vector2.Zero;
1048
+
1049
+ if (IsKeyHeld(Keys.W) || IsKeyHeld(Keys.Up)) movement.Y -= 1;
1050
+ if (IsKeyHeld(Keys.S) || IsKeyHeld(Keys.Down)) movement.Y += 1;
1051
+ if (IsKeyHeld(Keys.A) || IsKeyHeld(Keys.Left)) movement.X -= 1;
1052
+ if (IsKeyHeld(Keys.D) || IsKeyHeld(Keys.Right)) movement.X += 1;
1053
+
1054
+ if (movement != Vector2.Zero)
1055
+ movement = Vector2.Normalize(movement);
1056
+
1057
+ return movement;
1312
1058
  }
1313
1059
  }
1314
- generateGuid() {
1315
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
1316
- const r = (Math.random() * 16) | 0;
1317
- const v = c === 'x' ? r : (r & 0x3) | 0x8;
1318
- return v.toString(16).toUpperCase();
1319
- });
1060
+
1061
+ // ═══════════════════════════════════════════════════════════════
1062
+ // MENU SCREEN
1063
+ // ═══════════════════════════════════════════════════════════════
1064
+
1065
+ public class MenuScreen : Screen
1066
+ {
1067
+ private SpriteFont _font;
1068
+ private int _selectedIndex;
1069
+ private string[] _menuItems = { "Play", "Options", "Exit" };
1070
+
1071
+ public override void LoadContent()
1072
+ {
1073
+ _font = Content.Load<SpriteFont>("Fonts/MenuFont");
1074
+ }
1075
+
1076
+ public override void HandleInput(InputState input)
1077
+ {
1078
+ if (input.IsKeyPressed(Keys.Up))
1079
+ {
1080
+ _selectedIndex--;
1081
+ if (_selectedIndex < 0) _selectedIndex = _menuItems.Length - 1;
1082
+ }
1083
+
1084
+ if (input.IsKeyPressed(Keys.Down))
1085
+ {
1086
+ _selectedIndex++;
1087
+ if (_selectedIndex >= _menuItems.Length) _selectedIndex = 0;
1088
+ }
1089
+
1090
+ if (input.IsKeyPressed(Keys.Enter))
1091
+ {
1092
+ switch (_selectedIndex)
1093
+ {
1094
+ case 0: // Play
1095
+ ScreenManager.AddScreen(new GameplayScreen());
1096
+ ExitScreen();
1097
+ break;
1098
+ case 1: // Options
1099
+ // Options screen
1100
+ break;
1101
+ case 2: // Exit
1102
+ ScreenManager.Game.Exit();
1103
+ break;
1104
+ }
1105
+ }
1106
+ }
1107
+
1108
+ public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
1109
+ {
1110
+ spriteBatch.Begin();
1111
+
1112
+ for (int i = 0; i < _menuItems.Length; i++)
1113
+ {
1114
+ Color color = i == _selectedIndex ? Color.Yellow : Color.White;
1115
+ Vector2 position = new Vector2(640 - _font.MeasureString(_menuItems[i]).X / 2, 300 + i * 50);
1116
+ spriteBatch.DrawString(_font, _menuItems[i], position, color);
1117
+ }
1118
+
1119
+ spriteBatch.End();
1120
+ }
1121
+ }
1122
+
1123
+ // ═══════════════════════════════════════════════════════════════
1124
+ // GAMEPLAY SCREEN
1125
+ // ═══════════════════════════════════════════════════════════════
1126
+
1127
+ public class GameplayScreen : Screen
1128
+ {
1129
+ public override void LoadContent()
1130
+ {
1131
+ // Load level content
1132
+ }
1133
+
1134
+ public override void HandleInput(InputState input)
1135
+ {
1136
+ if (input.IsKeyPressed(Keys.Escape))
1137
+ {
1138
+ ScreenManager.AddScreen(new PauseScreen());
1139
+ }
1140
+
1141
+ Vector2 movement = input.GetMovement();
1142
+ // Apply to player
1143
+ }
1144
+
1145
+ public override void Update(GameTime gameTime)
1146
+ {
1147
+ // Update game logic
1148
+ }
1149
+
1150
+ public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
1151
+ {
1152
+ spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
1153
+
1154
+ // Draw game
1155
+
1156
+ spriteBatch.End();
1157
+ }
1158
+ }
1159
+
1160
+ // ═══════════════════════════════════════════════════════════════
1161
+ // PAUSE SCREEN
1162
+ // ═══════════════════════════════════════════════════════════════
1163
+
1164
+ public class PauseScreen : Screen
1165
+ {
1166
+ public PauseScreen()
1167
+ {
1168
+ IsPopup = true;
1169
+ }
1170
+
1171
+ public override void HandleInput(InputState input)
1172
+ {
1173
+ if (input.IsKeyPressed(Keys.Escape))
1174
+ {
1175
+ ExitScreen();
1176
+ }
1177
+ }
1178
+
1179
+ public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
1180
+ {
1181
+ spriteBatch.Begin();
1182
+
1183
+ // Draw semi-transparent overlay
1184
+ spriteBatch.Draw(
1185
+ Assets.PixelTexture,
1186
+ new Rectangle(0, 0, Game1.ScreenWidth, Game1.ScreenHeight),
1187
+ new Color(0, 0, 0, 0.5f)
1188
+ );
1189
+
1190
+ // Draw pause text
1191
+
1192
+ spriteBatch.End();
1193
+ }
1320
1194
  }
1321
- toPascalCase(str) {
1322
- return str
1323
- .split(/[\s_-]+/)
1324
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
1325
- .join('');
1195
+ }
1196
+ `;
1197
+ this.csharpFiles.set(`${this.config.solutionName}/Screens/Screens.cs`, screensCs);
1198
+ const assetsCs = `using Microsoft.Xna.Framework;
1199
+ using Microsoft.Xna.Framework.Content;
1200
+ using Microsoft.Xna.Framework.Graphics;
1201
+
1202
+ namespace ${namespace}
1203
+ {
1204
+ public static class Assets
1205
+ {
1206
+ // Textures
1207
+ public static Texture2D PixelTexture { get; private set; }
1208
+ public static Texture2D PlayerTexture { get; private set; }
1209
+ public static Texture2D EnemyTexture { get; private set; }
1210
+ public static Texture2D TilesetTexture { get; private set; }
1211
+
1212
+ // Fonts
1213
+ public static SpriteFont MenuFont { get; private set; }
1214
+ public static SpriteFont GameFont { get; private set; }
1215
+
1216
+ public static void Load(ContentManager content)
1217
+ {
1218
+ // Create pixel texture
1219
+ PixelTexture = new Texture2D(Game1.Instance.GraphicsDevice, 1, 1);
1220
+ PixelTexture.SetData(new[] { Color.White });
1221
+
1222
+ // Load textures
1223
+ PlayerTexture = content.Load<Texture2D>("Sprites/player");
1224
+ EnemyTexture = content.Load<Texture2D>("Sprites/enemy");
1225
+ TilesetTexture = content.Load<Texture2D>("Sprites/tileset");
1226
+
1227
+ // Load fonts
1228
+ MenuFont = content.Load<SpriteFont>("Fonts/MenuFont");
1229
+ GameFont = content.Load<SpriteFont>("Fonts/GameFont");
1230
+ }
1326
1231
  }
1327
1232
  }
1328
- /* ══════════════════════════════════════════════════════════════
1329
- EXPORTS
1330
- ══════════════════════════════════════════════════════════════ */
1233
+ `;
1234
+ this.csharpFiles.set(`${this.config.solutionName}/Assets.cs`, assetsCs);
1235
+ }
1236
+ generateContentMgcb(project) {
1237
+ let mgcb = `#----------------------------- Global Properties ----------------------------#
1238
+
1239
+ /outputDir:bin/$(Platform)
1240
+ /intermediateDir:obj/$(Platform)
1241
+ /platform:DesktopGL
1242
+ /config:
1243
+ /profile:Reach
1244
+ /compress:False
1245
+
1246
+ #-------------------------------- References --------------------------------#
1331
1247
 
1248
+ /reference:..\\..\\packages\\MonoGame.Extended.Content.Pipeline\\4.0.0\\tools\\MonoGame.Extended.Content.Pipeline.dll
1249
+
1250
+ #---------------------------------- Content ---------------------------------#
1251
+
1252
+ #begin Fonts/MenuFont.spritefont
1253
+ /importer:FontDescriptionImporter
1254
+ /processor:FontDescriptionProcessor
1255
+ /processorParam:PremultiplyAlpha=True
1256
+ /processorParam:TextureFormat=Compressed
1257
+ /build:Fonts/MenuFont.spritefont
1258
+
1259
+ #begin Fonts/GameFont.spritefont
1260
+ /importer:FontDescriptionImporter
1261
+ /processor:FontDescriptionProcessor
1262
+ /processorParam:PremultiplyAlpha=True
1263
+ /processorParam:TextureFormat=Compressed
1264
+ /build:Fonts/GameFont.spritefont
1265
+ `;
1266
+ if (project.assets) {
1267
+ for (const asset of project.assets) {
1268
+ const ext = asset.name.split(".").pop()?.toLowerCase();
1269
+ let processor = "TextureProcessor";
1270
+ let importer = "TextureImporter";
1271
+ if (ext === "ogg" || ext === "wav" || ext === "mp3") {
1272
+ processor = "SoundEffectProcessor";
1273
+ importer = "OggImporter";
1274
+ } else if (ext === "fx") {
1275
+ processor = "EffectProcessor";
1276
+ importer = "EffectImporter";
1277
+ }
1278
+ mgcb += `
1279
+ #begin ${asset.name}
1280
+ /importer:${importer}
1281
+ /processor:${processor}
1282
+ /build:${asset.name}
1283
+ `;
1284
+ }
1285
+ }
1286
+ this.csharpFiles.set(`${this.config.solutionName}/Content/Content.mgcb`, mgcb);
1287
+ }
1288
+ collectAssets(project) {
1289
+ if (project.assets) {
1290
+ this.assets = [...project.assets];
1291
+ }
1292
+ }
1293
+ generateGuid() {
1294
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
1295
+ const r = Math.random() * 16 | 0;
1296
+ const v = c === "x" ? r : r & 3 | 8;
1297
+ return v.toString(16).toUpperCase();
1298
+ });
1299
+ }
1300
+ toPascalCase(str) {
1301
+ return str.split(/[\s_-]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
1302
+ }
1303
+ }
1332
1304
  exports.DEFAULT_MONOGAME_CONFIG = DEFAULT_MONOGAME_CONFIG;
1333
1305
  exports.MonoGameExporter = MonoGameExporter;