| 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 |
#pragma once |
| 30 |
|
| 31 |
#include <stdbool.h> |
| 32 |
|
| 33 |
#include "c_array.h" |
| 34 |
#include "cpic.h" |
| 35 |
#include "mathc/mathc.h" |
| 36 |
#include "pic.h" |
| 37 |
#include "proto/msg.pb.h" |
| 38 |
#include "vector.h" |
| 39 |
|
| 40 |
typedef enum |
| 41 |
{ |
| 42 |
KIND_CHARACTER, |
| 43 |
KIND_PARTICLE, |
| 44 |
KIND_MOBILEOBJECT, |
| 45 |
KIND_OBJECT, |
| 46 |
KIND_PICKUP |
| 47 |
} ThingKind; |
| 48 |
|
| 49 |
#define THING_IMPASSABLE 1 |
| 50 |
#define THING_CAN_BE_SHOT 2 |
| 51 |
#define THING_OBJECTIVE (8 + 16 + 32 + 64 + 128) |
| 52 |
#define THING_DRAW_BELOW 256 |
| 53 |
#define THING_DRAW_ABOVE 512 |
| 54 |
#define OBJECTIVE_SHIFT 3 |
| 55 |
|
| 56 |
|
| 57 |
typedef struct |
| 58 |
{ |
| 59 |
int MobObjId; |
| 60 |
struct vec2 Scale; |
| 61 |
union |
| 62 |
{ |
| 63 |
struct |
| 64 |
{ |
| 65 |
const CArray *Sprites; |
| 66 |
direction_e Dir; |
| 67 |
color_t Color; |
| 68 |
} MuzzleFlash; |
| 69 |
} u; |
| 70 |
} ThingDrawFuncData; |
| 71 |
typedef void (*ThingDrawFunc)(const struct vec2i, const ThingDrawFuncData *); |
| 72 |
typedef struct |
| 73 |
{ |
| 74 |
struct vec2 Pos; |
| 75 |
struct vec2 LastPos; |
| 76 |
struct vec2 Vel; |
| 77 |
struct vec2i size; |
| 78 |
ThingKind kind; |
| 79 |
int id; |
| 80 |
int flags; |
| 81 |
ThingDrawFunc drawFunc; |
| 82 |
ThingDrawFuncData drawData; |
| 83 |
CPic CPic; |
| 84 |
DrawCPicFunc CPicFunc; |
| 85 |
struct vec2 drawShake; |
| 86 |
struct vec2i ShadowSize; |
| 87 |
int SoundLock; |
| 88 |
} Thing; |
| 89 |
#define SOUND_LOCK_THING 12 |
| 90 |
|
| 91 |
|
| 92 |
typedef struct |
| 93 |
{ |
| 94 |
|
| 95 |
int Id; |
| 96 |
ThingKind Kind; |
| 97 |
} ThingId; |
| 98 |
|
| 99 |
|
| 100 |
bool IsThingInsideTile(const Thing *i, const struct vec2i tilePos); |
| 101 |
|
| 102 |
void ThingInit( |
| 103 |
Thing *t, const int id, const ThingKind kind, const struct vec2i size, |
| 104 |
const int flags); |
| 105 |
void ThingUpdate(Thing *t, const int ticks); |
| 106 |
void ThingAddDrawShake(Thing *t, const struct vec2 shake); |
| 107 |
void ThingDamage(const NThingDamage d); |
| 108 |
|
| 109 |
Thing *ThingGetByUID(const ThingKind kind, const int uid); |
| 110 |
Thing *ThingIdGetThing(const ThingId *tid); |
| 111 |
bool ThingDrawBelow(const Thing *t); |
| 112 |
bool ThingDrawAbove(const Thing *t); |