:setup action is not managed only once anymore (#358)

Co-authored-by: StraToN <StraToN@users.noreply.github.com>
This commit is contained in:
Julian Murgia
2021-08-08 23:23:11 +02:00
committed by GitHub
parent cbb64df969
commit 61726bca81
20 changed files with 252 additions and 213 deletions

View File

@@ -9,10 +9,6 @@ extends ESCBaseCommand
class_name ChangeSceneCommand
# An array of scenes that have already been loaded
var readied_scenes: Array = []
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
@@ -103,10 +99,8 @@ func run(command_params: Array) -> int:
escoria.main.scene_transition.fade_in()
yield(escoria.main.scene_transition, "transition_done")
# If scene was never visited, add "ready" event to the events stack
if not command_params[0] in self.readied_scenes \
and script.events.has("ready"):
if script.events.has("ready"):
escoria.event_manager.queue_event(script.events["ready"])
var rc = yield(escoria.event_manager, "event_finished")
while rc[1] != "ready":
@@ -114,8 +108,6 @@ func run(command_params: Array) -> int:
if rc[0] != ESCExecution.RC_OK:
return rc[0]
self.readied_scenes.append(command_params[0])
# Clear queued resources
escoria.resource_cache.clear()

View File

@@ -329,14 +329,14 @@ func set_angle(deg: int, immediate = true):
func start_talking():
if animation_sprite.is_playing():
animation_sprite.stop()
animation_sprite.play(animations.speaks[_movable.last_dir][0])
animation_sprite.play(animations.speaks[_movable.last_dir].animation)
# Stop playing the talking animation
func stop_talking():
if animation_sprite.is_playing():
animation_sprite.stop()
animation_sprite.play(animations.idles[_movable.last_dir][0])
animation_sprite.play(animations.idles[_movable.last_dir].animation)
# Detect the child nodes and set respective references

View File

@@ -315,7 +315,7 @@ func _ev_left_click_on_item(obj, event, default_action = false):
"arrived"
)
self.logger.info("Context arrived: %s" % var2str(context))
self.logger.info("Context arrived: %s" % context)
if context.target_object and \
context.target_object.global_id != walk_context.\

View File

