Teams PM take down happiness

This commit is contained in:
AnonymusRaccoon
2020-03-06 17:35:21 +01:00
parent ac1b41df02
commit 1156affb2c
2 changed files with 16 additions and 5 deletions
+15 -4
View File
@@ -13,13 +13,15 @@
#include <stdlib.h>
#include <components/tag_component.h>
#include <components/fixed_to_cam_component.h>
#include <components/game_manager.h>
#include "my.h"
static void move_teams_up(gc_scene *scene, float amount)
static bool move_teams_up(gc_scene *scene, float amount)
{
gc_list *list = scene->get_entity_by_cmp(scene, "tag_component");
struct fixed_to_cam *fc;
struct tag_component *tc;
bool pm_timeout = false;
for (; list; list = list->next) {
tc = GETCMP(list->data, tag_component);
@@ -29,22 +31,31 @@ static void move_teams_up(gc_scene *scene, float amount)
if (!fc)
continue;
fc->pos.y -= amount;
if (fc->pos.y < 15)
((gc_entity *)list->data)->destroy(list->data, scene);
if (fc->pos.y < 15) {
((gc_entity *) list->data)->destroy(list->data, scene);
pm_timeout = true;
}
}
return (pm_timeout);
}
static void update_entity(gc_engine *engine, void *system, gc_entity *entity, \
float dtime)
{
struct teams_component *team = GETCMP(entity, teams_component);
gc_scene *scene = engine->scene;
struct gc_list *m = scene->get_entity_by_cmp(scene, "game_manager");
struct game_manager *manager;
int index;
team->next_teams -= dtime;
if (team->next_teams < 0 && team->prefab_count) {
index = random() % team->prefab_count;
team->next_teams = team->delay;
move_teams_up(engine->scene, team->prefabs_size[index]);
if (move_teams_up(engine->scene, team->prefabs_size[index]) && m) {
manager = GETCMP(m->data, game_manager);
manager->happiness -= 10;
}
prefab_load(engine, team->prefabs[index]);
}
}