-
-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathcheckpoints.hpp
More file actions
79 lines (67 loc) · 2.36 KB
/
checkpoints.hpp
File metadata and controls
79 lines (67 loc) · 2.36 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
/*
* 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>
/// The type of the checkpoint: https://open.mp/docs/scripting/functions/SetPlayerRaceCheckpoint
/// Note: checkpoint types are not restricted to any type of vehicle/on foot
enum class RaceCheckpointType
{
RACE_NORMAL = 0, // Must have nextPosition, else it shows as RACE_FINISH
RACE_FINISH, // Must have no nextPosition, else it shows as RACE_NORMAL
RACE_NOTHING,
RACE_AIR_NORMAL,
RACE_AIR_FINISH,
RACE_AIR_ONE,
RACE_AIR_TWO,
RACE_AIR_THREE,
RACE_AIR_FOUR,
RACE_NONE,
};
struct ICheckpointDataBase
{
virtual Vector3 getPosition() const = 0;
virtual void setPosition(const Vector3& position) = 0;
virtual float getRadius() const = 0;
virtual void setRadius(float radius) = 0;
virtual bool isPlayerInside() const = 0;
virtual void setPlayerInside(bool inside) = 0;
virtual void enable() = 0;
virtual void disable() = 0;
virtual bool isEnabled() const = 0;
};
struct ICheckpointData : public ICheckpointDataBase
{
};
struct IRaceCheckpointData : public ICheckpointDataBase
{
virtual RaceCheckpointType getType() const = 0;
virtual void setType(RaceCheckpointType type) = 0;
virtual Vector3 getNextPosition() const = 0;
virtual void setNextPosition(const Vector3& nextPosition) = 0;
};
static const UID PlayerCheckpointData_UID = UID(0xbc07576aa3591a66);
struct IPlayerCheckpointData : public IExtension
{
PROVIDE_EXT_UID(PlayerCheckpointData_UID);
virtual IRaceCheckpointData& getRaceCheckpoint() = 0;
virtual ICheckpointData& getCheckpoint() = 0;
};
struct PlayerCheckpointEventHandler
{
virtual void onPlayerEnterCheckpoint(IPlayer& player) { }
virtual void onPlayerLeaveCheckpoint(IPlayer& player) { }
virtual void onPlayerEnterRaceCheckpoint(IPlayer& player) { }
virtual void onPlayerLeaveRaceCheckpoint(IPlayer& player) { }
};
static const UID CheckpointsComponent_UID = UID(0x44a937350d611dde);
struct ICheckpointsComponent : public IComponent
{
PROVIDE_UID(CheckpointsComponent_UID)
// Access to event dispatchers for other components to add handlers to
virtual IEventDispatcher<PlayerCheckpointEventHandler>& getEventDispatcher() = 0;
};