@@ -146,7 +146,7 @@ func _on_mouse_double_left_click_inventory_item(
# that is hovered
func _on_mouse_entered_inventory_item(inventory_item_global_id: String) -> void:
escoria.logger.info(
"Inventory item focused " % inventory_item_global_id
"Inventory item focused %s" % inventory_item_global_id
)
escoria.main.current_scene.game.inventory_item_focused(
inventory_item_global_id

View File

@@ -14,16 +14,6 @@ to benefit save games, so they don't conflict with the scene's events.
@ESC
## Property Descriptions
### readied\_scenes
```gdscript
var readied_scenes: Array
```
An array of scenes that have already been loaded
## Method Descriptions
### configure

View File

@@ -47,12 +47,12 @@ All ESC scripts are divided into a series of events, which in turn run commands
An event has a name and the prefix ":" like this:
`:setup`
`:ready`
While you can use arbitrary event names (for example to schedule them with the `sched_event`command), there are some special events that are called by Escoria when certaiin things happen:
While you can use arbitrary event names (for example to schedule them with the `sched_event`command), there are some special events that are called by Escoria when certain things happen:
* `:setup` (on an ESCScene object): Called everytime when the scene is loaded
* `:ready`(on an ESCScene object): Called only when the scene is loaded the first time
* `:setup` (on an ESCScene object): Called before the transition is performed.
* `:ready`(on an ESCScene object): Called after the transition is performed.
* `:use <global id>`(on an ESCItem object): Called when the inventory item `<global id>`was used with this item
* `:<verb>`(on an ESCItem object): Called when a special verb was used on the item (e.g. `:look`)

View File

@@ -1,6 +1,7 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=1]
[ext_resource path="res://game/characters/worker/worker_animations.tres" type="Resource" id=2]
[ext_resource path="res://game/characters/worker/png/worker.png" type="Texture" id=4]
[sub_resource type="AtlasTexture" id=1]
@@ -26,7 +27,7 @@ is_movable = true
tooltip_name = "Worker"
default_action = "look"
dialog_color = Color( 0.196078, 0, 1, 1 )
animations = null
animations = ExtResource( 2 )
[node name="sprite" type="AnimatedSprite" parent="."]
position = Vector2( 0.0280151, -16.7213 )

View File

@@ -0,0 +1,172 @@
[gd_resource type="Resource" load_steps=36 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/resources/esc_animationresource.gd" type="Script" id=1]
[ext_resource path="res://addons/escoria-core/game/core-scripts/resources/esc_directionangle.gd" type="Script" id=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/resources/esc_animationname.gd" type="Script" id=3]
[sub_resource type="Resource" id=1]
script = ExtResource( 2 )
angle_start = 340
angle_size = 40
[sub_resource type="Resource" id=2]
script = ExtResource( 2 )
angle_start = 20
angle_size = 50
[sub_resource type="Resource" id=3]
script = ExtResource( 2 )
angle_start = 70
angle_size = 40
[sub_resource type="Resource" id=4]
script = ExtResource( 2 )
angle_start = 110
angle_size = 50
[sub_resource type="Resource" id=5]
script = ExtResource( 2 )
angle_start = 160
angle_size = 40
[sub_resource type="Resource" id=6]
script = ExtResource( 2 )
angle_start = 200
angle_size = 50
[sub_resource type="Resource" id=7]
script = ExtResource( 2 )
angle_start = 250
angle_size = 40
[sub_resource type="Resource" id=8]
script = ExtResource( 2 )
angle_start = 290
angle_size = 50
[sub_resource type="Resource" id=9]
script = ExtResource( 3 )
animation = "walk_up"
mirrored = false
[sub_resource type="Resource" id=10]
script = ExtResource( 3 )
animation = "walk_up"
mirrored = false
[sub_resource type="Resource" id=11]
script = ExtResource( 3 )
animation = "walk_right"
mirrored = false
[sub_resource type="Resource" id=12]
script = ExtResource( 3 )
animation = "walk_down"
mirrored = false
[sub_resource type="Resource" id=13]
script = ExtResource( 3 )
animation = "walk_down"
mirrored = false
[sub_resource type="Resource" id=14]
script = ExtResource( 3 )
animation = "walk_down"
mirrored = false
[sub_resource type="Resource" id=15]
script = ExtResource( 3 )
animation = "walk_right"
mirrored = true
[sub_resource type="Resource" id=16]
script = ExtResource( 3 )
animation = "walk_up"
mirrored = false
[sub_resource type="Resource" id=17]
script = ExtResource( 3 )
animation = "idle_up"
mirrored = false
[sub_resource type="Resource" id=18]
script = ExtResource( 3 )
animation = "idle_up"
mirrored = false
[sub_resource type="Resource" id=19]
script = ExtResource( 3 )
animation = "idle_right"
mirrored = false
[sub_resource type="Resource" id=20]
script = ExtResource( 3 )
animation = "idle_down_right"
mirrored = false
[sub_resource type="Resource" id=21]
script = ExtResource( 3 )
animation = "idle_down"
mirrored = false
[sub_resource type="Resource" id=22]
script = ExtResource( 3 )
animation = "idle_down_left"
mirrored = false
[sub_resource type="Resource" id=23]
script = ExtResource( 3 )
animation = "idle_left"
mirrored = false
[sub_resource type="Resource" id=24]
script = ExtResource( 3 )
animation = "idle_up"
mirrored = false
[sub_resource type="Resource" id=25]
script = ExtResource( 3 )
animation = "speak_up"
mirrored = false
[sub_resource type="Resource" id=26]
script = ExtResource( 3 )
animation = "speak_up"
mirrored = false
[sub_resource type="Resource" id=27]
script = ExtResource( 3 )
animation = "speak_right"
mirrored = false
[sub_resource type="Resource" id=28]
script = ExtResource( 3 )
animation = "speak_down"
mirrored = false
[sub_resource type="Resource" id=29]
script = ExtResource( 3 )
animation = "speak_down"
mirrored = false
[sub_resource type="Resource" id=30]
script = ExtResource( 3 )
animation = "speak_down"
mirrored = false
[sub_resource type="Resource" id=31]
script = ExtResource( 3 )
animation = "speak_right"
mirrored = true
[sub_resource type="Resource" id=32]
script = ExtResource( 3 )
animation = "speak_up"
mirrored = false
[resource]
script = ExtResource( 1 )
dir_angles = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ]
directions = [ SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ]
idles = [ SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ) ]
speaks = [ SubResource( 25 ), SubResource( 26 ), SubResource( 27 ), SubResource( 28 ), SubResource( 29 ), SubResource( 30 ), SubResource( 31 ), SubResource( 32 ) ]

View File

@@ -1,90 +0,0 @@
#const dir_angles = [
# 0, # 0 NORTH FACE CAMERA
# 45, # 1 NORTHEAST
# 90, # 2 EAST
# 135, # 3 SOUTHEAST
# 180, # 4 SOUTH BACK TO CAMERA
# 225, # 5 SOUTHWEST
# 270, # 6 WEST
# 315, # 7 NORTHWEST
#]
# Angle is [from_angle, area_angle]
# example: on a clock, [180, 45] starts exactly from 6 o'clock (180°)
# and stops between 7 o'clock and 8 o'clock (45° from 6 o'clock)
const dir_angles = [
[340, 40], # 0 UP
[20, 50], # 1 RIGHT UP
[70, 40], # 2 RIGHT
[110, 50], # 3 RIGHT DOWN
[160, 40], # 4 DOWN
[200, 50], # 5 LEFT DOWN
[250, 40], # 6 LEFT
[290, 50] # 7 LEFT UP
]
# Array of animations for each direction, from UP to RIGHT_UP clockwise
# [animation_name, scale]: scale parameter can be set to -1 to mirror the animation
const directions = [
["walk_up", 1], # 0 UP
["walk_up", 1], # 1 RIGHT UP
["walk_right", 1], # 2 RIGHT
["walk_down", 1], # 3 RIGHT DOWN
["walk_down", 1], # 4 DOWN
["walk_down", 1], # 5 LEFT DOWN
["walk_right", -1], # 6 LEFT
["walk_up", 1] # 7 LEFT UP
]
const idles = [
["idle_up", 1], # 0 UP
["idle_up", 1], # 1 RIGHT UP
["idle_right", 1], # 2 RIGHT
["idle_down_right", 1], # 3 RIGHT DOWN
["idle_down", 1], # 4 DOWN
["idle_down_left", 1], # 5 LEFT DOWN
["idle_left", 1], # 6 LEFT
["idle_up", 1] # 7 LEFT UP
]
const speaks = [
["speak_up", 1], # 0 UP
["speak_up", 1], # 1 RIGHT UP
["speak_right", 1], # 2 RIGHT
["speak_down", 1], # 3 RIGHT DOWN
["speak_down", 1], # 4 DOWN
["speak_down", 1], # 5 LEFT DOWN
["speak_right", -1], # 6 LEFT
["speak_up", 1] # 7 LEFT UP
]
#const directions = ["walk_left", -1, # 0
# "walk_left", -1, # 1
# "walk_back", 1, # 2
# "walk_back", 1, # 3
# "walk_left", 1, # 4
# "walk_left", 1, # 5
# "walk_front", 1, # 6
# "walk_front", 1 # 7
# ]
#
#const idles = [ "idle_front_right", 1, # 0
# "idle_front_right", 1, # 1
# "idle_back", 1, # 2
# "idle_back", 1, # 3
# "idle_front_left", 1, # 4
# "idle_front_left", 1, # 5
# "idle_front", 1, # 6
# "idle_front", 1 # 7
# ]
#
#const speaks = ["idle_front_left", 1, # 0
# "idle_front_left", 1, # 1
# "idle_back", 1, # 2
# "idle_back", 1, # 3
# "idle_front_right", 1, # 4
# "idle_front_right", 1, # 5
# "idle_front", 1, # 6
# "idle_front", 1 # 7
# ]

View File

@@ -1,6 +1,4 @@
:setup
set_global dialog_advance 0
set_global dialog_popup_advance 0
> [eq ESC_LAST_SCENE room2]
teleport player r1_r_exit
# Set player look left
@@ -10,11 +8,19 @@
teleport player player_start
stop
:ready
set_sound_state bg_music res://game/sfx/contemplation.ogg true
walk player r1_destination_point
wait 2
walk player r1_destination_point2
wait 2
set_angle player 225 false
> [!room1_visited]
set_global room1_visited true
set_global dialog_advance 0
set_global dialog_popup_advance 0
walk player r1_destination_point
wait 2
walk player r1_destination_point2
wait 2
set_angle player 225 false

View File

@@ -1,6 +1,5 @@
# THIS ROOMS FEATURES AN OPEN BRIDGE WITH A BUTTON TO USE IN ORDER TO OPEN
:setup
> [r2_bridge_closed]
@@ -25,15 +24,14 @@
#set_global r2_bridge_closed true
set_interactive r2_right_platform false
#set_interactive r2_bridge false
stop
> [!last_scene]
teleport player player_start
stop
#teleport player player_start
:ready
# DEBUG
#set_state r2_bridge bridge_close

View File

@@ -1,7 +1,14 @@
# THIS ROOMS FEATURES AN OPEN BRIDGE WITH A ***BROKEN*** BUTTON TO USE IN ORDER TO OPEN
:setup
> [!room3_visited]
set_global room3_visited true
set_global r3_bridge_closed false
set_state r3_button button_broken
set_global button_broken true
> [r3_bridge_closed]
# Make set_state IMMEDIATE to reach the final frame immediately
set_state r3_bridge bridge_close true
@@ -21,16 +28,13 @@
# If bridge not closed
> [!r3_bridge_closed]
set_interactive r3_right_platform false
stop
> [!last_scene]
teleport player player_start
stop
:ready
set_global r3_bridge_closed false
set_state r3_button button_broken
set_global button_broken true
# DEBUG
#set_state r3_bridge bridge_close

View File

@@ -9,11 +9,7 @@
# Set player look left
set_angle player 270
stop
> [eq ESC_LAST_SCENE ""]
> [!last_scene]
teleport player player_start
stop
teleport player player_start
#walk player r_exit

View File

@@ -29,7 +29,6 @@
stop
:ready
#walk player r5_wrench
#set_global i/r5_wrench true
#set_active r5_wrench false

View File

@@ -13,7 +13,6 @@
teleport player player_start
stop
:ready
#set_global i/r5_pen true
#set_active r5_pen false
#set_global i/r5_empty_sheet true

View File

@@ -1,11 +1,10 @@
# :SETUP is called EVERY TIME the room is loaded
# :READY is called only the FIRST TIME the room is loaded
:setup
set_state r7_button_push button_repaired
set_state r7_button_shift button_repaired
set_state r7_button_follow button_repaired
set_state r7_button_zoom button_repaired
set_state r7_button_push button_repaired true
set_state r7_button_shift button_repaired true
set_state r7_button_follow button_repaired true
set_state r7_button_zoom button_repaired true
> [eq ESC_LAST_SCENE room6]
teleport player r7_l_exit
@@ -22,17 +21,3 @@ set_state r7_button_zoom button_repaired
stop
:ready
#camera_push player 0 LINEAR
#camera_push r7_object2 1 LINEAR
#wait 3
#camera_push player 1 LINEAR
#camera_set_drag_margin_enabled bool bool
#camera_set_pos real int int
#camera_set_target real
#camera_set_zoom real
#camera_set_zoom_height int
#camera_shift int int

View File

@@ -1,6 +1,3 @@
# :SETUP is called EVERY TIME the room is loaded
# :READY is called only the FIRST TIME the room is loaded
:setup
> [r8_m_door_open]
@@ -20,7 +17,3 @@
teleport player player_start
stop
:ready

View File

@@ -1,7 +1,13 @@
# :SETUP is called EVERY TIME the room is loaded
# :READY is called only the FIRST TIME the room is loaded
:setup
> [!room09_visited]
set_global room09_visited true
set_global open_closets 0
#set_state r9_closet_left closed
#set_state r9_closet_middle closed
#set_state r9_closet_right closed
> [eq ESC_LAST_SCENE room8]
teleport player r9_l_exit
# Set player look right
@@ -17,9 +23,3 @@
stop
:ready
set_global open_closets 0
#set_state r9_closet_left closed
#set_state r9_closet_middle closed
#set_state r9_closet_right closed

View File

@@ -1,14 +1,12 @@
# :SETUP is called EVERY TIME the room is loaded
# :READY is called only the FIRST TIME the room is loaded
:setup
> [eq ESC_LAST_SCENE room8]
teleport player r9_l_exit
> [eq ESC_LAST_SCENE room9]
teleport player r10_l_exit
# Set player look right
set_angle player 180
stop
> [eq ESC_LAST_SCENE room10]
teleport player r9_r_exit
> [eq ESC_LAST_SCENE room11]
teleport player r10_r_exit
# Set player look left
set_angle player 270
stop
@@ -16,10 +14,3 @@
teleport player player_start
stop
:ready
set_global open_closets 0
#set_state r9_closet_left closed
#set_state r9_closet_middle closed
#set_state r9_closet_right closed

View File

@@ -84,10 +84,10 @@ position = Vector2( 22.6786, 212.927 )
script = ExtResource( 5 )
[node name="Label" type="Label" parent="Hotspots/button_stop_bg_music"]
margin_left = -8.81946
margin_top = -30.2381
margin_right = 61.1805
margin_bottom = -14.2381
margin_left = -20.8195
margin_top = -29.2381
margin_right = 87.1805
margin_bottom = -8.2381
custom_fonts/font = ExtResource( 3 )
text = "Stop bg music"
__meta__ = {
@@ -105,10 +105,10 @@ position = Vector2( 22.6786, 212.927 )
script = ExtResource( 5 )
[node name="Label" type="Label" parent="Hotspots/button_play_bg_music"]
margin_left = -8.81946
margin_top = -30.2381
margin_right = 61.1805
margin_bottom = -14.2381
margin_left = -18.8195
margin_top = -29.2381
margin_right = 85.1805
margin_bottom = -8.2381
custom_fonts/font = ExtResource( 3 )
text = "Play bg music"
__meta__ = {
@@ -126,10 +126,10 @@ position = Vector2( 22.6786, 212.927 )
script = ExtResource( 5 )
[node name="Label" type="Label" parent="Hotspots/button_play_sound"]
margin_left = -8.81946
margin_top = -30.2381
margin_right = 61.1805
margin_bottom = -14.2381
margin_left = -10.8195
margin_top = -29.2381
margin_right = 72.1805
margin_bottom = -8.2381
custom_fonts/font = ExtResource( 3 )
text = "Play sound"
__meta__ = {
@@ -145,9 +145,10 @@ animations = null
[node name="Label" type="Label" parent="Hotspots/button_accept_input"]
margin_left = -3.6864
margin_top = -38.4435
margin_right = 71.3136
margin_bottom = -7.44354
margin_top = -44.4435
margin_right = 85.3136
margin_bottom = 0.556503
custom_fonts/font = ExtResource( 3 )
text = "Test Accept
Input"
__meta__ = {
@@ -167,10 +168,11 @@ tooltip_name = "Test slide"
animations = null
[node name="Label" type="Label" parent="Hotspots/button_slide"]
margin_left = -3.6864
margin_top = -38.4435
margin_right = 71.3136
margin_bottom = -7.44354
margin_left = -9.6864
margin_top = -28.4435
margin_right = 66.3136
margin_bottom = 2.55646
custom_fonts/font = ExtResource( 3 )
text = "Test Slide"
__meta__ = {
"_edit_use_anchors_": false
@@ -189,10 +191,11 @@ tooltip_name = "Test turn_to"
animations = null
[node name="Label" type="Label" parent="Hotspots/button_turn_to"]
margin_left = -3.6864
margin_top = -38.4435
margin_right = 71.3136
margin_bottom = -7.44354
margin_left = -14.6864
margin_top = -26.4435
margin_right = 80.3136
margin_bottom = 4.55646
custom_fonts/font = ExtResource( 3 )
text = "Test turn_to"
__meta__ = {
"_edit_use_anchors_": false