aboutsummaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/samantha.c32
-rw-r--r--src/entities/samantha.h5
2 files changed, 36 insertions, 1 deletions
diff --git a/src/entities/samantha.c b/src/entities/samantha.c
index bc70b7a..d3c345b 100644
--- a/src/entities/samantha.c
+++ b/src/entities/samantha.c
@@ -7,6 +7,17 @@ void initSamantha(Entity* entity)
.min = (Vector3){-SAMANTHA_WIDTH, -SAMANTHA_HEIGHT, -SAMANTHA_THICKNESS},
.max = (Vector3){SAMANTHA_WIDTH, SAMANTHA_HEIGHT, SAMANTHA_THICKNESS}
};
+
+ entity->data = FT_MALLOC(sizeof(Samantha));
+
+ if (entity->data == NULL)
+ {
+ ALLOCATION_ERROR;
+ return;
+ }
+
+ Samantha* samantha = (Samantha*)entity->data;
+ samantha->dialogCount = 0;
}
void updateSamantha(Entity* entity, Game* game)
@@ -21,17 +32,36 @@ void updateSamantha(Entity* entity, Game* game)
DrawModel(game->assets.models[SAMANTHA_MODEL], entity->position, 1.0, WHITE);
}
+void closeSamantha(Entity* entity)
+{
+ if (entity->data != NULL)
+ {
+ FT_FREE(entity->data);
+ }
+}
+
InteractionCommand interactWithSamantha(Entity* entity, Game* game,
Selection selection)
{
InteractionChat* chat = &game->chat;
+ Samantha* samantha = (Samantha*)entity->data;
switch (selection)
{
case SELECTION_INTERACT:
- writeToInteractionChat(chat, "hihi");
+ setInteractionChat(chat, "hihi");
return INTERACTION_TALK;
case SELECTION_NEXT_MESSAGE:
+ if (samantha->dialogCount == 0)
+ {
+ setInteractionChat(chat, "I WILL DESTROY THE WORLD");
+ ++samantha->dialogCount;
+ return INTERACTION_TALK;
+ }
+ else
+ {
+ return INTERACTION_END;
+ }
case SELECTION_LEAVE:
return INTERACTION_END;
default:
diff --git a/src/entities/samantha.h b/src/entities/samantha.h
index 57587ff..c532215 100644
--- a/src/entities/samantha.h
+++ b/src/entities/samantha.h
@@ -10,8 +10,13 @@
#define SAMANTHA_STATIC_SPEED 24
#define SAMANTHA_STATIC_FRAMES 4
+typedef struct {
+ int dialogCount;
+} Samantha;
+
void initSamantha(Entity* entity);
void updateSamantha(Entity* entity, Game* game);
+void closeSamantha(Entity* entity);
InteractionCommand interactWithSamantha(Entity* entity, Game* game,
Selection selection);