-
-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathclasses.hpp
More file actions
68 lines (56 loc) · 1.92 KB
/
classes.hpp
File metadata and controls
68 lines (56 loc) · 1.92 KB
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
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*
* The original code is copyright (c) 2022, open.mp team and contributors.
*/
#pragma once
#include <sdk.hpp>
/// Player class interface
struct PlayerClass
{
int team; ///< The class's team
int skin; ///< The class's skin ID
Vector3 spawn; ///< The class's spawn position
float angle; ///< The class's angle
WeaponSlots weapons; ///< The class's weapons
PlayerClass(int skin, int team, Vector3 spawn, float angle, const WeaponSlots& weapons)
: team(team)
, skin(skin)
, spawn(spawn)
, angle(angle)
, weapons(weapons)
{
}
};
/// The class interface returned by the class pool
struct IClass : public IExtensible, public IIDProvider
{
/// Get the player class associated with the class interface
virtual const PlayerClass& getClass() = 0;
/// Set the player class data
virtual void setClass(const PlayerClass& data) = 0;
};
static const UID PlayerClassData_UID = UID(0x185655ded843788b);
struct IPlayerClassData : public IExtension
{
PROVIDE_EXT_UID(PlayerClassData_UID)
virtual const PlayerClass& getClass() = 0;
virtual void setSpawnInfo(const PlayerClass& info) = 0;
virtual void spawnPlayer() = 0;
};
/// The player class event handler
struct ClassEventHandler
{
virtual bool onPlayerRequestClass(IPlayer& player, unsigned int classId) { return true; }
};
static const UID ClassesComponent_UID = UID(0x8cfb3183976da208);
struct IClassesComponent : public IPoolComponent<IClass>
{
PROVIDE_UID(ClassesComponent_UID)
virtual IEventDispatcher<ClassEventHandler>& getEventDispatcher() = 0;
/// Attempt to create a new class from params
/// @return A pointer to the new class or nullptr if unable to create
virtual IClass* create(int skin, int team, Vector3 spawn, float angle, const WeaponSlots& weapons) = 0;
};