Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
entityplacementcallback.c
Go to the documentation of this file.
1
class
EntityPlacementCallback
: ObjectSnapCallback
2
{
3
#ifdef DIAG_DEVELOPER
4
#ifndef SERVER
5
ref
array<Shape>
m_Shapes =
new
array<Shape>
();
6
#endif
7
#endif
8
9
void
EntityPlacementCallback
()
10
{
11
}
12
13
void
~EntityPlacementCallback
()
14
{
15
ClearDebugShapes
();
16
}
17
18
void
ClearDebugShapes
()
19
{
20
#ifdef DIAG_DEVELOPER
21
#ifndef SERVER
22
foreach
(
auto
shape : m_Shapes)
23
{
24
shape.Destroy();
25
shape = null;
26
}
27
m_Shapes.Clear();
28
#endif
29
#endif
30
}
31
32
override
void
OnSetup
()
33
{
34
#ifdef DIAG_DEVELOPER
35
#ifndef SERVER
36
m_DebugEnabled
=
DiagMenu
.
GetBool
(
DiagMenuIDs
.INVENTORY_ENTITY_PLACEMENT_CALLBACK_DEBUG);
37
#endif
38
#endif
39
40
ClearDebugShapes
();
41
42
m_DirectionFunc
[0] = 1.2;
43
m_DirectionFunc
[1] = 0.3;
44
45
Human
human;
46
if
(
Class
.
CastTo
(human,
m_Owner
))
47
{
48
m_OwnerPosition
= human.GetBonePositionWS(human.
GetBoneIndexByName
(
"Head"
));
49
50
HumanInputController
hic = human.
GetInputController
();
51
if
(hic)
52
{
53
float
headingAngle = hic.
GetHeadingAngle
() +
Math
.
PI_HALF
;
54
m_OwnerDirection
[0] =
Math
.
Cos
(headingAngle);
55
m_OwnerDirection
[1] = 0.0;
56
m_OwnerDirection
[2] =
Math
.
Sin
(headingAngle);
57
58
m_OwnerDirection
.Normalized();
59
}
60
else
61
{
62
m_OwnerDirection
= human.GetDirection();
63
}
64
}
65
else
if
(
m_Owner
)
66
{
67
m_OwnerPosition
=
m_Owner
.GetPosition();
68
m_OwnerDirection
=
m_Owner
.GetDirection();
69
}
70
}
71
72
override
void
OnDebug
(
vector
p0,
vector
p1,
bool
hasHit,
bool
found)
73
{
74
#ifdef DIAG_DEVELOPER
75
#ifndef SERVER
76
Shape
shape;
77
78
int
alpha = 0x33000000;
79
int
colour = 0x00FF0000;
80
if
(!hasHit && found)
81
{
82
colour = 0x000000FF;
83
}
84
else
if
(!hasHit)
85
{
86
colour = 0x0000FF00;
87
alpha = 0x11000000;
88
}
89
90
shape =
Shape
.Create(
ShapeType
.BBOX, colour | alpha,
ShapeFlags
.NOZBUFFER |
ShapeFlags
.TRANSP, -
m_Extents
,
m_Extents
);
91
shape.SetMatrix(
m_Transform
);
92
m_Shapes.Insert(shape);
93
94
vector
p[2];
95
p[0] = p0;
96
p[1] = p1;
97
shape =
Shape
.CreateLines(colour | 0xFF000000,
ShapeFlags
.NOZBUFFER |
ShapeFlags
.TRANSP, p, 2);
98
m_Shapes.Insert(shape);
99
#endif
100
#endif
101
}
102
103
override
bool
OnFirstContact
(
Object
other)
104
{
105
if
(!other.IsTransport())
106
{
107
return
false
;
108
}
109
110
return
true
;
111
}
112
113
override
bool
OnQuery
(
Object
other)
114
{
115
if
(other.IsScenery())
116
{
117
return
false
;
118
}
119
120
if
(other.IsMan())
121
{
122
return
false
;
123
}
124
125
EntityAI
entity;
126
if
(
Class
.
CastTo
(entity, other))
127
{
128
if
(entity.IsAnimal() || entity.IsZombie())
129
{
130
return
false
;
131
}
132
}
133
134
if
(other.GetCollisionRadius() < 0.05)
135
{
136
return
false
;
137
}
138
139
return
true
;
140
}
141
142
override
bool
OnCollide
(
Object
other)
143
{
144
if
(other.IsScenery())
145
{
146
return
false
;
147
}
148
149
if
(other.IsMan())
150
{
151
return
false
;
152
}
153
154
if
(!other.CanObstruct() && !other.IsTransport())
155
{
156
return
false
;
157
}
158
159
return
true
;
160
}
161
};
Class
Super root of all classes in Enforce script.
Definition
enscript.c:11
DiagMenu
Definition
endebug.c:241
EntityAI
Definition
inventoryitem.c:2
EntityPlacementCallback::ClearDebugShapes
void ClearDebugShapes()
Definition
entityplacementcallback.c:18
EntityPlacementCallback::OnSetup
override void OnSetup()
Definition
entityplacementcallback.c:32
EntityPlacementCallback::OnQuery
override bool OnQuery(Object other)
Definition
entityplacementcallback.c:113
EntityPlacementCallback::OnFirstContact
override bool OnFirstContact(Object other)
Definition
entityplacementcallback.c:103
EntityPlacementCallback::OnCollide
override bool OnCollide(Object other)
Definition
entityplacementcallback.c:142
EntityPlacementCallback::~EntityPlacementCallback
void ~EntityPlacementCallback()
Definition
entityplacementcallback.c:13
EntityPlacementCallback::OnDebug
override void OnDebug(vector p0, vector p1, bool hasHit, bool found)
Definition
entityplacementcallback.c:72
EntityPlacementCallback::EntityPlacementCallback
void EntityPlacementCallback()
Definition
entityplacementcallback.c:9
Human
Definition
human.c:1333
Human::GetBoneIndexByName
proto native int GetBoneIndexByName(string pBoneName)
returns bone index for a name (-1 if pBoneName doesn't exist)
Human::GetInputController
proto native HumanInputController GetInputController()
returns human input controller
HumanInputController
Definition
human.c:18
HumanInputController::GetHeadingAngle
proto native float GetHeadingAngle()
returns main heading angle (in radians) -PI .. PI (this is world Y angle player is actualy pointing t...
Math
Definition
enmath.c:7
Object
Definition
objecttyped.c:2
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
vector
Definition
enconvert.c:119
DiagMenuIDs
DiagMenuIDs
Definition
ediagmenuids.c:2
ShapeType
ShapeType
Definition
endebug.c:116
ShapeFlags
ShapeFlags
Definition
endebug.c:126
DiagMenu::GetBool
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
Shape
class DiagMenu Shape
Instance of created debug visualizer.
Class::CastTo
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
Math::Cos
static proto float Cos(float angle)
Returns cosinus of angle in radians.
Math::PI_HALF
static const float PI_HALF
Definition
enmath.c:14
Math::Sin
static proto float Sin(float angle)
Returns sinus of angle in radians.
m_DirectionFunc
vector m_DirectionFunc
The size of the boundig box, centered.
Definition
object.c:18
m_Owner
enum ProcessDirectDamageFlags m_Owner
m_OwnerDirection
vector m_OwnerDirection
The position of the owner in world space.
Definition
object.c:13
m_Transform
vector m_Transform[4]
If 'OnDebug' is to be called.
Definition
object.c:21
m_DebugEnabled
bool m_DebugEnabled
How much should the direction be favoured.
Definition
object.c:20
m_OwnerPosition
vector m_OwnerPosition
The owner performing the snap callback.
Definition
object.c:12
m_Extents
vector m_Extents
The true center of the bounding box of the object to be dropped in model space.
Definition
object.c:16
Games
Dayz
scripts
4_world
systems
inventory
entityplacementcallback.c
Generated by
1.17.0