zrR)(BpfqNK>|W|F?CP$GHVf~PmL6jnmtKs*{II|(vbje&P+|ZiQedIc>-*v
zW{sVGp>om__c!uXc@L0DwjwaBlLCUv86t0z8QYrEsi^ZGm>2LC1TkmtJA(ybrQYhmvhYiYLy+A8s{QhF-mZ$PxAN4E80)DgXok6>o1^g3Gkono$MrL1DQx=sUgo
zkj^X4*IB0i7-G68Fr4MVIJiJ|49tf69{rK<0a1`c#`KBWXU{b}FvK=wCXa0oS!Dm$
zCZ7fEIq8_x_!T=!;MHa%QjB=i`-esAaoqzpCSd_&+Wa#q=i_9;!_o!V>pRfvAeEm`
z%+KcrJs?ZP1PCXywzJlPzCqfB_)%em8SJmKuDFpJEI`Fmj1mTle<`Hz21`khqm8J%WM7*CX-^
z>A2vyJ3Q$0YM5B{<7^T0w7q&418Y{`?@tQU2Fdfk)fNo1
zE82@w_wDU8FMzVYGjo$8l(mc-(H)P@6IUAJ*6G&U5NAW->VE@3&5r-IwB0e9Xf6?xPx2IR6|E$8XE
zk@X486mSf>Z`Dc?*wt2<4|pC}NC~0rq#Ssd5~U%)Lva{hf{QXyBsPuH*GIjR8Obbr
zB*LgI#&XCeoW$;bbEsy=s^#QOhY;VD~JMevvYE2H2N4hd}%bm2U$b-GxU=*e=GTC
zqI4+u>CNlP2r87X0He8%y1#i$irVack8~c&E=bqTtXy-4;iQv-k>hg!Yj~XU@sV}h
zc;9^Y_`MO(a0h~uzj)RO5>H?^VWU833IqBx^Rj#a*y$|^Ry_~Ednh4-k;7J&NS-LfSTd{gDvA-%GtW)cUrq{d;ef`
zLPR^gZH)d12_~GReX}mzTXHVF_3J+#C{U=ewn)S%l+>eVuS>9y8&2$xKDmj-Phj*v
zOtDI2lc9+7-s}wA$_<+~gc`pAP=~=5_D-rX+S)Eg&h=s+B)x(~vEXg_M;SI6iu>;8
z;8E81x1XAe~o>!FdzIIj(UD4mt@E2?es8Pgd2d7yO|jm|9#{Y(HkuIpw{2~
zzDv?LzI3)gFr@pL11XJQZSlS8}0|5M7D|3kI^aokK(
zW_)89OIc?yLq%EBf-yr}(^TVjQ=&ALrLso$B_m6g`Z8m^#ZV+$B1JJwF0Mh}WXUaN
z?uf`f7zWk2A0FTDU+_IYoyX&x$64Oz{dvDX=RD8rwHb;ud5A%E)XP@l!+r?}ug^>(
z2t)Qm*5{37c%*2CY$gQ}#EQZzi05;uFAb9_iS?`s^uPoXt4EG}q`aw`By_@>u%j#4
z-Q-UlvffwWEUxokl(s0xnp+KRr&TtSt{q`ffs#p68ww>U7!qS7cum@&0YeBB`mXiX
zH9#R~`ddoU;<$R9GEJ}JaEh}pN&u%Qh=xXI`49!q&@)ff!X)v@4kjC-
zhQfJ~9U-zzSzGg+zYY+&794@zcKnFW4*hHRkBOozgzRDG9r&WdRp~oCMyL?w_S`$RKrym5t1dBR4M1NNOmI%yyM5oK>6W;uyh))C1Ru)S$DH3E-_rVSIiwjax>*e7
z8kkd1@oBLJqO0XgMRRrSxcaKo>Z7JLt?L_CII6fqc0Pzs8;li{x6*IY#Z5r))&@4>
z+JtPA%2kqwLGjt}jc)C{lM%(ni^)lp9WMH1S;;jYHeC`fX4+N?`ig%Jh1Z+tq)?PczAX6
z)Y3_LA2IP$fQZi^ocMRGoK&L|Y*1wPQZi=sO#uh%~@=Iv$S2@(*CoH9cC
zUid2a%L{OtA
z#pT26D&5REO7vn3LxC1n({3{|A#9cJnIm^vr_$J1D9rzY)-Oz>pXfkj2{;k20lQOd@H~@BjV^2rIp6D1}J?$ToR#&03;2V%nn82XP5yAj{
zWKe`wZirC>Ygd7;q?e>Wa5(6Zr8#Nrmd>TT0(lTqm$d9*Dl;xK^^=WXoiu>X%|UeM+y!xL8c6VIEMt8VgxsB@Cv#GV^|JXrj!-JP523jh1}Ve_2|w8H-a|NnCp
b1A}g$RjuDT7Y0&4NPvZ8d+OLTYijI2_y&7)
literal 0
HcmV?d00001
diff --git a/include/components/game_display.h b/include/components/game_display.h
new file mode 100644
index 0000000..9f1bb27
--- /dev/null
+++ b/include/components/game_display.h
@@ -0,0 +1,24 @@
+//
+// Created by anonymus-raccoon on 3/3/20.
+//
+
+#ifndef _TEAMS_COMPONENT_C_
+#define _TEAMS_COMPONENT_H_
+
+#include "component.h"
+
+typedef enum display_type
+{
+ HAPPINESS_DISPLAY
+} display_type;
+
+struct game_display
+{
+ gc_component base;
+ display_type type;
+};
+
+const struct game_display game_display;
+const struct gc_system game_display_system;
+
+#endif //_TEAMS_COMPONENT_C_
diff --git a/include/components/game_manager.h b/include/components/game_manager.h
new file mode 100644
index 0000000..dc7824a
--- /dev/null
+++ b/include/components/game_manager.h
@@ -0,0 +1,18 @@
+//
+// Created by anonymus-raccoon on 3/3/20.
+//
+
+#ifndef _TEAMS_COMPONENT_C_
+#define _TEAMS_COMPONENT_H_
+
+#include "component.h"
+
+struct game_manager
+{
+ gc_component base;
+ int happiness;
+};
+
+const struct game_manager game_manager;
+
+#endif //_TEAMS_COMPONENT_C_
diff --git a/include/components/teams_component.h b/include/components/teams_component.h
index 23b749f..6db17f3 100644
--- a/include/components/teams_component.h
+++ b/include/components/teams_component.h
@@ -13,6 +13,7 @@ struct teams_component
float next_teams;
float delay;
char **prefabs;
+ int *prefabs_size;
int prefab_count;
};
diff --git a/include/dpr_errors.h b/include/dpr_errors.h
new file mode 100644
index 0000000..58ad02b
--- /dev/null
+++ b/include/dpr_errors.h
@@ -0,0 +1,11 @@
+//
+// Created by anonymus-raccoon on 3/6/20.
+//
+
+#ifndef _DPR_ERRORS_H_
+#define _DPR_ERRORS_H_
+
+#define MULTIPLE_GAME_MGR_ERROR "Warning: two game manager exists, \
+behaviors are undefined.\n"
+
+#endif //_DPR_ERRORS_H_
diff --git a/lib/gamacon b/lib/gamacon
index 42743e0..76101c2 160000
--- a/lib/gamacon
+++ b/lib/gamacon
@@ -1 +1 @@
-Subproject commit 42743e0172e578c26c154c52851b7cadfdfda654
+Subproject commit 76101c299286c32f13c0917e01049b33848ff94b
diff --git a/lib/my/my/my_getnbr.c b/lib/my/my/my_getnbr.c
index e5832e0..6a837c1 100755
--- a/lib/my/my/my_getnbr.c
+++ b/lib/my/my/my_getnbr.c
@@ -55,7 +55,7 @@ int my_getnbr(const char *str)
int start_index = -1;
char c;
- for (int i = 0; 1; i++) {
+ for (int i = 0; str[i]; i++) {
c = str[i];
if ((c >= '0' && c <= '9') || c == '-' || c == '+') {
if (start_index == -1)
@@ -65,5 +65,7 @@ int my_getnbr(const char *str)
else if (count > 0 || c == '\0')
break;
}
+ if (count <= 0)
+ return (0);
return init_print(str, count, start_index);
}
diff --git a/lib/my/my/my_strdup.c b/lib/my/my/my_strdup.c
index 1ae14cc..e95701b 100644
--- a/lib/my/my/my_strdup.c
+++ b/lib/my/my/my_strdup.c
@@ -14,6 +14,8 @@ char *my_strdup(const char *src)
int length = my_strlen(src);
char *ret = malloc(sizeof(char) * (length + 1));
+ if (!ret)
+ return (NULL);
for (int i = 0; i < length; i++)
ret[i] = src[i];
ret[length] = '\0';
diff --git a/lib/my/my/tostr.c b/lib/my/my/tostr.c
index ce3e977..025415c 100644
--- a/lib/my/my/tostr.c
+++ b/lib/my/my/tostr.c
@@ -54,6 +54,9 @@ char *tostr(int n)
int count = get_new_size(n);
char *ret = malloc(sizeof(char) * (count + 1));
+ if (!ret)
+ return (NULL);
+
putnbr_in(n, base, ret, count);
ret[count] = '\0';
return (ret);
diff --git a/lib/my/src/#printf.c# b/lib/my/src/#printf.c#
deleted file mode 100644
index c8715a9..0000000
--- a/lib/my/src/#printf.c#
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** Sum stdarg
-** File description:
-** sum_stdarg
-*/
-
-#include "formaters.h"
-#include "my.h"
-#include
-#include
-
-formater_t formaters[] = {{string_formater, 's'},
- {string_nonprintable_formater, 'S'},
- {char_formater, 'c'},
- {int_formater, 'i'},
- {int_formater, 'd'},
- {octal_formater, 'o'},
- {hexa_formater, 'x'},
- {big_hexa_formater, 'X'},
- {uint_formater, 'u'},
- {ptr_formater, 'p'},
- {ubinary_formater, 'b'},
- {float_formater, 'f'},
- {float_formater, 'F'},
- {no_format, '%'},
- {0, 0}};
-
-const char modifiersCst[] = "#0-+ hl";
-
-int format(va_list ap, char flag, char modifiers[MODIFIERS_SIZE])
-{
- for (int i = 0; formaters[i].flag; i++) {
- if (formaters[i].flag == flag) {
- return (formaters[i].func(ap, modifiers));
- }
- }
- return (0);
-}
-
-int is_flag(char c)
-{
- for (int i = 0; formaters[i].flag; i++) {
- if (formaters[i].flag == c) {
- return (1);
- }
- }
- return (0);
-}
-
-int is_modifier(char c)
-{
- for (int i = 0; modifiersCst[i]; i++) {
- if (modifiersCst[i] == c)
- return (1);
- }
- return (0);
-}
-
-int get_modifiers(const char *str, char flags[MODIFIERS_SIZE])
-{
- int i;
-
- for (i = 0; !is_flag(str[i]); i++) {
- if (!is_modifier(str[i]) && !is_num(str[i]))
- return (-1);
- flags[i] = str[i];
- }
- flags[i] = '\0';
- return (i);
-}
-
-int my_printf(const char *str, ...)
-{
- int count = 0;
- va_list ap;
- char modifiers[MODIFIERS_SIZE];
- int next_is_flag;
-
- va_start(ap, str);
- for (int i = 0; str[i]; i++) {
- if (str[i] == '%') {
- next_is_flag = 1;
- i++;
- i += get_modifiers(&str[i], modifiers);
- } else
- next_is_flag = 0;
- if (next_is_flag && is_flag(str[i]))
- count += format(ap, str[i], modifiers);
- else
- count += write(1, &str[i], 1);
- }
- va_end(ap);
- return (count);
-}
\ No newline at end of file
diff --git a/lib/my/src/printf.c b/lib/my/src/printf.c
index 451fc28..3fa08e7 100644
--- a/lib/my/src/printf.c
+++ b/lib/my/src/printf.c
@@ -11,20 +11,21 @@
#include
formater_t formaters[] = {{string_formater, 's'},
- {string_nonprintable_formater, 'S'},
- {char_formater, 'c'},
- {int_formater, 'i'},
- {int_formater, 'd'},
- {octal_formater, 'o'},
- {hexa_formater, 'x'},
- {big_hexa_formater, 'X'},
- {uint_formater, 'u'},
- {ptr_formater, 'p'},
- {ubinary_formater, 'b'},
- {float_formater, 'f'},
- {float_formater, 'F'},
- {no_format, '%'},
- {0, 0}};
+ {string_nonprintable_formater, 'S'},
+ {char_formater, 'c'},
+ {int_formater, 'i'},
+ {int_formater, 'd'},
+ {octal_formater, 'o'},
+ {hexa_formater, 'x'},
+ {big_hexa_formater, 'X'},
+ {uint_formater, 'u'},
+ {ptr_formater, 'p'},
+ {ubinary_formater, 'b'},
+ {float_formater, 'f'},
+ {float_formater, 'F'},
+ {no_format, '%'},
+ {0, 0}
+};
const char modifiersCst[] = "#0-+ hl";
diff --git a/lib/xmlparser b/lib/xmlparser
index 5028a21..91f3604 160000
--- a/lib/xmlparser
+++ b/lib/xmlparser
@@ -1 +1 @@
-Subproject commit 5028a210a2b30afbea128f47e3030b4da84f0271
+Subproject commit 91f3604772158a2ff8c17fb74459088004e4fe15
diff --git a/prefabs/game.gcprefab b/prefabs/game.gcprefab
index debbca9..a68df99 100644
--- a/prefabs/game.gcprefab
+++ b/prefabs/game.gcprefab
@@ -5,10 +5,12 @@
+
+
@@ -24,17 +26,20 @@
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/prefabs/teams/absent.gcprefab b/prefabs/teams/absent.gcprefab
new file mode 100644
index 0000000..52cc769
--- /dev/null
+++ b/prefabs/teams/absent.gcprefab
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/prefabs/teams/forgot_register.gcprefab b/prefabs/teams/forgot_register.gcprefab
index 7c6dc71..206b462 100644
--- a/prefabs/teams/forgot_register.gcprefab
+++ b/prefabs/teams/forgot_register.gcprefab
@@ -1,8 +1,8 @@
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/game_display.c b/src/components/game_display.c
new file mode 100644
index 0000000..78acd75
--- /dev/null
+++ b/src/components/game_display.c
@@ -0,0 +1,63 @@
+/*
+** EPITECH PROJECT, 2020
+** DPR
+** File description:
+** game_stats
+*/
+
+#include
+#include
+#include "dpr_errors.h"
+#include "xml.h"
+#include "component.h"
+#include "utility.h"
+#include "components/game_display.h"
+#include
+
+static void ctr(void *component, va_list args)
+{
+ struct game_display *cmp = (struct game_display *)component;
+
+ cmp->type = va_arg(args, display_type);
+}
+
+static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
+{
+ struct game_display *cmp = (struct game_display *)component;
+ struct renderer *rend = GETCMP(entity, renderer);
+
+ cmp->type = HAPPINESS_DISPLAY;
+ if (!rend || rend->type != GC_TXTREND) {
+ my_printf("Using a game display without a text renderer.\n");
+ return;
+ }
+ ((gc_text *)rend->data)->text = malloc(sizeof(char) * 10);
+ if (((gc_text *)rend->data)->text)
+ ((gc_text *)rend->data)->text[0] = '\0';
+}
+
+static void dtr(void *component)
+{
+ (void)component;
+}
+
+static char *serialize(void *component)
+{
+ (void)component;
+ return (NULL);
+}
+
+const struct game_display game_display = {
+ base: {
+ name: "game_display",
+ size: sizeof(struct game_display),
+ dependencies: (char *[]) {
+ NULL
+ },
+ ctr: &ctr,
+ fdctr: &fdctr,
+ dtr: &dtr,
+ serialize: &serialize,
+ destroy: &component_destroy
+ }
+};
\ No newline at end of file
diff --git a/src/components/game_manager.c b/src/components/game_manager.c
new file mode 100644
index 0000000..a28d875
--- /dev/null
+++ b/src/components/game_manager.c
@@ -0,0 +1,54 @@
+/*
+** EPITECH PROJECT, 2020
+** DPR
+** File description:
+** game_stats
+*/
+
+#include "dpr_errors.h"
+#include "xml.h"
+#include "component.h"
+#include "utility.h"
+#include "components/game_manager.h"
+
+static void ctr(void *component, va_list args)
+{
+ struct game_manager *cmp = (struct game_manager *)component;
+
+ cmp->happiness = va_arg(args, int);
+}
+
+static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
+{
+ struct game_manager *cmp = (struct game_manager *)component;
+
+ cmp->happiness = xml_getintprop(n, "happiness");
+ if (scene->get_entity_by_cmp(scene, "game_manager"))
+ my_printf(MULTIPLE_GAME_MGR_ERROR);
+}
+
+static void dtr(void *component)
+{
+ (void)component;
+}
+
+static char *serialize(void *component)
+{
+ (void)component;
+ return (NULL);
+}
+
+const struct game_manager game_manager = {
+ base: {
+ name: "game_manager",
+ size: sizeof(struct game_manager),
+ dependencies: (char *[]) {
+ NULL
+ },
+ ctr: &ctr,
+ fdctr: &fdctr,
+ dtr: &dtr,
+ serialize: &serialize,
+ destroy: &component_destroy
+ }
+};
\ No newline at end of file
diff --git a/src/components/teams_component.c b/src/components/teams_component.c
index 04555d2..3f414cc 100644
--- a/src/components/teams_component.c
+++ b/src/components/teams_component.c
@@ -27,9 +27,17 @@ static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
cmp->next_teams = cmp->delay;
cmp->prefab_count = xml_getchildcount_filtered(n, "prefab");
cmp->prefabs = malloc(sizeof(char *) * cmp->prefab_count);
+ cmp->prefabs_size = malloc(sizeof(int) * cmp->prefab_count);
n = n->child;
+ if (!cmp->prefabs || !cmp->prefab_count) {
+ cmp->prefabs = NULL;
+ cmp->prefabs_size = NULL;
+ cmp->prefab_count = 0;
+ return;
+ }
for (int i = 0; i < cmp->prefab_count; i++) {
cmp->prefabs[i] = xml_getproperty(n, "src");
+ cmp->prefabs_size[i] = xml_getintprop(n, "height");
n = n->next;
}
}
diff --git a/src/game_loader.c b/src/game_loader.c
index 4ebb9bb..b63a758 100644
--- a/src/game_loader.c
+++ b/src/game_loader.c
@@ -10,9 +10,14 @@
#include "components/teams_component.h"
#include "systems/teams_system.h"
#include
+#include "components/game_display.h"
+#include "components/game_manager.h"
int register_customcmps(gc_engine *engine)
{
+ engine->add_component(engine, &game_manager);
+ engine->add_component(engine, &game_display);
+ engine->add_system(engine, &game_display_system);
engine->add_component(engine, &teams_component);
engine->add_system(engine, &teams_system);
engine->finish_physics(engine);
diff --git a/src/systems/game_display_system.c b/src/systems/game_display_system.c
new file mode 100644
index 0000000..9adf5be
--- /dev/null
+++ b/src/systems/game_display_system.c
@@ -0,0 +1,49 @@
+/*
+** EPITECH PROJECT, 2019
+** MUL_my_runner_2019
+** File description:
+** teams_system
+*/
+
+#include "entity.h"
+#include "system.h"
+#include
+#include "components/game_display.h"
+#include "components/game_manager.h"
+#include "text.h"
+#include "components/renderer.h"
+#include
+
+static void update_entity(gc_engine *engine, void *system, gc_entity *entity, \
+float dtime)
+{
+ struct game_display *disp = GETCMP(entity, game_display);
+ struct renderer *rend = GETCMP(entity, renderer);
+ struct game_manager *manager;
+ gc_scene *scene = engine->scene;
+ gc_list *entities = scene->get_entity_by_cmp(scene, "game_manager");
+
+ if (!entities)
+ return;
+ manager = GETCMP(entities->data, game_manager);
+ if (rend->type != GC_TXTREND)
+ return;
+ if (disp->type == HAPPINESS_DISPLAY)
+ sprintf(((gc_text *)rend->data)->text, "%d%%", manager->happiness);
+}
+
+static void destroy(void *system)
+{
+ (void)system;
+}
+
+const gc_system game_display_system = {
+ name: "game_display_system",
+ component_name: "game_display",
+ size: sizeof(gc_system),
+ ctr: NULL,
+ dtr: NULL,
+ check_dependencies: &system_check_dependencies,
+ update_entity: &update_entity,
+ destroy: &destroy
+};
\ No newline at end of file
diff --git a/src/systems/teams_system.c b/src/systems/teams_system.c
index f4a7197..eef7412 100644
--- a/src/systems/teams_system.c
+++ b/src/systems/teams_system.c
@@ -11,23 +11,41 @@
#include "components/teams_component.h"
#include
#include
+#include
+#include
+#include "my.h"
-static void move_teams_up(gc_scene *scene)
+static void move_teams_up(gc_scene *scene, float amount)
{
gc_list *list = scene->get_entity_by_cmp(scene, "tag_component");
- //Should filter components by the tag teams and move them up.
+ struct fixed_to_cam *fc;
+ struct tag_component *tc;
+
+ for (; list; list = list->next) {
+ tc = GETCMP(list->data, tag_component);
+ if (my_strcmp(tc->tag, "teams"))
+ continue;
+ fc = GETCMP(list->data, fixed_to_cam);
+ if (!fc)
+ continue;
+ fc->pos.y -= amount;
+ if (fc->pos.y < 15)
+ ((gc_entity *)list->data)->destroy(list->data, scene);
+ }
}
static void update_entity(gc_engine *engine, void *system, gc_entity *entity, \
float dtime)
{
struct teams_component *team = GETCMP(entity, teams_component);
+ 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);
- prefab_load(engine, team->prefabs[random() % team->prefab_count]);
+ move_teams_up(engine->scene, team->prefabs_size[index]);
+ prefab_load(engine, team->prefabs[index]);
}
}
From 1156affb2ceae7319d38130d448241020092d80d Mon Sep 17 00:00:00 2001
From: AnonymusRaccoon
Date: Fri, 6 Mar 2020 17:35:21 +0100
Subject: [PATCH 5/5] Teams PM take down happiness
---
lib/gamacon | 2 +-
src/systems/teams_system.c | 19 +++++++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/lib/gamacon b/lib/gamacon
index 76101c2..da57b43 160000
--- a/lib/gamacon
+++ b/lib/gamacon
@@ -1 +1 @@
-Subproject commit 76101c299286c32f13c0917e01049b33848ff94b
+Subproject commit da57b43f45546cefb28a4b485eb7d5ca0d4e1d42
diff --git a/src/systems/teams_system.c b/src/systems/teams_system.c
index eef7412..6f9a4fb 100644
--- a/src/systems/teams_system.c
+++ b/src/systems/teams_system.c
@@ -13,13 +13,15 @@
#include
#include
#include
+#include
#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]);
}
}