Compare commits
	
		
			No commits in common. "42c1f7c55aea805be3816216009e80814d59095b" and "2182cc80fa9615e70332ed4cdbd71bf909ae26bb" have entirely different histories.
		
	
	
		
			42c1f7c55a
			...
			2182cc80fa
		
	
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -11,7 +11,6 @@ | |||||||
| - @subpage savesindex | - @subpage savesindex | ||||||
| - @subpage hitboxesindex | - @subpage hitboxesindex | ||||||
| - @subpage drawcell | - @subpage drawcell | ||||||
| - @subpage scriptengine |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # What is this section | # What is this section | ||||||
|  | |||||||
| @ -1,31 +0,0 @@ | |||||||
| @page scriptengine Script Engine |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| # Potential problems with integrating with the overall game engine |  | ||||||
| A chief problem we want to avoid is allowing people to 'escape' the scripting engine and get access to all objects in the overall engine |  | ||||||
| 
 |  | ||||||
| # Roadmap for integrating with the overall game engine |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| # On adding different instances of the scripting engine |  | ||||||
| There should be a single monolithic instance of the scripting engine |  | ||||||
| All context-dependent scripts running should have their context provided |  | ||||||
| 
 |  | ||||||
| IE, lets say I'm the client and I want to fire an event when a client-side effect completes, |  | ||||||
| I'd provide a copy of the client's scene as a part of the function call on javascript side |  | ||||||
| That way for any unforseen reason the client could still get access to the server's objects |  | ||||||
| 
 |  | ||||||
| IE, lets say I'm a script running on a specific scene on the server, |  | ||||||
| I'd provide the specific scene to the function call |  | ||||||
| 
 |  | ||||||
| IE, lets say I'm some script firing every time a user logs in, |  | ||||||
| I'd provide the new user object and the global server user tracking service |  | ||||||
| That way you could still drill down to individual scenes on the server if you needed to |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| @ -1,35 +0,0 @@ | |||||||
| 
 |  | ||||||
| 
 |  | ||||||
| Demo experience: |  | ||||||
|  - Load into world |  | ||||||
|  - pick up a katana |  | ||||||
|  - popup appears telling you controls to swing it |  | ||||||
|  - Upon dismissing popup, spawn enemy with sword |  | ||||||
|  - Fight enemy to the death |  | ||||||
| 
 |  | ||||||
| Demo requirements: |  | ||||||
|  = Assets =  |  | ||||||
| Fix attack animation bone rotations for hand |  | ||||||
| Clean up equip state data |  | ||||||
| Audio FX for everything |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|  = Coding =  |  | ||||||
| Sub menu on title screen that allows changing control mappings |  | ||||||
|  - Automatically generate based on the controls arrays in controls handler |  | ||||||
| Redo hitboxes to have capsules and also chaining between frames (but not between swinging the camera around) |  | ||||||
|  - Introduce block hitbox (blockbox) type |  | ||||||
|  - Sour spot, sweet spot for damage hitboxes and hurtboxes |  | ||||||
| Enemy AI |  | ||||||
| better scaffolding for scriptig engine with hooks for equipping items, spawning entities, pausing/resuming play, etc |  | ||||||
| Ability for private realms to have time start/stop based on the player's feedback <-- sync this up to tutorial ui via script |  | ||||||
| Scene Message Service |  | ||||||
|  - Can send arbitrary events and messages |  | ||||||
|   - Synchronized and unsynchronized |  | ||||||
|    - Use synchronized to have client-driver ui interactions |  | ||||||
|  - Variables |  | ||||||
|   - Synchronized and unsynchronized |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|    |  | ||||||
| @ -387,23 +387,35 @@ Fix items falling below the ground | |||||||
| Fix server always rotating entity to face client camera -- should only be changing movement vector | Fix server always rotating entity to face client camera -- should only be changing movement vector | ||||||
| Probably some kind of tutorial text | Probably some kind of tutorial text | ||||||
| 
 | 
 | ||||||
| (06/??/2024) |  | ||||||
| Start working on script engine documentation/design |  | ||||||
| 
 |  | ||||||
| (06/27/2024) |  | ||||||
| Animations |  | ||||||
|  - 2H Sword Hold (3rd person) |  | ||||||
|  - 2H Sword Attack (3rd person) |  | ||||||
|  - 2H Sword Block (3rd person) |  | ||||||
|  - 2H Sword Hold (1st person) |  | ||||||
|  - 2H Sword Attach (1st person) |  | ||||||
|  - 2H Sword Block (1st person) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| # TODO | # TODO | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | Demo requirements: | ||||||
|  |  = Assets =  | ||||||
|  | Block animation in first person | ||||||
|  | Block animation in third person | ||||||
|  | Fix attack animation bone rotations for hand | ||||||
|  | Clean up equip state data | ||||||
|  | Audio FX for everything | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |  = Coding =  | ||||||
|  | Sour spot, sweet spot for damage hitboxes and hurtboxes | ||||||
|  | Sub menu on title screen that allows changing control mappings | ||||||
|  | Redo hitboxes to have capsules and also chaining between frames (but not between swinging the camera around) | ||||||
|  |  - Introduce block hitbox (blockbox) type | ||||||
|  | Enemy AI | ||||||
|  | Network-able ui messages | ||||||
|  | Ability to display video both on title screen as well as in game windows for tutorials | ||||||
|  | better scaffolding for scriptig engine with hooks for equipping items, spawning entities, pausing/resuming play, etc | ||||||
|  | Ability for private realms to have time start/stop based on the player's feedback <-- sync this up to tutorial ui via script | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| BIG BIG BIG BIG IMMEDIATE TO DO: | BIG BIG BIG BIG IMMEDIATE TO DO: | ||||||
| always enforce opengl interface across all opengl calls jesus christ the bone uniform bug was impossible | always enforce opengl interface across all opengl calls jesus christ the bone uniform bug was impossible | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -13,23 +13,12 @@ import org.graalvm.polyglot.Value; | |||||||
| import electrosphere.logger.LoggerInterface; | import electrosphere.logger.LoggerInterface; | ||||||
| import electrosphere.util.FileUtils; | import electrosphere.util.FileUtils; | ||||||
| 
 | 
 | ||||||
