mirror of
https://github.com/zoriya/My3D.git
synced 2026-06-06 20:02:39 +00:00
Teams PM take down happiness
This commit is contained in:
+1
-1
Submodule lib/gamacon updated: 76101c2992...da57b43f45
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user