-
-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathactors.hpp
More file actions
84 lines (64 loc) · 2.26 KB
/
actors.hpp
File metadata and controls
84 lines (64 loc) · 2.26 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
/*
* 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 <anim.hpp>
#include <component.hpp>
#include <player.hpp>
#include <types.hpp>
#include <values.hpp>
struct ActorSpawnData
{
Vector3 position;
float facingAngle;
int skin;
};
/// Actor interace
struct IActor : public IExtensible, public IEntity
{
/// Sets the actor's skin
virtual void setSkin(int id) = 0;
/// Gets the actor's model
virtual int getSkin() const = 0;
/// Apply an animation for the actor
virtual void applyAnimation(const AnimationData& animation) = 0;
/// Get the actor's applied animation
virtual const AnimationData& getAnimation() const = 0;
/// Clear the actor's animations
virtual void clearAnimations() = 0;
/// Set the actor's health
virtual void setHealth(float health) = 0;
/// Get the actor's health
virtual float getHealth() const = 0;
/// Set whether the actor is invulnerable
virtual void setInvulnerable(bool invuln) = 0;
/// Get whether the actor is invulnerable
virtual bool isInvulnerable() const = 0;
/// Checks if actor is streamed for a player
virtual bool isStreamedInForPlayer(const IPlayer& player) const = 0;
/// Streams actor for a player
virtual void streamInForPlayer(IPlayer& player) = 0;
/// Streams out actor for a player
virtual void streamOutForPlayer(IPlayer& player) = 0;
/// Get actor spawn data
virtual const ActorSpawnData& getSpawnData() = 0;
};
struct ActorEventHandler
{
virtual void onPlayerGiveDamageActor(IPlayer& player, IActor& actor, float amount, unsigned weapon, BodyPart part) { }
virtual void onActorStreamOut(IActor& actor, IPlayer& forPlayer) { }
virtual void onActorStreamIn(IActor& actor, IPlayer& forPlayer) { }
};
static const UID ActorsComponent_UID = UID(0xc81ca021eae2ad5c);
struct IActorsComponent : public IPoolComponent<IActor>
{
PROVIDE_UID(ActorsComponent_UID);
/// Get the ActorEventHandler event dispatcher
virtual IEventDispatcher<ActorEventHandler>& getEventDispatcher() = 0;
/// Create an actor
virtual IActor* create(int skin, Vector3 pos, float angle) = 0;
};