| 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 "c_array.h" |
| 32 |
#include "character.h" |
| 33 |
#include "particle.h" |
| 34 |
#include "player.h" |
| 35 |
#include "proto/msg.pb.h" |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
typedef enum |
| 43 |
{ |
| 44 |
GAME_EVENT_NONE, |
| 45 |
|
| 46 |
|
| 47 |
GAME_EVENT_CLIENT_CONNECT, |
| 48 |
GAME_EVENT_CLIENT_ID, |
| 49 |
GAME_EVENT_CAMPAIGN_DEF, |
| 50 |
GAME_EVENT_PLAYER_DATA, |
| 51 |
GAME_EVENT_PLAYER_REMOVE, |
| 52 |
GAME_EVENT_TILE_SET, |
| 53 |
|
| 54 |
GAME_EVENT_THING_DAMAGE, |
| 55 |
GAME_EVENT_MAP_OBJECT_ADD, |
| 56 |
GAME_EVENT_MAP_OBJECT_REMOVE, |
| 57 |
GAME_EVENT_CLIENT_READY, |
| 58 |
GAME_EVENT_NET_GAME_START, |
| 59 |
|
| 60 |
GAME_EVENT_CONFIG, |
| 61 |
GAME_EVENT_SCORE, |
| 62 |
GAME_EVENT_SOUND_AT, |
| 63 |
GAME_EVENT_SCREEN_SHAKE, |
| 64 |
GAME_EVENT_SET_MESSAGE, |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
GAME_EVENT_GAME_START, |
| 69 |
GAME_EVENT_GAME_BEGIN, |
| 70 |
|
| 71 |
GAME_EVENT_ACTOR_ADD, |
| 72 |
GAME_EVENT_ACTOR_MOVE, |
| 73 |
GAME_EVENT_ACTOR_STATE, |
| 74 |
GAME_EVENT_ACTOR_DIR, |
| 75 |
GAME_EVENT_ACTOR_SLIDE, |
| 76 |
GAME_EVENT_ACTOR_IMPULSE, |
| 77 |
GAME_EVENT_ACTOR_SWITCH_GUN, |
| 78 |
GAME_EVENT_ACTOR_PICKUP_ALL, |
| 79 |
GAME_EVENT_ACTOR_REPLACE_GUN, |
| 80 |
GAME_EVENT_ACTOR_HEAL, |
| 81 |
GAME_EVENT_ACTOR_ADD_AMMO, |
| 82 |
GAME_EVENT_ACTOR_USE_AMMO, |
| 83 |
GAME_EVENT_ACTOR_DIE, |
| 84 |
GAME_EVENT_PLAYER_ADD_LIVES, |
| 85 |
GAME_EVENT_ACTOR_MELEE, |
| 86 |
GAME_EVENT_ACTOR_PILOT, |
| 87 |
|
| 88 |
GAME_EVENT_ADD_PICKUP, |
| 89 |
GAME_EVENT_REMOVE_PICKUP, |
| 90 |
|
| 91 |
GAME_EVENT_BULLET_BOUNCE, |
| 92 |
GAME_EVENT_REMOVE_BULLET, |
| 93 |
GAME_EVENT_PARTICLE_REMOVE, |
| 94 |
GAME_EVENT_GUN_FIRE, |
| 95 |
GAME_EVENT_GUN_RELOAD, |
| 96 |
GAME_EVENT_GUN_STATE, |
| 97 |
GAME_EVENT_ADD_BULLET, |
| 98 |
GAME_EVENT_ADD_PARTICLE, |
| 99 |
GAME_EVENT_TRIGGER, |
| 100 |
GAME_EVENT_EXPLORE_TILES, |
| 101 |
GAME_EVENT_RESCUE_CHARACTER, |
| 102 |
GAME_EVENT_OBJECTIVE_UPDATE, |
| 103 |
GAME_EVENT_ADD_KEYS, |
| 104 |
GAME_EVENT_DOOR_TOGGLE, |
| 105 |
|
| 106 |
|
| 107 |
GAME_EVENT_MISSION_COMPLETE, |
| 108 |
|
| 109 |
|
| 110 |
GAME_EVENT_MISSION_INCOMPLETE, |
| 111 |
|
| 112 |
GAME_EVENT_MISSION_PICKUP, |
| 113 |
GAME_EVENT_MISSION_END |
| 114 |
} GameEventType; |
| 115 |
|
| 116 |
|
| 117 |
typedef struct |
| 118 |
{ |
| 119 |
GameEventType Type; |
| 120 |
|
| 121 |
bool Broadcast; |
| 122 |
|
| 123 |
bool Submit; |
| 124 |
|
| 125 |
bool Enqueue; |
| 126 |
|
| 127 |
bool GameStart; |
| 128 |
const pb_msgdesc_t *Fields; |
| 129 |
} GameEventEntry; |
| 130 |
GameEventEntry GameEventGetEntry(const GameEventType e); |
| 131 |
|
| 132 |
typedef struct |
| 133 |
{ |
| 134 |
GameEventType Type; |
| 135 |
int Delay; |
| 136 |
union |
| 137 |
{ |
| 138 |
NPlayerData PlayerData; |
| 139 |
NPlayerRemove PlayerRemove; |
| 140 |
NTileSet TileSet; |
| 141 |
NThingDamage ThingDamage; |
| 142 |
NMapObjectAdd MapObjectAdd; |
| 143 |
NMapObjectRemove MapObjectRemove; |
| 144 |
NConfig Config; |
| 145 |
NScore Score; |
| 146 |
NSound SoundAt; |
| 147 |
struct |
| 148 |
{ |
| 149 |
int Amount; |
| 150 |
bool CameraSubjectOnly; |
| 151 |
int ActorUID; |
| 152 |
} Shake; |
| 153 |
struct |
| 154 |
{ |
| 155 |
char Message[256]; |
| 156 |
int Ticks; |
| 157 |
} SetMessage; |
| 158 |
NGameBegin GameBegin; |
| 159 |
NActorAdd ActorAdd; |
| 160 |
NActorMove ActorMove; |
| 161 |
NActorState ActorState; |
| 162 |
NActorDir ActorDir; |
| 163 |
NActorSlide ActorSlide; |
| 164 |
NActorImpulse ActorImpulse; |
| 165 |
NActorSwitchGun ActorSwitchGun; |
| 166 |
NActorPickupAll ActorPickupAll; |
| 167 |
NActorReplaceGun ActorReplaceGun; |
| 168 |
NActorHeal Heal; |
| 169 |
NActorAddAmmo AddAmmo; |
| 170 |
NActorUseAmmo UseAmmo; |
| 171 |
NActorDie ActorDie; |
| 172 |
NPlayerAddLives PlayerAddLives; |
| 173 |
NActorMelee Melee; |
| 174 |
NActorPilot Pilot; |
| 175 |
NAddPickup AddPickup; |
| 176 |
NRemovePickup RemovePickup; |
| 177 |
struct |
| 178 |
{ |
| 179 |
int UID; |
| 180 |
int Count; |
| 181 |
} ObjectSetCounter; |
| 182 |
NBulletBounce BulletBounce; |
| 183 |
NRemoveBullet RemoveBullet; |
| 184 |
int ParticleRemoveId; |
| 185 |
NGunFire GunFire; |
| 186 |
NGunReload GunReload; |
| 187 |
NGunState GunState; |
| 188 |
NAddBullet AddBullet; |
| 189 |
AddParticle AddParticle; |
| 190 |
NTrigger TriggerEvent; |
| 191 |
NExploreTiles ExploreTiles; |
| 192 |
NRescueCharacter Rescue; |
| 193 |
NObjectiveUpdate ObjectiveUpdate; |
| 194 |
NAddKeys AddKeys; |
| 195 |
NDoorToggle DoorToggle; |
| 196 |
NMissionComplete MissionComplete; |
| 197 |
NMissionEnd MissionEnd; |
| 198 |
} u; |
| 199 |
} GameEvent; |
| 200 |
|
| 201 |
extern CArray gGameEvents; |
| 202 |
|
| 203 |
#define GAME_OVER_DELAY (FPS_FRAMELIMIT * 2) |
| 204 |
|
| 205 |
void GameEventsInit(CArray *store); |
| 206 |
void GameEventsTerminate(CArray *store); |
| 207 |
void GameEventsEnqueue(CArray *store, GameEvent e); |
| 208 |
void GameEventsClear(CArray *store); |
| 209 |
|
| 210 |
GameEvent GameEventNew(GameEventType type); |
| 211 |
GameEvent GameEventNewActorAdd(const struct vec2 pos, const Character *c, const PlayerData *p); |