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_MapLocator.c
Go to the documentation of this file.
1
class
SCR_MapLocatorClass
: GenericEntityClass
2
{
3
};
4
5
class
SCR_MapLocator
:
GenericEntity
6
{
7
[
Attribute
(
"{2229B9CC8917D3A3}UI/layouts/Map/MapLocationHint.layout"
,
params
:
"et class=layout"
)]
8
protected
ResourceName
m_sUIHintLayout
;
9
protected
Widget
m_wUIHintLayout
;
10
11
[
Attribute
(
"MapLocationHint_Text"
)]
12
protected
string
m_sMapLocationHintWidgetName1
;
13
[
Attribute
(
"MapLocationHint_Text2"
)]
14
protected
string
m_sMapLocationHintWidgetName2
;
15
16
protected
TextWidget
m_wUIHintText
;
17
protected
TextWidget
m_wUIHintText2
;
18
19
[
Attribute
()]
20
protected
ref
SCR_MapLocationQuadHint
m_WorldDirections
;
21
22
protected
int
m_iGridSizeX
;
23
protected
int
m_iGridSizeY
;
24
25
protected
const
float
angleA
= 0.775;
26
protected
const
float
angleB
= 0.325;
27
28
//------------------------------------------------------------------------------------------------
29
override
void
EOnInit
(
IEntity
owner)
30
{
31
if
(!
GetGame
().InPlayMode() || !
m_WorldDirections
)
32
return
;
33
SCR_MapEntity
.
GetOnMapOpen
().Insert(
ShowMapHint
);
34
SCR_MapEntity
.
GetOnMapClose
().Insert(
HideMapHint
);
35
36
vector
mins,maxs;
37
GetGame
().GetWorldEntity().GetWorldBounds(mins, maxs);
38
39
m_iGridSizeX
= maxs[0]/3;
40
m_iGridSizeY
= maxs[2]/3;
41
}
42
43
protected
void
ShowMapHint
(
MapConfiguration
config)
44
{
45
//--- ToDo: Don't hardcode conditions, let the map config define whether to show location hint or not
46
if
(SCR_DeployMenuMain.GetDeployMenu())
47
return
;
48
m_wUIHintLayout
=
GetGame
().GetWorkspace().CreateWidgets(
m_sUIHintLayout
);
49
if
(!
m_wUIHintLayout
)
50
return
;
51
m_wUIHintText
=
TextWidget
.Cast(
m_wUIHintLayout
.FindAnyWidget(
m_sMapLocationHintWidgetName1
));
52
m_wUIHintText2
=
TextWidget
.Cast(
m_wUIHintLayout
.FindAnyWidget(
m_sMapLocationHintWidgetName2
));
53
CalculateClosestLocation
();
54
GetGame
().GetCallqueue().CallLater(
CalculateClosestLocation
,10000,
true
);
55
}
56
57
protected
void
HideMapHint
(
MapConfiguration
config)
58
{
59
if
(
m_wUIHintLayout
)
60
m_wUIHintLayout
.RemoveFromHierarchy();
61
m_wUIHintLayout
= null;
62
m_wUIHintText
= null;
63
m_wUIHintText2
= null;
64
GetGame
().GetCallqueue().Remove(
CalculateClosestLocation
);
65
}
66
67
protected
void
CalculateClosestLocation
()
68
{
69
SCR_EditableEntityCore
core =
SCR_EditableEntityCore
.Cast(
SCR_EditableEntityCore
.GetInstance(
SCR_EditableEntityCore
));
70
if
(!core)
71
return
;
72
ChimeraCharacter
player =
ChimeraCharacter
.Cast(
SCR_PlayerController
.
GetLocalControlledEntity
());
73
if
(!player)
74
{
75
if
(
m_wUIHintLayout
)
76
{
77
m_wUIHintLayout
.RemoveFromHierarchy();
78
m_wUIHintLayout
= null;
79
}
80
return
;
81
}
82
vector
posPlayer = player.GetOrigin();
83
84
SCR_EditableEntityComponent
nearest = core.
FindNearestEntity
(posPlayer,
EEditableEntityType
.COMMENT,
EEditableEntityFlag
.LOCAL);
85
if
(!nearest)
86
return
;
87
GenericEntity
nearestLocation = nearest.GetOwner();
88
SCR_MapDescriptorComponent mapDescr = SCR_MapDescriptorComponent.Cast(nearestLocation.
FindComponent
(SCR_MapDescriptorComponent));
89
string
closestLocationName;
90
if
(!mapDescr)
91
return
;
92
MapItem
item = mapDescr.Item();
93
closestLocationName = item.GetDisplayName();
94
95
vector
lastLocationPos = nearestLocation.
GetOrigin
();
96
float
lastDistance =
vector
.DistanceSqXZ(lastLocationPos, posPlayer);
97
98
LocalizedString
closeLocationAzimuth;
99
vector
result = posPlayer - lastLocationPos;
100
result.Normalize();
101
102
float
angle1 =
vector
.DotXZ(result,
vector
.Forward);
103
float
angle2 =
vector
.DotXZ(result,
vector
.Right);
104
105
if
(angle2 > 0)
106
{
107
if
(angle1 >=
angleA
)
108
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionNorth"
;
109
if
(angle1 < angleA && angle1 >=
angleB
)
110
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionNorthEast"
;
111
if
(angle1 < angleB && angle1 >=-
angleB
)
112
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionEast"
;
113
if
(angle1 < -angleB && angle1 >=-
angleA
)
114
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionSouthEast"
;
115
if
(angle1 < -
angleA
)
116
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionSouth"
;
117
}
118
else
119
{
120
if
(angle1 >=
angleA
)
121
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionNorth"
;
122
if
(angle1 < angleA && angle1 >=
angleB
)
123
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionNorthWest"
;
124
if
(angle1 < angleB && angle1 >=-
angleB
)
125
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionWest"
;
126
if
(angle1 < -angleB && angle1 >=-
angleA
)
127
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionSouthWest"
;
128
if
(angle1 < -
angleA
)
129
closeLocationAzimuth =
"#AR-MapLocationHint_DirectionSouth"
;
130
};
131
132
int
playerGridPositionX = posPlayer[0]/
m_iGridSizeX
;
133
int
playerGridPositionY = posPlayer[2]/
m_iGridSizeY
;
134
135
int
playerGridID =
GetGridIndex
(playerGridPositionX,playerGridPositionY);
136
m_wUIHintText
.SetTextFormat(
m_WorldDirections
.GetPlayerPositionHint(),
m_WorldDirections
.GetQuadHint(playerGridID));
137
if
(lastDistance < 40000)
138
m_wUIHintText2
.SetTextFormat(
"#AR-MapLocationHint_PlayerPositionNear"
, closestLocationName);
139
else
140
{
141
m_wUIHintText2
.SetVisible(!closestLocationName.IsEmpty());
142
m_wUIHintText2
.SetTextFormat(closeLocationAzimuth, closestLocationName);
143
}
144
}
145
146
protected
int
GetGridIndex
(
int
x,
int
y)
147
{
148
return
3*y + x;
149
}
150
151
//------------------------------------------------------------------------------------------------
152
void
SCR_MapLocator
(
IEntitySource
src,
IEntity
parent)
153
{
154
SetEventMask
(
EntityEvent
.INIT);
155
}
156
};
157
158
//------------------------------------------------------------------------------------------------
159
[
BaseContainerProps
(configRoot:
true
)]
160
class
SCR_MapLocationQuadHint
161
{
162
[
Attribute
(
"#AR-MapLocationHint_PlayerPositionIslandName"
)]
163
protected
LocalizedString
m_sPlayerPositionHint
;
164
165
[
Attribute
(
desc
:
"Description of given quad. Order: SW, S, SE, W, C, E, NW, N, NE"
,
params
:
"MaxSize=9"
)]
166
protected
ref array<LocalizedString>
m_aQuadHints
;
167
168
//------------------------------------------------------------------------------------------------
169
LocalizedString
GetPlayerPositionHint
()
170
{
171
return
m_sPlayerPositionHint
;
172
}
173
174
LocalizedString
GetQuadHint
(
int
index
)
175
{
176
if
(!
m_aQuadHints
.IsIndexValid(
index
))
177
return
LocalizedString
.Empty;
178
179
return
m_aQuadHints
[
index
];
180
}
181
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
ChimeraCharacter
Definition
ChimeraCharacter.c:13
GenericEntity
Definition
GenericEntity.c:16
IEntity::IEntity
void IEntity(IEntitySource src, IEntity parent)
protected script Constructor
IEntity::SetEventMask
proto external EntityEvent SetEventMask(EntityEvent e)
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetOrigin
proto external vector GetOrigin()
IEntitySource
Definition
IEntitySource.c:13
LocalizedString
Definition
LocalizedString.c:22
MapConfiguration
Definition
MapConfiguration.c:3
MapItem
Definition
MapItem.c:13
ResourceName
Definition
ResourceName.c:13
SCR_EditableEntityComponent
Definition
SCR_EditableEntityComponent.c:14
SCR_EditableEntityCore
Definition
SCR_EditableEntityCore.c:20
SCR_EditableEntityCore::FindNearestEntity
SCR_EditableEntityComponent FindNearestEntity(vector pos, EEditableEntityType type, EEditableEntityFlag flags=0, bool onlyDirect=true)
Definition
SCR_EditableEntityCore.c:350
SCR_MapEntity
Definition
SCR_MapEntity.c:18
SCR_MapEntity::GetOnMapClose
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
Definition
SCR_MapEntity.c:92
SCR_MapEntity::GetOnMapOpen
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapOpen()
Get on map open invoker.
Definition
SCR_MapEntity.c:88
SCR_MapLocationQuadHint
Definition
SCR_MapLocator.c:161
SCR_MapLocationQuadHint::GetPlayerPositionHint
LocalizedString GetPlayerPositionHint()
Definition
SCR_MapLocator.c:169
SCR_MapLocationQuadHint::GetQuadHint
LocalizedString GetQuadHint(int index)
Definition
SCR_MapLocator.c:174
SCR_MapLocationQuadHint::m_sPlayerPositionHint
LocalizedString m_sPlayerPositionHint
Definition
SCR_MapLocator.c:163
SCR_MapLocationQuadHint::m_aQuadHints
ref array< LocalizedString > m_aQuadHints
Definition
SCR_MapLocator.c:166
SCR_MapLocatorClass
Definition
SCR_MapLocator.c:2
SCR_MapLocator::m_wUIHintLayout
Widget m_wUIHintLayout
Definition
SCR_MapLocator.c:9
SCR_MapLocator::angleA
const float angleA
Definition
SCR_MapLocator.c:25
SCR_MapLocator::m_sMapLocationHintWidgetName2
string m_sMapLocationHintWidgetName2
Definition
SCR_MapLocator.c:14
SCR_MapLocator::EOnInit
override void EOnInit(IEntity owner)
Definition
SCR_MapLocator.c:29
SCR_MapLocator::m_iGridSizeX
int m_iGridSizeX
Definition
SCR_MapLocator.c:22
SCR_MapLocator::m_wUIHintText2
TextWidget m_wUIHintText2
Definition
SCR_MapLocator.c:17
SCR_MapLocator::SCR_MapLocator
void SCR_MapLocator(IEntitySource src, IEntity parent)
Definition
SCR_MapLocator.c:152
SCR_MapLocator::GetGridIndex
int GetGridIndex(int x, int y)
Definition
SCR_MapLocator.c:146
SCR_MapLocator::m_iGridSizeY
int m_iGridSizeY
Definition
SCR_MapLocator.c:23
SCR_MapLocator::m_WorldDirections
ref SCR_MapLocationQuadHint m_WorldDirections
Definition
SCR_MapLocator.c:20
SCR_MapLocator::m_sMapLocationHintWidgetName1
string m_sMapLocationHintWidgetName1
Definition
SCR_MapLocator.c:12
SCR_MapLocator::angleB
const float angleB
Definition
SCR_MapLocator.c:26
SCR_MapLocator::HideMapHint
void HideMapHint(MapConfiguration config)
Definition
SCR_MapLocator.c:57
SCR_MapLocator::ShowMapHint
void ShowMapHint(MapConfiguration config)
Definition
SCR_MapLocator.c:43
SCR_MapLocator::m_sUIHintLayout
ResourceName m_sUIHintLayout
Definition
SCR_MapLocator.c:8
SCR_MapLocator::m_wUIHintText
TextWidget m_wUIHintText
Definition
SCR_MapLocator.c:16
SCR_MapLocator::CalculateClosestLocation
void CalculateClosestLocation()
Definition
SCR_MapLocator.c:67
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalControlledEntity
static IEntity GetLocalControlledEntity()
Definition
SCR_PlayerController.c:495
TextWidget
Definition
TextWidget.c:16
Widget
Definition
Widget.c:13
vector
Definition
vector.c:13
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition
EEditableEntityType.c:6
EEditableEntityFlag
EEditableEntityFlag
Unique flags of the entity.
Definition
EEditableEntityFlag.c:6
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EntityEvent
EntityEvent
Various entity events.
Definition
EntityEvent.c:14
scripts
Game
Entities
SCR_MapLocator.c
Generated by
1.17.0