mirror of
https://github.com/zoriya/ForecastingVillage.git
synced 2026-05-30 09:38:33 +00:00
Disabling movements when the player enter in a dialog
This commit is contained in:
@@ -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;
|
||||
@@ -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",
|
||||
|
||||
@@ -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, \
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user