Disabling movements when the player enter in a dialog

This commit is contained in:
Anonymus Raccoon
2020-04-15 15:31:06 +02:00
parent c11962b462
commit 3ec83a6e43
4 changed files with 19 additions and 1 deletions
@@ -16,6 +16,9 @@ struct controllable_component
int movement_x;
int movement_y;
float move_callback;
bool can_move;
};
void controllable_set_can_move(gc_scene *scene, bool value);
extern const struct controllable_component controllable_component;
+12
View File
@@ -19,6 +19,7 @@ component;
cmp->movement_x = 0;
cmp->movement_y = 0;
cmp->move_callback = 0;
cmp->can_move = true;
(void)args;
}
@@ -47,6 +48,17 @@ static char *controllable_serialize(void *component)
return (NULL);
}
void controllable_set_can_move(gc_scene *scene, bool value)
{
gc_list *list = scene->get_entity_by_cmp(scene, "controllable_component");
struct controllable_component *ctl;
for (; list; list = list->next) {
ctl = GETCMP(list->data, controllable_component);
ctl->can_move = value;
}
}
const struct controllable_component controllable_component = {
base: {
name: "controllable_component",
+3
View File
@@ -6,6 +6,7 @@
*/
#include <malloc.h>
#include <components/controllable_component.h>
#include "components/map_linker.h"
#include "text.h"
#include "my.h"
@@ -78,6 +79,7 @@ static void check_for_dialog(gc_engine *engine, va_list args)
return;
if (this->dialog_id == -1)
load_dialog(this, engine, entity);
controllable_set_can_move(scene, false);
holder_name = scene->get_entity(scene, 1336);
entity = scene->get_entity(scene, 1337);
if (!update_dialog(this, entity, holder_name, scene))
@@ -87,6 +89,7 @@ static void check_for_dialog(gc_engine *engine, va_list args)
((gc_entity *) li->data)->destroy(li->data, scene);
}
this->dialog_id = -1;
controllable_set_can_move(scene, true);
}
static void update_entity(gc_engine *engine, void *system, gc_entity *entity, \
+1 -1
View File
@@ -68,7 +68,7 @@ float dtime)
gc_vector2i map_pos = get_new_map_pos(link, ctl);
struct tile *new_tile;
if (!maps)
if (!maps || !ctl->can_move)
return;
map = GETCMP(maps->data, vertex_component);
new_tile = get_tile_at(map, map_pos);