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_SpherePointGeneratorPreviewComponent.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted/Utilities"
, description:
"Displays points generated by the SCR_SpherePointGenerator"
)]
2
class
SCR_SpherePointGeneratorPreviewComponentClass
:
ScriptComponentClass
3
{
4
}
5
6
class
SCR_SpherePointGeneratorPreviewComponent :
ScriptComponent
7
{
8
[
Attribute
(
desc
:
"Radii of spheres to generate"
, defvalue:
"{}"
,
category
:
"Sphere"
,
params
:
"0.001 inf"
)]
9
ref array<float> m_aSphereRadii;
10
11
[
Attribute
(
desc
:
"Size of generated points"
, defvalue:
"1"
,
category
:
"Sphere"
,
params
:
"0.001 inf"
)]
12
float
m_fPointSize;
13
14
[
Attribute
(
desc
:
"Maximum generated points"
, defvalue:
"1000"
,
category
:
"Sphere"
,
params
:
"0 100000"
)]
15
int
m_iMaxPoints;
16
17
[
Attribute
(
desc
:
"Spacing between generated points. "
, defvalue:
"5"
,
category
:
"Spacing Based"
,
params
:
"0.001 inf"
)]
18
float
m_fSpacing;
19
20
[
Attribute
(
desc
:
"Amount of Points to generate in each sphere. Overrides Spacing Based settings."
, defvalue:
"{}"
,
category
:
"Amount Based"
,
params
:
"0 100000"
)]
21
ref array<int> m_aPointAmounts;
22
23
[
Attribute
(
desc
:
"Base color"
, defvalue:
""
,
category
:
"Labelling"
)]
24
ref
Color
m_BaseColor
;
25
26
[
Attribute
(
desc
:
"Hue-shift By Point In Sphere"
, defvalue:
"1"
,
category
:
"Labelling"
)]
27
bool
m_bHueShiftByIndex
;
28
29
[
Attribute
(
desc
:
"Hue-shift By Sphere"
, defvalue:
"1"
,
category
:
"Labelling"
)]
30
bool
m_bHueShiftBySphere
;
31
32
[
Attribute
(
desc
:
"Show index"
, defvalue:
"1"
,
category
:
"Labelling"
)]
33
bool
m_bShowIndex
;
34
35
protected
string
m_sInstanceId
;
36
37
protected
static
const
int
PREVIEW_POINT_BUDGET = 100000;
38
protected
static
ref set<string> s_KeyUpdateSet;
39
40
//------------------------------------------------------------------------------------------------
42
override
protected
void
OnPostInit
(
IEntity
owner)
43
{
44
DrawPreview
();
45
}
46
47
//------------------------------------------------------------------------------------------------
50
protected
void
DrawPreview
()
51
{
52
string
tag =
string
.Format(
"SCR_SpherePointGeneratorPreview_%1"
,
GetInstanceId
());
53
SCR_DebugShapeHelperComponent.RemoveTag(tag);
54
if
(!
IsActive
())
55
return
;
56
57
int
sphereAmount = m_aSphereRadii.Count();
58
if
(sphereAmount < 1)
59
return
;
60
61
if
(!
m_BaseColor
)
62
m_BaseColor
=
Color
.FromInt(SCR_DebugShapeHelperComponent.MakeTransparent(
Color
.VIOLET));
63
if
(m_fSpacing < 0.01)
64
m_fSpacing = 0.01;
65
66
World
world =
GetOwner
().
GetWorld
();
67
vector
position
=
GetOwner
().
GetOrigin
();
68
SCR_ColorAHSV
colorHSVA =
SCR_ColorAHSV
.FromColor(
m_BaseColor
);
69
int
colorInt =
m_BaseColor
.PackToInt();
70
float
pointShiftOffset = 0;
71
float
pointShiftModifier = 0.833;
// Prevents full hue rotation to avoid confusion.
72
if
(
m_bHueShiftBySphere
)
73
pointShiftModifier /= sphereAmount;
74
75
int
remainingPointBudget =
Math
.Min(m_iMaxPoints, PREVIEW_POINT_BUDGET);
76
for
(
int
sphereI = 1; sphereI <= sphereAmount; ++sphereI)
77
{
78
int
pointsAmount;
79
float
radius = m_aSphereRadii[sphereI - 1];
80
if
(radius <= 0)
81
continue
;
82
83
if
(m_aPointAmounts.Count() >= sphereI)
84
pointsAmount = m_aPointAmounts[sphereI - 1];
85
else
86
pointsAmount =
SCR_SpherePointGenerator
.EstimatePointsFromSpacingOnUnitSphere(m_fSpacing / radius);
87
88
if
(pointsAmount < 0)
89
continue
;
// Allow other sheres with defiend points to be renderd.
90
91
pointsAmount =
Math
.Min(pointsAmount, remainingPointBudget);
92
remainingPointBudget -= pointsAmount;
93
if
(pointsAmount < 1)
94
break
;
// No more points in budget.
95
96
if
(
m_bHueShiftBySphere
)
97
pointShiftOffset = (sphereI - 1) / sphereAmount;
98
for
(
int
pointI = 0; pointI < pointsAmount; ++pointI)
99
{
100
int
shiftedColor = colorInt;
101
if
(
m_bHueShiftByIndex
)
102
shiftedColor = colorHSVA.WithHueShift(pointShiftOffset + pointShiftModifier * (pointI / pointsAmount)).ToColor().PackToInt();
103
vector
point =
position
+ radius *
SCR_SpherePointGenerator
.GetPointOnUnitSphereFromEquator(pointsAmount, pointI);
104
SCR_DebugShapeHelperComponent.AddSphere(point, m_fPointSize, shiftedColor, tag: tag);
105
if
(world &&
m_bShowIndex
)
106
SCR_DebugShapeHelperComponent.AddText(world, point, pointI.ToString(), tag: tag);
107
}
108
}
109
}
110
111
//------------------------------------------------------------------------------------------------
115
protected
string
GetInstanceId
()
116
{
117
if
(!
SCR_StringHelper
.
IsEmptyOrWhiteSpace
(
m_sInstanceId
))
118
return
m_sInstanceId
;
119
m_sInstanceId
=
GetOwner
().
GetName
();
120
return
m_sInstanceId
;
121
}
122
123
//------------------------------------------------------------------------------------------------
125
override
void
_WB_OnInit
(
IEntity
owner, inout
vector
mat[4],
IEntitySource
src)
126
{
127
DrawPreview
();
128
super._WB_OnInit(owner, mat, src);
129
}
130
131
//------------------------------------------------------------------------------------------------
133
override
bool
_WB_OnKeyChanged
(
IEntity
owner,
BaseContainer
src,
string
key,
BaseContainerList
ownerContainers,
IEntity
parent)
134
{
135
if
(key ==
"coords"
)
136
{
137
DrawPreview
();
138
return
true
;
139
}
140
141
if
(GetKeyUpdateSet().
Contains
(key))
142
return
false
;
143
144
return
true
;
145
}
146
147
//------------------------------------------------------------------------------------------------
150
override
void
OnDelete
(
IEntity
owner)
151
{
152
SCR_DebugShapeHelperComponent.RemoveTag(
"SCR_SpherePointGeneratorPreview_"
+
GetInstanceId
());
153
}
154
155
//------------------------------------------------------------------------------------------------
157
protected
static
set<string> GetKeyUpdateSet()
158
{
159
if
(!s_KeyUpdateSet)
160
{
161
s_KeyUpdateSet =
new
set<string>();
162
s_KeyUpdateSet.Insert(
"Enabled"
);
163
s_KeyUpdateSet.Insert(
"m_aSphereRadii"
);
164
s_KeyUpdateSet.Insert(
"m_fPointSize"
);
165
s_KeyUpdateSet.Insert(
"m_iMaxPoints"
);
166
s_KeyUpdateSet.Insert(
"m_fSpacing"
);
167
s_KeyUpdateSet.Insert(
"m_aPointAmounts"
);
168
s_KeyUpdateSet.Insert(
"m_BaseColor"
);
169
s_KeyUpdateSet.Insert(
"m_bHueShiftByIndex"
);
170
s_KeyUpdateSet.Insert(
"m_bHueShiftBySphere"
);
171
s_KeyUpdateSet.Insert(
"m_bShowIndex"
);
172
}
173
return
s_KeyUpdateSet;
174
}
175
}
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
position
vector position
Definition
SCR_DestructibleTreeV2.c:30
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
m_bShowIndex
bool m_bShowIndex
Definition
SCR_SpherePointGeneratorPreviewComponent.c:33
m_bHueShiftBySphere
bool m_bHueShiftBySphere
Definition
SCR_SpherePointGeneratorPreviewComponent.c:30
m_BaseColor
ref Color m_BaseColor
Definition
SCR_SpherePointGeneratorPreviewComponent.c:24
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
GetInstanceId
string GetInstanceId()
Definition
SCR_SpherePointGeneratorPreviewComponent.c:115
m_sInstanceId
string m_sInstanceId
Definition
SCR_SpherePointGeneratorPreviewComponent.c:35
m_bHueShiftByIndex
bool m_bHueShiftByIndex
Definition
SCR_SpherePointGeneratorPreviewComponent.c:27
DrawPreview
void DrawPreview()
Definition
SCR_SpherePointGeneratorPreviewComponent.c:50
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
BaseContainer
Definition
BaseContainer.c:13
BaseContainerList
Definition
BaseContainerList.c:13
Color
Definition
Color.c:13
GenericComponent::IsActive
proto external bool IsActive()
GenericComponent::_WB_OnInit
event void _WB_OnInit(IEntity owner, inout vector mat[4], IEntitySource src)
Called always after entity creation. It's purpose is to prepare entity for editing....
GenericComponent::_WB_OnKeyChanged
event bool _WB_OnKeyChanged(IEntity owner, BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
Any property value has been changed. You can use editor API here and do some additional edit actions ...
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
IEntity::GetWorld
proto external BaseWorld GetWorld()
IEntity::GetName
proto external string GetName()
IEntitySource
Definition
IEntitySource.c:13
Math
Definition
Math.c:13
SCR_ColorAHSV
Definition
SCR_ColorAHSV.c:2
SCR_SpherePointGenerator
Definition
SCR_SpherePointGenerator.c:2
SCR_SpherePointGeneratorPreviewComponentClass
Definition
SCR_SpherePointGeneratorPreviewComponent.c:3
SCR_StringHelper
Definition
SCR_StringHelper.c:2
SCR_StringHelper::IsEmptyOrWhiteSpace
static bool IsEmptyOrWhiteSpace(string input)
Definition
SCR_StringHelper.c:594
ScriptComponentClass
Definition
ScriptComponentClass.c:8
ScriptComponent
Definition
ScriptComponent.c:24
ScriptComponent::GetOwner
proto external GenericEntity GetOwner()
Get owner entity.
World
Definition
World.c:16
vector
Definition
vector.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
OnDelete
@ OnDelete
Definition
SndComponentCallbacks.c:16
Contains
proto bool Contains(T value)
scripts
Game
Components
Helpers
SCR_SpherePointGeneratorPreviewComponent.c
Generated by
1.17.0