| /** |  | ||||||
|  * Interface for executing scripts in the game engine |  | ||||||
|  */ |  | ||||||
| public class ScriptEngine { | public class ScriptEngine { | ||||||
| 
 | 
 | ||||||
|     //the graal context |  | ||||||
|     Context context; |     Context context; | ||||||
| 
 | 
 | ||||||
|     //the map of script filepaths to parsed, in-memory scripts |  | ||||||
|     Map<String,Source> sourceMap; |     Map<String,Source> sourceMap; | ||||||
| 
 | 
 | ||||||
|     //the javascript object that stores values |  | ||||||
|     Value jsBindingsObject; |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * Initializes the engine |  | ||||||
|      */ |  | ||||||
|     public void init(){ |     public void init(){ | ||||||
|         //init datastructures |         //init datastructures | ||||||
|         sourceMap = new HashMap<String,Source>(); |         sourceMap = new HashMap<String,Source>(); | ||||||
| @ -39,8 +28,6 @@ public class ScriptEngine { | |||||||
|         context = Context.newBuilder("js").engine(engine).build(); |         context = Context.newBuilder("js").engine(engine).build(); | ||||||
|         //read scripts into source map |         //read scripts into source map | ||||||
|         readScriptsDirectory("/src/main/sql", FileUtils.getAssetFile("/src/main/sql")); |         readScriptsDirectory("/src/main/sql", FileUtils.getAssetFile("/src/main/sql")); | ||||||
|         //save the js bindings object |  | ||||||
|         jsBindingsObject = context.getBindings("js"); |  | ||||||
|         //create bindings |         //create bindings | ||||||
|         // try { |         // try { | ||||||
|         //     String content = FileUtils.getAssetFileAsString("/Scripts/test.js"); |         //     String content = FileUtils.getAssetFileAsString("/Scripts/test.js"); | ||||||
| @ -53,29 +40,11 @@ public class ScriptEngine { | |||||||
|         // } |         // } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     void createBindings(){ | ||||||
|      * Stores a variable at the top level of the js bindings |         Value jsBindings = context.getBindings("js"); | ||||||
|      * @param valueName The name of the variable (ie the name of the variable) |         jsBindings.putMember("name", "somescript"); | ||||||
|      * @param value The value that is stored at that variable |  | ||||||
|      */ |  | ||||||
|     public void putTopLevelValue(String valueName, Object value){ |  | ||||||
|         jsBindingsObject.putMember(valueName, value); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * Gets a top level value from the script engine |  | ||||||
|      * @param valueName The name of the variable |  | ||||||
|      * @return The value of the variable |  | ||||||
|      */ |  | ||||||
|     public Value getTopLevelValue(String valueName){ |  | ||||||
|         return jsBindingsObject.getMember(valueName); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * Reads the scripts directory |  | ||||||
|      * @param path The  |  | ||||||
|      * @param directory |  | ||||||
|      */ |  | ||||||
|     void readScriptsDirectory(String path, File directory){ |     void readScriptsDirectory(String path, File directory){ | ||||||
|         if(directory.exists() && directory.isDirectory()){ |         if(directory.exists() && directory.isDirectory()){ | ||||||
|             File[] children = directory.listFiles(); |             File[] children = directory.listFiles(); | ||||||
| @ -92,10 +61,6 @@ public class ScriptEngine { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * Loads a script from disk |  | ||||||
|      * @param path The path to the script file |  | ||||||
|      */ |  | ||||||
|     public void loadScript(String path){ |     public void loadScript(String path){ | ||||||
|         String content; |         String content; | ||||||
|         try { |         try { | ||||||
| @ -108,17 +73,11 @@ public class ScriptEngine { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * Runs a script |  | ||||||
|      * @param path The filepath of the script |  | ||||||
|      */ |  | ||||||
|     public void runScript(String path){ |     public void runScript(String path){ | ||||||
|         Source source = sourceMap.get(path); |         Source source = sourceMap.get(path); | ||||||
|         if(source != null){ |         if(source != null){ | ||||||
|             context.eval(source); |             context.eval(source); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|      |  | ||||||
|      |      | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user