aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-12-19 02:23:24 +0000
committernathan <nathansmith@disroot.org>2025-12-19 02:23:24 +0000
commite4acecf8cebacbcbb6b7739aff7f34fd0147ed45 (patch)
tree90f266e8aee4b94682c318e9bc77ef6b1e034556
parent8394a306ed1d8dfdc9ca72e4c2c7888a4b79c576 (diff)
downloadFindThings-e4acecf8cebacbcbb6b7739aff7f34fd0147ed45.tar.gz
FindThings-e4acecf8cebacbcbb6b7739aff7f34fd0147ed45.tar.bz2
FindThings-e4acecf8cebacbcbb6b7739aff7f34fd0147ed45.zip
So little yet so much
-rw-r--r--src/entities/samantha.c32
-rw-r--r--src/entities/samantha.h5
-rw-r--r--src/entity.c2
-rw-r--r--src/ui.c5
-rw-r--r--src/ui.h1
5 files changed, 43 insertions, 2 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);
diff --git a/src/entity.c b/src/entity.c
index 92d4cf2..df14f34 100644
--- a/src/entity.c
+++ b/src/entity.c
@@ -13,7 +13,7 @@ const EntityEntry entityEntries[ENTITY_COUNT] = {
(EntityEntry){"Pond", initPond, updatePond, NULL, NULL, true, true},
(EntityEntry){"Utility Pole", initUtilityPole, NULL, NULL, NULL, false,
false},
- (EntityEntry){"Samantha", initSamantha, updateSamantha, NULL,
+ (EntityEntry){"Samantha", initSamantha, updateSamantha, closeSamantha,
interactWithSamantha, false, true},
(EntityEntry){"Samantha's Spot", initSamanthasSpot, updateSamanthasSpot,
NULL, NULL, true, false},
diff --git a/src/ui.c b/src/ui.c
index ae9341f..17a5c9f 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -35,6 +35,11 @@ void hideInteractionChat(InteractionChat* chat)
chat->visible = false;
}
+void setInteractionChat(InteractionChat* chat, const char* text)
+{
+ strncpy(chat->text, text, INTERACTION_CHAT_MAX * sizeof(char) - 1);
+}
+
void writeToInteractionChat(InteractionChat* chat, const char* text)
{
strncat(chat->text, text, INTERACTION_CHAT_MAX * sizeof(char) - 1);
diff --git a/src/ui.h b/src/ui.h
index 3c3ab47..7257855 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -17,6 +17,7 @@ typedef struct {
void initInteractionChat(InteractionChat* chat, const Settings* settings);
void showInteractionChat(InteractionChat* chat);
void hideInteractionChat(InteractionChat* chat);
+void setInteractionChat(InteractionChat* chat, const char* text);
void writeToInteractionChat(InteractionChat* chat, const char* text);
void clearInteractionChat(InteractionChat* chat);
void updateInteractionChat(InteractionChat* chat, Game* game);