MARCH.c (894B)
1 #include "stb_ds.h" 2 #include "core/command.h" 3 #include "actions/movement.h" 4 5 static bool march(World *w, int id, int x, int y) { 6 Entity *e = World_Get_Entity(w, id); 7 if (e==NULL) return false; 8 Entity_Add_Component(e, (Component){ 9 .type = COMPONENT_MOVEMENT_TARGET, 10 .movement_target = { .x=x, .y=y } 11 }); 12 Component *actions = Entity_Find_Component(e, COMPONENT_ACTIONS); 13 if (actions==NULL) return false; 14 arrput(actions->actions.items, (struct Actions_Item){ .run = Action_Movement }); 15 Component *pos = Entity_Find_Component(e, COMPONENT_POSITION); 16 printf("[%d] MARCH_STARTED unitId=%d x=%d y=%d targetX=%d targetY=%d\n", w->turn, id, pos->position.x, pos->position.y, x, y); 17 return true; 18 } 19 20 bool cmd_march(World *w, int argc, char **argv) { 21 if (argc!=3) return false; 22 return march(w, atoi(argv[0]), atoi(argv[1]), atoi(argv[2])); 23 }