Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_PrefabDeleterEntity.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted/Utility"
, description:
"Delete entities in a certain radius."
)]
2
class
SCR_PrefabDeleterEntityClass
: GenericEntityClass
3
{
4
}
5
9
class
SCR_PrefabDeleterEntity
:
GenericEntity
10
{
11
/*
12
Deletion
13
*/
14
15
[
Attribute
(defvalue:
"1"
,
desc
:
"Delete player entities"
,
category
:
"Deletion"
)]
16
protected
bool
m_bDeletePlayers;
17
18
[
Attribute
(defvalue:
"0"
,
desc
:
"Only delete entities with a VObjectComponent, e.g a model/particle/etc; otherwise delete everything"
,
category
:
"Deletion"
)]
19
protected
bool
m_bOnlyDeleteVisibleEntities;
20
21
[
Attribute
(defvalue:
"10"
, uiwidget:
UIWidgets
.Slider,
desc
:
"Radius in which entities are deleted"
,
params
:
"0 1000 1"
,
category
:
"Deletion"
)]
22
protected
float
m_fRadius
;
23
24
[
Attribute
(defvalue:
"0"
, uiwidget:
UIWidgets
.Slider,
desc
:
"[s] Delay before deletion"
,
params
:
"0 10"
,
precision
: 1,
category
:
"Deletion"
)]
25
protected
float
m_fDelay
;
26
27
protected
static
ref array<IEntity> s_aFoundEntities = {};
28
29
//------------------------------------------------------------------------------------------------
30
override
void
EOnInit
(
IEntity
owner)
31
{
32
// authority only
33
RplComponent rplComponent = RplComponent.Cast(owner.
FindComponent
(RplComponent));
34
if
(rplComponent && !rplComponent.IsMaster())
35
return
;
36
37
// CallLater: delete after first frame to not break init
38
GetGame
().GetCallqueue().CallLater(
PerformDeletion
,
m_fDelay
* 1000,
param1
: owner);
39
}
40
41
//------------------------------------------------------------------------------------------------
42
protected
void
PerformDeletion
(
IEntity
owner)
43
{
44
EQueryEntitiesFlags
flags
=
EQueryEntitiesFlags
.ALL;
45
if
(m_bOnlyDeleteVisibleEntities)
46
flags
|=
EQueryEntitiesFlags
.WITH_OBJECT;
47
48
GetWorld
().QueryEntitiesBySphere(owner.
GetOrigin
(),
m_fRadius
,
PerformDeletion_QueryEntitiesCallback
, null,
flags
);
49
50
foreach
(
IEntity
entity : s_aFoundEntities)
51
{
52
if
(!entity)
// if one saw its parent already deleted
53
continue
;
54
55
if
(entity.Type() && entity.Type().IsInherited(
SCR_PrefabDeleterEntity
))
// avoid self and other deleters
56
continue
;
57
58
if
(
vector
.Distance(
GetOrigin
(), entity.GetOrigin()) >
m_fRadius
)
// sphere query works with bboxes; here we get more accurate by origin
59
continue
;
60
61
IEntity
root = entity.
GetRootParent
();
62
63
if
(!m_bDeletePlayers &&
EntityUtils
.IsPlayer(root))
64
continue
;
65
66
RplComponent.DeleteRplEntity(root,
false
);
67
}
68
69
s_aFoundEntities.Clear();
70
71
RplComponent.DeleteRplEntity(owner,
false
);
// destroy self
72
}
73
74
//------------------------------------------------------------------------------------------------
75
protected
bool
PerformDeletion_QueryEntitiesCallback
(
IEntity
e)
76
{
77
s_aFoundEntities.Insert(e);
78
return
true
;
79
}
80
81
//------------------------------------------------------------------------------------------------
82
// constructor
85
void
SCR_PrefabDeleterEntity
(
IEntitySource
src,
IEntity
parent)
86
{
87
if
(
m_fRadius
<= 0 || !
GetGame
().InPlayMode())
88
return
;
89
90
SetEventMask
(
EntityEvent
.INIT);
91
}
92
93
#ifdef WORKBENCH
94
95
//------------------------------------------------------------------------------------------------
96
override
int
_WB_GetAfterWorldUpdateSpecs
(IEntitySource src)
97
{
98
return
EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE | EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_SELECTED;
99
}
100
101
//------------------------------------------------------------------------------------------------
102
override
void
_WB_AfterWorldUpdate
(
float
timeSlice)
103
{
104
super._WB_AfterWorldUpdate(timeSlice);
105
if
(
m_fRadius
> 0)
106
Shape.CreateSphere(0x44FFCC00,
ShapeFlags
.WIREFRAME |
ShapeFlags
.ONCE |
ShapeFlags
.TRANSP,
GetOrigin
(),
m_fRadius
);
107
}
108
109
#endif
110
111
}
flags
SCR_EAIThreatSectorFlags flags
Definition
AIControlComponentSerializer.c:16
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
precision
params precision
Definition
SCR_2DOpticsComponent.c:20
GetOrigin
vector GetOrigin()
Definition
SCR_AIUtilityComponent.c:471
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
m_fDelay
float m_fDelay
Definition
SCR_EditorImagePositionEntity.c:21
PerformDeletion_QueryEntitiesCallback
bool PerformDeletion_QueryEntitiesCallback(IEntity e)
Definition
SCR_PrefabDeleterEntity.c:75
PerformDeletion
void PerformDeletion(IEntity owner)
Definition
SCR_PrefabDeleterEntity.c:42
SCR_PrefabDeleterEntity
void SCR_PrefabDeleterEntity(IEntitySource src, IEntity parent)
Definition
SCR_PrefabDeleterEntity.c:85
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
m_fRadius
float m_fRadius
Definition
SCR_SupportStationAreaMeshComponent.c:15
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
EntityUtils
Definition
EntityUtils.c:13
GenericEntity
Definition
GenericEntity.c:16
GenericEntity::_WB_AfterWorldUpdate
event void _WB_AfterWorldUpdate(float timeSlice)
Called after updating world in Workbench. The entity must be visible in frustum, selected or named....
GenericEntity::_WB_GetAfterWorldUpdateSpecs
event int _WB_GetAfterWorldUpdateSpecs(IEntitySource src)
Called after _WB_OnInit or also later when editor needs to know whether _WB_AfterWorldUpdate needs to...
IEntity
Definition
IEntity.c:13
IEntity::SetEventMask
proto external EntityEvent SetEventMask(EntityEvent e)
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::EOnInit
void EOnInit(IEntity owner)
IEntity::GetOrigin
proto external vector GetOrigin()
IEntity::GetWorld
proto external BaseWorld GetWorld()
IEntity::GetRootParent
proto external IEntity GetRootParent()
IEntitySource
Definition
IEntitySource.c:13
SCR_PrefabDeleterEntityClass
Definition
SCR_PrefabDeleterEntity.c:3
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
ShapeFlags
ShapeFlags
Definition
ShapeFlags.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EntityEvent
EntityEvent
Various entity events.
Definition
EntityEvent.c:14
param1
Tuple param1
EQueryEntitiesFlags
EQueryEntitiesFlags
Definition
EQueryEntitiesFlags.c:13
scripts
Game
Campaign
SCR_PrefabDeleterEntity.c
Generated by
1.17.0