aboutsummaryrefslogtreecommitdiffstats
path: root/src/entities/samantha.c
blob: 66b8996996990099290015c3d6344ccd4d063684 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "samantha.h"
#include "ui.h"

void initSamantha(Entity* entity)
{
  entity->box = (BoundingBox){
    .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)
{
  // silly tv static effect.
  game->assets.models[SAMANTHA_MODEL].materials[0]
    .maps[MATERIAL_MAP_DIFFUSE].texture =
    game->assets.textures[
      SAMANTHA_1_TEXTURE + ((int)(GetTime() * SAMANTHA_STATIC_SPEED) %
                            SAMANTHA_STATIC_FRAMES)];

  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->interactionChat;
  Samantha* samantha = (Samantha*)entity->data;

  switch (selection)
  {
  case SELECTION_INTERACT:
    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
    {
      samantha->dialogCount = 0;
      return INTERACTION_END;
    }
  case SELECTION_LEAVE:
    samantha->dialogCount = 0;
    return INTERACTION_END;
  default:
    return INTERACTION_END;
  }
}