OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
ammo.h
1/*
2===========================================================================
3Copyright (C) 2015 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// ammo.h: Base class for all ammunition for entities derived from the Weapon class.
24
25#pragma once
26
27#include "g_local.h"
28#include "item.h"
29
30class AmmoEntity : public Item
31{
32public:
33 CLASS_PROTOTYPE(AmmoEntity);
34
35 AmmoEntity();
36 Item *ItemPickup(Entity *other, qboolean add_to_inventory) override;
37 void EventPostSpawn(Event *ev);
38};
39
40class Ammo : public Class
41{
42 int amount;
43 int maxamount;
44 str name;
45 int name_index;
46
47public:
48 CLASS_PROTOTYPE(Ammo);
49
50 Ammo();
51 Ammo(str name, int amount, int name_index);
52
53 void setAmount(int a);
54 int getAmount(void);
55 void setMaxAmount(int a);
56 int getMaxAmount(void);
57 void setName(str name);
58 str getName(void);
59 int getIndex(void);
60 void Archive(Archiver& arc) override;
61};
62
63inline void Ammo::Archive(Archiver& arc)
64{
65 Class::Archive(arc);
66
67 arc.ArchiveInteger(&amount);
68 arc.ArchiveInteger(&maxamount);
69 arc.ArchiveString(&name);
70 arc.ArchiveInteger(&name_index);
71 //
72 // name_index not archived, because it is auto-generated by gi.itemindex
73 //
74 if (arc.Loading()) {
75 setName(name);
76 }
77}
Definition archive.h:86
Definition entity.h:203
Definition listener.h:246
Definition str.h:77