OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
barrels.h
1/*
2===========================================================================
3Copyright (C) 2024 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// barrels.h : Barrels
24
25#pragma once
26
27#include "entity.h"
28
29#define BARREL_INDESTRUCTABLE 1
30#define MAX_BARREL_LEAKS 4
31
32enum {
33 BARREL_EMPTY,
34 BARREL_OIL,
35 BARREL_WATER,
36 BARREL_GAS
37};
38
39class BarrelObject : public Entity
40{
41 int m_iBarrelType;
42 float m_fFluidAmount;
43 float m_fHeightFluid;
44 qboolean m_bLeaksActive[MAX_BARREL_LEAKS];
45 Vector m_vLeaks[MAX_BARREL_LEAKS];
46 Vector m_vLeakNorms[MAX_BARREL_LEAKS];
47 Vector m_vJitterAngles;
48 Vector m_vStartAngles;
49 float m_fJitterScale;
50 float m_fLastEffectTime;
51 float m_fDamageSoundTime;
52
53public:
54 CLASS_PROTOTYPE(BarrelObject);
55
56 BarrelObject();
57
58 int PickBarrelLeak(void);
59
60 void BarrelSetup(Event *ev);
61 void BarrelSetType(Event *ev);
62 void BarrelThink(Event *ev);
63 void BarrelDamaged(Event *ev);
64 void BarrelKilled(Event *ev);
65
66 void Archive(Archiver& arc) override;
67};
68
69inline void BarrelObject::Archive(Archiver& arc)
70{
71 Entity::Archive(arc);
72
73 arc.ArchiveInteger(&m_iBarrelType);
74 arc.ArchiveFloat(&m_fFluidAmount);
75 arc.ArchiveFloat(&m_fHeightFluid);
76 arc.ArchiveVector(&m_vJitterAngles);
77 arc.ArchiveVector(&m_vStartAngles);
78 arc.ArchiveFloat(&m_fJitterScale);
79 arc.ArchiveFloat(&m_fLastEffectTime);
80 arc.ArchiveFloat(&m_fDamageSoundTime);
81
82 for (int i = MAX_BARREL_LEAKS - 1; i >= 0; i--) {
83 arc.ArchiveBoolean(&m_bLeaksActive[i]);
84 arc.ArchiveVector(&m_vLeaks[i]);
85 arc.ArchiveVector(&m_vLeakNorms[i]);
86 }
87}
Definition archive.h:86
Definition listener.h:246
Definition vector.h:61