Merge branch 'develop' into feature/tilesets

# Conflicts:
#	godot/Main.tscn
#	godot/levels/Level2.tmx
#	godot/levels/Level2.tmx.import
#	godot/tilesets/tiles.tsx
This commit is contained in:
Chris Cromer 2022-04-20 10:22:52 -04:00
commit 9adf91c231
Signed by: cromer
GPG Key ID: FA91071797BEEEC2
32 changed files with 646 additions and 28 deletions

BIN
godot/assets/blocks/blocks-coin.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/blocks-coin.png-e02d021b2492bebc2d42f6607de594d0.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/blocks/blocks-coin.png"
dest_files=[ "res://.import/blocks-coin.png-e02d021b2492bebc2d42f6607de594d0.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/blocks/blocks-exclamation.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/blocks-exclamation.png-3d4ad82f7288be44d67e956f3c0bebbc.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/blocks/blocks-exclamation.png"
dest_files=[ "res://.import/blocks-exclamation.png-3d4ad82f7288be44d67e956f3c0bebbc.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/blocks/blocks-lock.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/blocks-lock.png-e62b69c90efbafbcd301ed5c5a597fa0.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/blocks/blocks-lock.png"
dest_files=[ "res://.import/blocks-lock.png-e62b69c90efbafbcd301ed5c5a597fa0.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/blocks/blocks-normal.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/blocks-normal.png-4af7780b7fe056a41734dfa530cd81c4.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/blocks/blocks-normal.png"
dest_files=[ "res://.import/blocks-normal.png-4af7780b7fe056a41734dfa530cd81c4.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/button.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button.png-c79155b6e84601a7c5a042250ad77b07.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/button.png"
dest_files=[ "res://.import/button.png-c79155b6e84601a7c5a042250ad77b07.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/coin.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/coin.png-f04b9cd408b88aba3ab0966b4da32df0.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/coin.png"
dest_files=[ "res://.import/coin.png-f04b9cd408b88aba3ab0966b4da32df0.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/flag.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/flag.png-29c6a06ab0a1d25cfcfa38ea2a7baffa.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/flag.png"
dest_files=[ "res://.import/flag.png-29c6a06ab0a1d25cfcfa38ea2a7baffa.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/gems/gem1.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/gem1.png-11065ad0e2eb5b112fc6a0edf260e97b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/gems/gem1.png"
dest_files=[ "res://.import/gem1.png-11065ad0e2eb5b112fc6a0edf260e97b.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/gems/gem2.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/gem2.png-72573c34c050e40128e078d94f847e09.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/gems/gem2.png"
dest_files=[ "res://.import/gem2.png-72573c34c050e40128e078d94f847e09.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/gems/gem3.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/gem3.png-471deee972b4e29e8d552e3b1ebf7645.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/gems/gem3.png"
dest_files=[ "res://.import/gem3.png-471deee972b4e29e8d552e3b1ebf7645.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/health.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/health.png-00457dc45e4c240f12819344f6504f87.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/health.png"
dest_files=[ "res://.import/health.png-00457dc45e4c240f12819344f6504f87.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/key.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/key.png-a97df9ba773df86f934812b8b28ef996.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/key.png"
dest_files=[ "res://.import/key.png-a97df9ba773df86f934812b8b28ef996.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/spring.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/spring.png-3b3902b04c9197ab9097abc899b361d1.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/spring.png"
dest_files=[ "res://.import/spring.png-3b3902b04c9197ab9097abc899b361d1.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
godot/assets/switch.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/switch.png-7f9d21c701660c7107ee136e6649068b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/switch.png"
dest_files=[ "res://.import/switch.png-7f9d21c701660c7107ee136e6649068b.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View File

@ -239,7 +239,7 @@
</tile>
<tile id="91">
<objectgroup draworder="index" id="2">
<object id="2" type="one-way" x="0" y="6" width="18" height="6"/>
<object id="1" type="one-way" x="0" y="6" width="18" height="6"/>
</objectgroup>
</tile>
<tile id="92">

View File

@ -25,12 +25,12 @@ void State::_init()
void State::_state_enter(const String state, const Array args)
{
WARN_PRINT("State " + state + " is missing its _state_enter method!");
WARN_PRINT("State " + get_state_machine()->get_current_state() + " is missing its _state_enter method!");
}
void State::_state_exit(const String state, const Array args)
{
WARN_PRINT("State " + state + " is missing its _state_exit method!");
WARN_PRINT("State " + get_state_machine()->get_current_state() + " is missing its _state_exit method!");
}
void State::set_parent(Node *parent)

View File

@ -34,7 +34,15 @@ void StateMachine::_ready()
connect("tree_entered", this, "_on_StateMachine_tree_entered");
connect("tree_exiting", this, "_on_StateMachine_tree_exiting");
parent = get_parent();
add_states();
if (has(get_default_state()))
{
set_current_state(get_default_state());
}
else
{
WARN_PRINT("The selected default state " + get_default_state() + " doesn't exist!");
}
setup();
}
@ -46,13 +54,13 @@ void StateMachine::setup()
{
if (children.size() > 0)
{
WARN_PRINT("State machine doesn't have a default state set, using first child!");
WARN_PRINT("The state machine doesn't have a default state set, using first child!");
auto child = Object::cast_to<Node>(children[0].operator Object*());
set_current_state(child->get_name());
}
else
{
ERR_PRINT("State machine doesn't have a default state set and has no child states!");
ERR_PRINT("The state machine doesn't have a default state set and has no child states!");
return;
}
}
@ -60,7 +68,6 @@ void StateMachine::setup()
for (uint8_t i = 0; i < children.size(); i++)
{
auto child = Object::cast_to<Node>(children[i].operator Object*());
add_state(child->get_name(), child);
child->call("set_state_machine", this);
@ -72,8 +79,25 @@ void StateMachine::setup()
}
}
Node *state_node = Object::cast_to<Node>(this->states[get_current_state()]);
if (state_node->has_method("_state_enter"))
{
this->call("_state_enter", get_current_state());
}
else {
WARN_PRINT("The state " + get_current_state() + " doesn't have a _state_enter method!");
}
}
void StateMachine::add_states()
{
auto children = get_children();
for (uint8_t i = 0; i < children.size(); i++)
{
auto child = Object::cast_to<Node>(children[i].operator Object*());
add_state(child->get_name(), child);
}
}
void StateMachine::add_state(const String state, Node *child)
{
@ -111,8 +135,31 @@ void StateMachine::change(const String state, const Array &args)
return this->restart(state, args);
}
if (!has(state))
{
WARN_PRINT("The state " + state + " does not exist, called from state " + get_current_state() + "!");
return;
}
auto previous_state = get_current_state();
auto exiting = this->call("_state_exit", state, args);
Variant exiting;
Node *state_node = Object::cast_to<Node>(this->states[previous_state]);
if (state_node)
{
if (state_node->has_method("_state_exit"))
{
exiting = this->call("_state_exit", state, args);
}
else
{
WARN_PRINT("The state " + get_current_state() + " doesn't have a _state_exit method!");
}
}
else
{
ERR_PRINT("Could not get current state node for " + get_current_state() + "!");
}
if (get_current_state() != "")
{
@ -132,7 +179,23 @@ void StateMachine::change(const String state, const Array &args)
auto child = Object::cast_to<Node>(states[get_current_state()].operator Object*());
this->add_child(child);
state_node = Object::cast_to<Node>(this->states[get_current_state()]);
if (state_node)
{
if (state_node->has_method("_state_enter"))
{
this->call("_state_enter", previous_state, args);
}
else
{
WARN_PRINT("The state " + get_current_state() + " doesn't have a _state_enter method!");
}
}
else
{
ERR_PRINT("Could not get current state node for " + get_current_state() + "!");
}
this->emit_signal("state_entered", get_current_state());
if (debug)
{
@ -143,12 +206,24 @@ void StateMachine::change(const String state, const Array &args)
Variant StateMachine::call(const String method, const Array &args)
{
auto node = Object::cast_to<Node>(states[get_current_state()].operator Object*());
if (node != nullptr)
if (node)
{
if (node->has_method(method))
{
return node->call(method, args);
}
else
{
WARN_PRINT("The state " + get_current_state() + " doesn't contain the method " + method + "!");
return Variant();
}
}
else
{
ERR_PRINT("Could not get current state node for " + get_current_state() + "!");
return Variant();
}
}
Variant StateMachine::_call(const String method, const Array &args)
{
@ -196,7 +271,7 @@ void StateMachine::_on_StateMachine_tree_exiting()
for (uint8_t i = 0; i < keys.size(); i++)
{
auto child = Object::cast_to<Node>(states[keys[i]].operator Object*());
if (child != nullptr)
if (child)
{
auto children = get_children();
if (!children.has(child))
@ -204,5 +279,10 @@ void StateMachine::_on_StateMachine_tree_exiting()
this->add_child(child);
}
}
else
{
ERR_PRINT("Could not get child node!");
return;
}
}
}

View File

@ -43,6 +43,12 @@ namespace godot
*/
Dictionary states;
/**
* @brief This adds all nodes of the states machine as states in the machine.
*
*/
void add_states();
/**
* @brief This adds a state to the list of states in the state machine.
*
@ -51,6 +57,13 @@ namespace godot
*/
void add_state(const String state, Node *child);
/**
* @brief Set the current state object.
*
* @param[in] current_state The current state that is running.
*/
void set_current_state(const String current_state);
public:
/**
* @brief This method registers classes with Godot.
@ -157,6 +170,13 @@ namespace godot
*/
String get_default_state();
/**
* @brief Get the current state object.
*
* @return String The current running state.
*/
String get_current_state();
/**
* @brief Set the debug object.
*
@ -172,20 +192,6 @@ namespace godot
*/
bool get_debug();
/**
* @brief Set the current state object.
*
* @param[in] current_state The current state that is running.
*/
void set_current_state(const String current_state);
/**
* @brief Get the current state object.
*
* @return String The current running state.
*/
String get_current_state();
/**
* @brief This method is called when the signal tree_entered is emitted.
*