Compare commits

...

2 Commits

Author SHA1 Message Date
austin
42c1f7c55a moving documentation around
Some checks are pending
studiorailgun/Renderer/pipeline/head Build queued...
2024-06-27 22:50:20 -04:00
austin
a26ea92aae animation updates 2024-06-27 22:35:36 -04:00
7 changed files with 125 additions and 29 deletions

View File

@ -11,6 +11,7 @@
- @subpage savesindex
- @subpage hitboxesindex
- @subpage drawcell
- @subpage scriptengine
# What is this section

View File

@ -0,0 +1,31 @@
@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

View File

@ -0,0 +1,35 @@
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

View File

@ -387,35 +387,23 @@ Fix items falling below the ground
Fix server always rotating entity to face client camera -- should only be changing movement vector
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
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:
always enforce opengl interface across all opengl calls jesus christ the bone uniform bug was impossible

View File

@ -13,12 +13,23 @@ import org.graalvm.polyglot.Value;
import electrosphere.logger.LoggerInterface;
import electrosphere.util.FileUtils;
/**
* Interface for executing scripts in the game engine
*/
public class ScriptEngine {
//the graal context
Context context;
//the map of script filepaths to parsed, in-memory scripts
Map<String,Source> sourceMap;
//the javascript object that stores values
Value jsBindingsObject;
/**
* Initializes the engine
*/
public void init(){
//init datastructures
sourceMap = new HashMap<String,Source>();
@ -28,6 +39,8 @@ public class ScriptEngine {
context = Context.newBuilder("js").engine(engine).build();
//read scripts into source map
readScriptsDirectory("/src/main/sql", FileUtils.getAssetFile("/src/main/sql"));
//save the js bindings object
jsBindingsObject = context.getBindings("js");
//create bindings
// try {
// String content = FileUtils.getAssetFileAsString("/Scripts/test.js");
@ -40,11 +53,29 @@ public class ScriptEngine {
// }
}
void createBindings(){
Value jsBindings = context.getBindings("js");
jsBindings.putMember("name", "somescript");
/**
* Stores a variable at the top level of the js bindings
* @param valueName The name of the variable (ie the name of the variable)
* @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){
if(directory.exists() && directory.isDirectory()){
File[] children = directory.listFiles();
@ -61,6 +92,10 @@ public class ScriptEngine {
}
}
/**
* Loads a script from disk
* @param path The path to the script file
*/
public void loadScript(String path){
String content;
try {
@ -73,11 +108,17 @@ public class ScriptEngine {
}
}
/**
* Runs a script
* @param path The filepath of the script
*/
public void runScript(String path){
Source source = sourceMap.get(path);
if(source != null){
context.eval(source);
}
}
}