Documentation and Optimization Part 1 (#2)

Authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-06-16 10:12:51 +02:00
committed by GitHub
parent a22805d0e6
commit 4e09f522ff
109 changed files with 3556 additions and 2043 deletions

205
docs/api/Movable.md Normal file
View File

@@ -0,0 +1,205 @@
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
# Movable
**Extends:** [Node](../Node)
## Description
Node that performs the moving (walk, teleport, terrain scaling...) actions on
its parent node.
## Property Descriptions
### walk\_path
```gdscript
var walk_path: Array
```
Character path through the scene as calculated by the Pathfinder
### path\_ofs
```gdscript
var path_ofs: int
```
Current active walk path entry
### walk\_destination
```gdscript
var walk_destination: Vector2
```
The destination where the character should be moving to
### walk\_context
```gdscript
var walk_context: Dictionary
```
A dictionary with context information about the walk command
fast => Wether to walk fast or slow
target => Walk target
### moved
```gdscript
var moved: bool
```
Wether the character was moved at all
### last\_deg
```gdscript
var last_deg: int
```
Angle degrees to the last position (TODO is that correct?)
### last\_dir
```gdscript
var last_dir: int
```
Direction of the last position (TODO is that correct?)
### last\_scale
```gdscript
var last_scale: Vector2
```
Scale of the last position (TODO is that correct?)
### pose\_scale
```gdscript
var pose_scale: int
```
TODO Isn't this actually the flip state of the current animation?
### parent
```gdscript
var parent
```
Shortcut variable that references the node's parent
### bypass\_missing\_animation
```gdscript
var bypass_missing_animation
```
 If character misses an animation, bypass it and proceed.
## Method Descriptions
### teleport
```gdscript
func teleport(target, angle: Object = null) -> void
```
Teleports this item to the target position.
TODO angle is only used for logging and has no further use, so it probably
can be removed
#### Parameters
- target: Vector2, Position2d or ESCItem
### walk\_to
```gdscript
func walk_to(pos: Vector2, p_walk_context = null) -> void
```
Walk to a given position
#### Parameters
- pos: Position to walk to
- p_walk_context: Walk context to use
### walk
```gdscript
func walk(target_pos, p_speed, context = null) -> void
```
FIXME this function doesn't seem to be used anywhere
### walk\_stop
```gdscript
func walk_stop(pos: Vector2) -> var
```
We have finished walking. Set the idle pose and complete
#### Parameters
- pos: Final target position
### update\_terrain
```gdscript
func update_terrain(on_event_finished_name = null) -> void
```
Update the sprite scale and lighting
#### Parameters
- on_event_finished_name: Used if this function is called from an ESC event
### is\_angle\_in\_interval
```gdscript
func is_angle_in_interval(angle: float, interval: Array) -> bool
```
Returns true if given angle is inside the interval given by a starting_angle
and the size.
TODO Refactor to make this stuff understandable :D
#### Parameters
- angle: Angle to test
- interval : Array of size 2, containing the starting angle, and the size of
interval
eg: [90, 40] corresponds to angle between 90° and 130°
### set\_angle
```gdscript
func set_angle(deg: int, immediate = true) -> void
```
Sets character's angle and plays according animation.
TODO: depending on current angle and current angle, the character may
directly turn around with no "progression". We may enhance this by
calculating successive directions to turn the character to, so that he
doesn't switch to opposite direction too fast.
For example, if character looks WEST and set_angle(EAST) is called, we may
want the character to first turn SOUTHWEST, then SOUTH, then SOUTHEAST and
finally EAST, all more or less fast.
Whatever the implementation, this should be activated using "parameter
"immediate" set to false.
#### Parameters
- deg int angle to set the character
- immediate bool (currently unused, see TODO below)
If true, direction is switched immediately. Else, successive animations are
used so that the character turns to target angle.

275
docs/api/esc_compiler.gd.md Normal file
View File

@@ -0,0 +1,275 @@
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
# esc\_compiler.gd
**Extends:** [Node](../Node)
## Description
ESC compiler
The workflow is like this:
Lines beginning with ":" such as :push, :say are EVENTS.
Lines in between are usually the ESC API functions calls. They are called COMMANDS.
Steps
* compile_script(path/to/esc) : called once
* compile(path/to/esc, errors) : called once
* read_events() : called once\
create an ESCState, initialized with 1st line\
for each line in ESCState that corresponds to an event (:event), create a new level
* add_level(state, level, errors)\
for each state.line that belongs to same group (same indentation), create a command
* read_cmd(state, level, errors)\
get the token in state.line : this is the actual command (say, teleport, etc.)\
get the parameters next to the token\
create an ESCCommand, check it and push it into level array\
* create an ESCEvent with the level created\
* add it to the returned Dictionary of events
In the end, the ESCState has read all lines in the file and is deleted
Returned value is a Dictionary { event name : ESCEvent}
And ESCEvent.level is an array of ESCCommand
## Constants Descriptions
### COMMANDS
```gdscript
const COMMANDS: Dictionary = {"!":{"alias":"end_dialog","min_args":0},"%":{"alias":"label","min_args":1},">":{"alias":"branch"},"?":{"alias":"dialog"},"accept_input":{"min_args":1,"types":[4]},"anim":{"min_args":2,"types":[4,4,1,1,1]},"autosave":{"min_args":0},"camera_push":{"min_args":1,"types":[4]},"camera_set_drag_margin_enabled":{"min_args":2,"types":[1,1]},"camera_set_limits":{"min_args":1,"types":[2]},"camera_set_pos":{"min_args":3,"types":[3,2,2]},"camera_set_target":{"min_args":1,"types":[3]},"camera_set_zoom":{"min_args":1,"types":[3]},"camera_set_zoom_height":{"min_args":1,"types":[2]},"camera_shift":{"min_args":2,"types":[2,2]},"change_scene":{"min_args":1,"types":[4,1]},"custom":{"min_args":2,"types":[4,4]},"cut_scene":{"min_args":2,"types":[4,4,1,1,1]},"debug":{"min_args":1},"dec_global":{"min_args":2,"types":[4,2]},"enable_terrain":{"min_args":1,"types":[4]},"game_over":{"min_args":1,"types":[1]},"inc_global":{"min_args":2,"types":[4,2]},"inventory_add":{"min_args":1},"inventory_display":{"min_args":1,"types":[1]},"inventory_remove":{"min_args":1},"jump":{"min_args":1},"label":{"min_args":1},"queue_animation":{"min_args":2,"types":[4,4,1]},"queue_resource":{"min_args":1,"types":[4,1]},"repeat":true,"say":{"min_args":2},"sched_event":{"min_args":3,"types":[3,4,4]},"set_active":{"min_args":2,"types":[4,1]},"set_angle":{"min_args":2,"types":[4,2]},"set_global":{"min_args":2,"types":[4,4]},"set_globals":{"min_args":2,"types":[4,1]},"set_hud_visible":{"min_args":1,"types":[1]},"set_interactive":{"min_args":2,"types":[4,1]},"set_sound_state":{"min_args":2,"types":[4,4,1]},"set_speed":{"min_args":2,"types":[4,2]},"set_state":{"min_args":2,"types":[4,4,1]},"slide":{"min_args":2},"slide_block":{"min_args":2},"spawn":{"min_args":1},"stop":true,"superpose_scene":{"min_args":1,"types":[4,1]},"teleport":{"min_args":2,"types":[4,4,2]},"teleport_pos":{"min_args":3},"turn_to":{"min_args":2},"wait":true,"walk":{"min_args":2},"walk_block":{"min_args":2},"walk_to_pos":{"min_args":3},"walk_to_pos_block":{"min_args":3}}
```
A list of valid ESC commands
### DEBUG\_COMMANDS
```gdscript
const DEBUG_COMMANDS: Dictionary = {"get_active":{"min_args":1,"types":[4]},"get_global":{"min_args":1,"types":[4]},"get_interactive":{"min_args":1,"types":[4]},"get_state":{"min_args":1,"types":[4]}}
```
Commands that can be called only by the ESC debug prompt
## Method Descriptions
### compile\_str
```gdscript
func compile_str(p_str: String, errors: Array)
```
Compile a string into a dictionary of ESC events
#### Parameters
- p_str: String to compile
- errors: List of errors occured during parsing
**Returns** A dictionary of ESCEvents
### load\_esc\_file
```gdscript
func load_esc_file(esc_file_path: String) -> Dictionary
```
Loads an ESC or special GDScript file and compiles it to a dictionary of
events.
#### Parameters
- esc_file_path: The path to the ESC file to load
**Returns** A dictionary of ESC events
### compile\_script
```gdscript
func compile_script(p_path: String) -> Dictionary
```
Compiles an ESC file into a dictionary of events.
Alternatively, a GDScript file can be specified as well. In that case,
the compiler expects a function get_events in that script that
returns a dictionary of events.
#### Parameters
- p_path: Path to the ESC/GDScript-file
**Returns** A dictionary of ESC events
### compile
```gdscript
func compile(p_fname: String, errors: Array) -> Dictionary
```
Compile an ESC file into a list of events
#### Parameters
- p_fname: Path to the ESC file
- errors: A list of errors that wil be filled by the compiler
**Returns** A dictionary of ESC events
### read\_events
```gdscript
func read_events(f, ret: Dictionary, errors: Array) -> void
```
Parse a file or a special dictionary into a dictionary of ESC events
The dictionary is currently used as a workaround to parse ESC from text
(see read_line for specifics)
#### Parameters
- f: File or Dictionary to read
- ret: The parsed dictionary
- errors: A list of errors that have been found during parsing
### add\_level
```gdscript
func add_level(state: ESCState, level: Array, errors: Array) -> void
```
Add a new level of indent to the current event parsing
#### Parameters
- state: The state we're working on
- level: The existing levels
- errors: A list of errors during parsing
### read\_cmd
```gdscript
func read_cmd(state: ESCState, level: Array, errors: Array) -> void
```
Interpret a line in an esc event level as a command and add it to the
level commands
#### Parameters
- state: The state we're working on
- level: The list of level commands
- errors: A list of errors occured during parsing
### add\_dialog
```gdscript
func add_dialog(state: ESCState, level: Array, errors: Array) -> void
```
Add a dialog into the current level
#### Parameters
- state: State we're working on
- level: Current list of level commands
- errors: List of errors occured during parsing
### read\_dialog\_option
```gdscript
func read_dialog_option(state: ESCState, level: Array, errors: Array) -> void
```
### check\_normal\_command
```gdscript
func check_normal_command(cmd: ESCCommand, state: ESCState, errors: Array) -> bool
```
### check\_debug\_command
```gdscript
func check_debug_command(cmd: ESCCommand, state: ESCState, errors: Array) -> bool
```
### check\_command
```gdscript
func check_command(commands_list: Dictionary, cmd: ESCCommand, state: ESCState, errors: Array) -> bool
```
### read\_line
```gdscript
func read_line(state: ESCState) -> void
```
Advance to the next line in the state
#### Parameters
- state: State we're working on
### is\_comment
```gdscript
func is_comment(line: String) -> bool
```
 Check wether line is a comment (starting with #)
#### Parameters
- line: Current line as string
**Returns** Wether the line is a comment or not
### get\_indent
```gdscript
func get_indent(line: String) -> int
```
Returns the position of the first non-blank character in given line string
#### Parameters
- line: Line to check
**Returns** Indent of the checked line
### is\_event
```gdscript
func is_event(line: String)
```
Check wether the given line is a event (begins with ":")
#### Parameters
- line: Line to check
**Returns**
### is\_flags
```gdscript
func is_flags(tk: String) -> bool
```
Checks wetehr the given token is a flag (ie. "[.+]")
#### Parameters
- tk: Token to check
**Returns** Wether the token is a flag or not
### get\_token
```gdscript
func get_token(line: String, p_from: int, line_count: int, errors: Array) -> int
```
### parse\_flags
```gdscript
func parse_flags(p_flags: String, flags_list: Array, ifs: Dictionary)
```
Parses a flags string (usually defined by '[.*]') and fills the flags_list array
and ifs variable (Dictionary containing all ifs conditions)

164
docs/api/escoria.gd.md Normal file
View File

@@ -0,0 +1,164 @@
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
# escoria.gd
**Extends:** [Node](../Node)
## Description
The escorie main script
## Enumerations
### GAME\_STATE
```gdscript
const GAME_STATE: Dictionary = {"DEFAULT":0,"DIALOG":1,"WAIT":2}
```
An enum of game states
* DEFAULT - Default mode
* DIALOG - Game is running a dialog
* WAIT - Game is currently waiting for a specified time
## Property Descriptions
### main\_menu\_instance
```gdscript
var main_menu_instance
```
The instance of the used main menu scene
### dialog\_player
```gdscript
var dialog_player
```
Dialog player instantiator. This instance is called directly for dialogs.
### inventory
```gdscript
var inventory
```
The inventory scene used
### room\_terrain
```gdscript
var room_terrain
```
The terrain of the current main room
### esc\_compiler
```gdscript
var esc_compiler
```
The ESC compiler instance
### logger
```gdscript
var logger
```
The logger instance
### main
```gdscript
var main
```
The main scene
### esc\_runner
```gdscript
var esc_runner
```
The ESC main loop
### esc\_level\_runner
```gdscript
var esc_level_runner
```
The ESC interpreter
### inputs\_manager
```gdscript
var inputs_manager
```
The escoria inputs manager
### utils
```gdscript
var utils
```
Several utilities
### current\_state
```gdscript
var current_state
```
The current state of the game
### game\_size
```gdscript
var game_size
```
The game resolution
## Method Descriptions
### new\_game
```gdscript
func new_game()
```
Called by Main menu "start new game"
### register\_object
```gdscript
func register_object(object: Object)
```
Register an object to the matching manager. (A dialog player as the
main dialog player, an item in the ESC runner, etc.)
#### Parameters
- object: The object to register
### do
```gdscript
func do(action: String, params: Array) -> void
```
Run a generic action
#### Parameters
- action: type of the action to run
- params: Parameters for the action

View File

@@ -0,0 +1,144 @@
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
# escoria\_types.gd
**Extends:** [Node](../Node)
## Description
Escoria basic types
## Enumerations
### EVENT\_LEVEL\_STATE
```gdscript
const EVENT_LEVEL_STATE: Dictionary = {"BREAK":2,"CALL":4,"JUMP":5,"REPEAT":3,"RETURN":0,"YIELD":1}
```
ESC script states
RETURN - The ESC script has been completed successfully
YIELD - ESC is waiting for Godot to finish something (e.g. Sprite animation)
BREAK - ESC has completed the current command block. Jump back
REPEAT - ESC is repeating a command block
CALL - Call another ESC command block
JUMP - Jump to another ESC label
## Constants Descriptions
### OBJ\_DEFAULT\_STATE
```gdscript
const OBJ_DEFAULT_STATE: String = "default"
```
The default state of an object
## Sub\-classes
### ESCState
#### Property Descriptions
### file
```gdscript
var file
```
File or Dictionary
### line
```gdscript
var line
```
String, can be null
### indent
```gdscript
var indent: int
```
### line\_count
```gdscript
var line_count: int
```
#### Method Descriptions
### \_init
```gdscript
func _init(p_file, p_line, p_indent, p_line_count)
```
### ESCEvent
#### Property Descriptions
### ev\_name
```gdscript
var ev_name: String
```
### ev\_level
```gdscript
var ev_level: Array
```
### ev\_flags
```gdscript
var ev_flags: Array
```
#### Method Descriptions
### \_init
```gdscript
func _init(p_name, p_level, p_flags)
```
### ESCCommand
#### Property Descriptions
### name
```gdscript
var name: String
```
### params
```gdscript
var params: Array
```
### conditions
```gdscript
var conditions: Dictionary
```
### flags
```gdscript
var flags: Array
```
#### Method Descriptions
### \_init
```gdscript
func _init(p_name)
```