summaryrefslogtreecommitdiff
path: root/src/characters.h
blob: 2f1e10b2d4a78e50759351306e09e8ed9e4b0f6b (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#pragma once

#include "raylib.h"
#include "entity.h"
#include "array.h"

typedef enum {
  AA_IDLE = 0,
  AA_CHARGE = 1,
  AA_ATTACK = 2,
} AttackAnimState;

typedef enum {
  C_IDLE = 0,
  C_OBSERVE = 1,
  C_PATROL = 2,
  C_FOLLOW = 3,
  C_AGGRO = 4,
  C_HIT = 5,
  C_DEAD = 6
} CharState;

typedef enum {
  AI_NONE = 0,
  AI_IDLE = 1,
  AI_PATROL = 2,
  AI_DETECT = 3,
  AI_ATTACK = 4,
} AIState;

typedef enum {
  HA_IDLE = 0,
  HA_PLAY = 1,
} HitAnimState;

typedef enum {
  PATROL_TOP = 0,
  PATROL_LEFT = 1,
  PATROL_DOWN = 2,
  PATROL_RIGHT = 3,
} PatrolDir;

typedef struct Entity AttackedEntity;
typedef struct Entity AggroEntity;
typedef struct Entity FriendEntity;

struct Character {
  bool isburning;
  EntityType type; // TROLL / BANDIT
  int entity_id;
  CharState state;  // CharState
  int tile_id;      // MapSymbol
  int home_tile_id; // MapSymbol
  AIState ai_state;
  int health;
  float speed_multiplier;
  float move_speed;
  float detection_threshold;
  float attack_threshold;
  // improved idle behavior
  PatrolDir patrol_dir;
  bool to_core_pos;
  Vector2 core_position; // this is the main position characters will stick to
  double t_idle_start; // time spent at core position, useful to rotate them out
  // of positions
  float t_idle_duration; // max allowed duration they should be idle

  Vector2 position;
  Vector2 last_enemy_position;
  Vector2 move_dir;
  Vector2 target_position;
  Rectangle target_rect;
  Rectangle render_rect;
  Color tint_color_base;
  Color tint_color_active;
  Color tint_color;
  Texture2D *sprite;
  // AggroEntity attackers[2];
  EntityArrayList attackers;
  // FriendEntity friends[2];
  EntityArrayList friends;
  //
  // Animation
  //
  // getting hit
  HitAnimState anim_hit_state;
  float anim_hit_speed;
  double t_anim_hit_start;
  float t_anim_hit_duration;
  // getting burned
  double t_anim_burn_start;

  // attacking
  int anim_attack_state;
  float anim_attack_speed;
  float t_anim_charge_duration;
  float t_anim_attack_duration;
  double t_anim_charge_start;
  double t_anim_attack_start;
};