-
-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathpickups.hpp
More file actions
131 lines (94 loc) · 4 KB
/
pickups.hpp
File metadata and controls
131 lines (94 loc) · 4 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* 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 <component.hpp>
#include <player.hpp>
#include <types.hpp>
#include <values.hpp>
typedef uint8_t PickupType;
/// Pickup base interface
struct IBasePickup : public IExtensible, public IEntity
{
/// Sets pickup's type and restreams
virtual void setType(PickupType type, bool update = true) = 0;
/// Gets pickup's type
virtual PickupType getType() const = 0;
/// Sets pickup's position but don't restream
virtual void setPositionNoUpdate(Vector3 position) = 0;
/// Sets pickup's model and restreams
virtual void setModel(int id, bool update = true) = 0;
/// Gets pickup's model
virtual int getModel() const = 0;
/// Checks if pickup is streamed for a player
virtual bool isStreamedInForPlayer(const IPlayer& player) const = 0;
/// Streams pickup for a player
virtual void streamInForPlayer(IPlayer& player) = 0;
/// Streams out pickup for a player
virtual void streamOutForPlayer(IPlayer& player) = 0;
/// Set pickup state hidden or shown for a player (only process streaming if pickup is not hidden)
virtual void setPickupHiddenForPlayer(IPlayer& player, bool hidden) = 0;
/// Check if given pickup has hidden state for player (only process streaming if pickup is not hidden)
virtual bool isPickupHiddenForPlayer(IPlayer& player) const = 0;
/// Used by legacy per-player pickups for ID mapping.
virtual void setLegacyPlayer(IPlayer* player) = 0;
/// Used by legacy per-player pickups for ID mapping.
virtual IPlayer* getLegacyPlayer() const = 0;
};
struct IPickup : public IBasePickup
{
};
struct IPlayerPickup : public IBasePickup
{
};
struct PickupEventHandler
{
virtual void onPlayerPickUpPickup(IPlayer& player, IPickup& pickup) { }
};
static const UID PickupsComponent_UID = UID(0xcf304faa363dd971);
struct IPickupsComponent : public IPoolComponent<IPickup>
{
PROVIDE_UID(PickupsComponent_UID);
virtual IEventDispatcher<PickupEventHandler>& getEventDispatcher() = 0;
/// Create a pickup
virtual IPickup* create(int modelId, PickupType type, Vector3 pos, uint32_t virtualWorld, bool isStatic) = 0;
/// Get the ID of this pickup as used in old pools (i.e. in pawn).
virtual int toLegacyID(int real) const = 0;
/// Get the ID of this pickup as used in the SDK.
virtual int fromLegacyID(int legacy) const = 0;
/// Release the ID used in limited pools.
virtual void releaseLegacyID(int legacy) = 0;
/// Return an ID not yet used in pawn (et al) to represent this pickup.
virtual int reserveLegacyID() = 0;
/// Assign a full ID to the legacy ID reserved earlier.
virtual void setLegacyID(int legacy, int real) = 0;
};
static const UID PickupData_UID = UID(0x98376F4428D7B70B);
struct IPlayerPickupData : public IExtension
{
PROVIDE_EXT_UID(PickupData_UID);
/// Get the ID of this pickup as used in old pools (i.e. in pawn).
virtual int toLegacyID(int real) const = 0;
/// Get the ID of this pickup as used in the SDK.
virtual int fromLegacyID(int legacy) const = 0;
/// Release the ID used in limited pools.
virtual void releaseLegacyID(int legacy) = 0;
/// Return an ID not yet used in pawn (et al) to represent this pickup.
virtual int reserveLegacyID() = 0;
/// Assign a full ID to the legacy ID reserved earlier.
virtual void setLegacyID(int legacy, int real) = 0;
/// Get the ID of this pickup as used internally (i.e. sent to the client).
virtual int toClientID(int real) const = 0;
/// Get the ID of this pickup as used in the SDK.
virtual int fromClientID(int legacy) const = 0;
/// Release the ID used on the client.
virtual void releaseClientID(int legacy) = 0;
/// Return an ID not yet used on the client to represent this pickup.
virtual int reserveClientID() = 0;
/// Assign a full ID to the legacy ID reserved earlier.
virtual void setClientID(int legacy, int real) = 0;
};