DayZ 1.24
Loading...
Searching...
No Matches
EntityPlacementCallback Class Reference
Inheritance diagram for EntityPlacementCallback:
[legend]
Collaboration diagram for EntityPlacementCallback:
[legend]

Private Member Functions

void EntityPlacementCallback ()
 
void ~EntityPlacementCallback ()
 
void ClearDebugShapes ()
 
override void OnSetup ()
 
override void OnDebug (vector p0, vector p1, bool hasHit, bool found)
 
override bool OnFirstContact (Object other)
 
override bool OnQuery (Object other)
 
override bool OnCollide (Object other)
 

Detailed Description

Definition at line 1 of file EntityPlacementCallback.c.

Constructor & Destructor Documentation

◆ EntityPlacementCallback()

void EntityPlacementCallback::EntityPlacementCallback ( )
inlineprivate

Definition at line 9 of file EntityPlacementCallback.c.

10 {
11 }

◆ ~EntityPlacementCallback()

void EntityPlacementCallback::~EntityPlacementCallback ( )
inlineprivate

Definition at line 13 of file EntityPlacementCallback.c.

References ClearDebugShapes().

Member Function Documentation

◆ ClearDebugShapes()

void EntityPlacementCallback::ClearDebugShapes ( )
inlineprivate

Definition at line 18 of file EntityPlacementCallback.c.

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 }

Referenced by OnSetup(), and ~EntityPlacementCallback().

◆ OnCollide()

override bool EntityPlacementCallback::OnCollide ( Object other)
inlineprivate

Definition at line 128 of file EntityPlacementCallback.c.

129 {
130 if (other.IsScenery())
131 return false;
132
133 if (other.IsMan())
134 return false;
135
136 if (!other.CanObstruct() && !other.IsTransport())
137 return false;
138
139 return true;
140 }

◆ OnDebug()

override void EntityPlacementCallback::OnDebug ( vector p0,
vector p1,
bool hasHit,
bool found )
inlineprivate

Definition at line 70 of file EntityPlacementCallback.c.

71 {
72#ifdef DIAG_DEVELOPER
73#ifndef SERVER
75
76 int alpha = 0x33000000;
77 int colour = 0x00FF0000;
78 if (!hasHit && found)
79 colour = 0x000000FF;
80 else if (!hasHit)
81 {
82 colour = 0x0000FF00;
83 alpha = 0x11000000;
84 }
85
86 shape = Shape.Create(ShapeType.BBOX, colour | alpha, ShapeFlags.NOZBUFFER | ShapeFlags.TRANSP, -m_Extents, m_Extents);
87 shape.SetMatrix(m_Transform);
88 m_Shapes.Insert(shape);
89
90 vector p[2];
91 p[0] = p0;
92 p[1] = p1;
93 shape = Shape.CreateLines(colour | 0xFF000000, ShapeFlags.NOZBUFFER | ShapeFlags.TRANSP, p, 2);
94 m_Shapes.Insert(shape);
95#endif
96#endif
97 }
vector m_Transform[4]
If 'OnDebug' is to be called.
Definition Object.c:21
vector m_Extents
The true center of the bounding box of the object to be dropped in model space.
Definition Object.c:16
ShapeType
Definition EnDebug.c:116
ShapeFlags
Definition EnDebug.c:126
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead

References m_Extents, m_Transform, and Shape.

◆ OnFirstContact()

override bool EntityPlacementCallback::OnFirstContact ( Object other)
inlineprivate

Definition at line 99 of file EntityPlacementCallback.c.

100 {
101 if (!other.IsTransport())
102 return false;
103
104 return true;
105 }

◆ OnQuery()

override bool EntityPlacementCallback::OnQuery ( Object other)
inlineprivate

Definition at line 107 of file EntityPlacementCallback.c.

108 {
109 if (other.IsScenery())
110 return false;
111
112 if (other.IsMan())
113 return false;
114
116 if (Class.CastTo(entity, other))
117 {
118 if (entity.IsAnimal() || entity.IsZombie())
119 return false;
120 }
121
122 if (other.GetCollisionRadius() < 0.05)
123 return false;
124
125 return true;
126 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo().

◆ OnSetup()

override void EntityPlacementCallback::OnSetup ( )
inlineprivate

Definition at line 32 of file EntityPlacementCallback.c.

33 {
34#ifdef DIAG_DEVELOPER
35#ifndef SERVER
36 m_DebugEnabled = DiagMenu.GetBool(DiagMenuIDs.INVENTORY_ENTITY_PLACEMENT_CALLBACK_DEBUG);
37#endif
38#endif
39
41
42 m_DirectionFunc[0] = 1.2;
43 m_DirectionFunc[1] = 0.3;
44
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;
55 m_OwnerDirection[1] = 0.0;
57
59 }
60 else
61 m_OwnerDirection = human.GetDirection();
62 }
63 else if (m_Owner)
64 {
65 m_OwnerPosition = m_Owner.GetPosition();
66 m_OwnerDirection = m_Owner.GetDirection();
67 }
68 }
DiagMenuIDs
Definition EDiagMenuIDs.c:2
vector m_DirectionFunc
The size of the boundig box, centered.
Definition Object.c:18
enum ProcessDirectDamageFlags m_Owner
vector m_OwnerDirection
The position of the owner in world space.
Definition Object.c:13
bool m_DebugEnabled
How much should the direction be favoured.
Definition Object.c:20
vector m_OwnerPosition
The owner performing the snap callback.
Definition Object.c:12
Definition EnMath.c:7
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
static const float PI_HALF
Definition EnMath.c:14
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Sin(float angle)
Returns sinus of angle in radians.

References Class::CastTo(), ClearDebugShapes(), Math::Cos(), DiagMenu::GetBool(), m_DebugEnabled, m_DirectionFunc, m_Owner, m_OwnerDirection, m_OwnerPosition, vector::Normalized(), Math::PI_HALF, and Math::Sin().


The documentation for this class was generated from the following file: