Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditorCameraDefaultsComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Editor", description: "")]
5
8
13{
14 [Attribute()]
15 protected ref array<ref SCR_CameraCoordinates> m_aPositions;
16
22 bool GetRandomPosition(out vector transform[4])
23 {
24 if (!m_aPositions || m_aPositions.Count() == 0) return false;
25
26 SCR_CameraCoordinates coordinates = m_aPositions[Math.RandomInt(0, m_aPositions.Count())];
27 coordinates.GetTransform(transform);
28 return true;
29 }
30
36 {
38
39 BaseGameMode gameMode = GetGame().GetGameMode();
40 if (gameMode)
41 {
42 result = SCR_EditorCameraDefaultsComponent.Cast(gameMode.FindComponent(SCR_EditorCameraDefaultsComponent));
43 if (result) return result;
44 }
45
46 GenericWorldEntity world = GetGame().GetWorldEntity();
47 if (world)
48 {
50 if (result) return result;
51 }
52
53 return null;
54 }
55
56#ifdef WORKBENCH
57 override void _WB_OnContextMenu(IEntity owner, int id)
58 {
59 GenericEntity genericOwner = GenericEntity.Cast(owner);
60 if (!genericOwner) return;
61
62 WorldEditorAPI api = genericOwner._WB_GetEditorAPI();
63 if (!api) return;
64
65 BaseWorld world = api.GetWorld();
66 if (!world) return;
67
68 api.BeginEntityAction();
69
70 IEntitySource ownerSource = api.EntityToSource(owner);
71 int index = m_aPositions.Count();
72 array<ref ContainerIdPathEntry> path = {new ContainerIdPathEntry(Type().ToString())};
73 api.CreateObjectArrayVariableMember(ownerSource, path, "m_aPositions", "SCR_CameraCoordinates", index);
74
75 vector transform[4];
76 world.GetCurrentCamera(transform);
77 vector pos = transform[3];
78 vector dir = Math3D.MatrixToAngles(transform);
79
80 path.Insert(new ContainerIdPathEntry("m_aPositions", index));
81 api.SetVariableValue(ownerSource, path, "m_vCameraPosition", string.Format("%1 %2 %3", pos[0], pos[1], pos[2]));
82 api.SetVariableValue(ownerSource, path, "m_vCameraAngles", string.Format("%1 %2 %3", dir[1], dir[0], dir[2]));
83
84 path = null;
85 api.EndEntityAction();
86 }
87 override array<ref WB_UIMenuItem> _WB_GetContextMenuItems(IEntity owner)
88 {
89 return { new WB_UIMenuItem("Add current camera coordinates", 0) };
90 }
91 override int _WB_GetAfterWorldUpdateSpecs(IEntity owner, IEntitySource src)
92 {
93 return EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE;
94 }
95 override void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
96 {
97 if (!m_aPositions) return;
98
99 GenericEntity genericOwner = GenericEntity.Cast(owner);
100 if (!genericOwner) return;
101
102 WorldEditorAPI api = genericOwner._WB_GetEditorAPI();
103 if (!api || !api.IsEntitySelected(api.EntityToSource(owner))) return;
104
105 const float length = 200; // TODO: check for good const usage
106 const float width = 160; // TODO: check for good const usage
107 const float height = 90; // TODO: check for good const usage
108
109 vector transform[4];
110 foreach (SCR_CameraCoordinates coordinate: m_aPositions)
111 {
112 coordinate.GetTransform(transform);
113
114 vector points[12];
115
116 points[0] = transform[3];
117 points[1] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * -width;
118 points[2] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * width;
119
120 points[3] = transform[3];
121 points[4] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * width;
122 points[5] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * width;
123
124 points[6] = transform[3];
125 points[7] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * -width;
126 points[8] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * width;
127
128 points[9] = transform[3];
129 points[10] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * -width;
130 points[11] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * -width;
131
132 Shape.CreateTris(ARGBF(0.1, 1, 0, 1), ShapeFlags.ONCE | ShapeFlags.TRANSP | ShapeFlags.DOUBLESIDE, points, 4);
133 Shape.CreateSphere(ARGBF(1, 1, 0, 1), ShapeFlags.ONCE, transform[3], 1);
134 }
135 }
136#endif
137};
138
141{
142 [Attribute(desc: "Camera position in format lateral, vertical, longitudinal")]
144
145 [Attribute(desc: "Camera angles in format pitch, yaw, roll\n(the same as World Editor camera, you can copy the value from there)")]
147
148 void GetTransform(out vector transform[4])
149 {
151 Math3D.AnglesToMatrix(angles, transform);
152 transform[3] = m_vCameraPosition;
153 }
154};
string path
void ContainerIdPathEntry(string propertyName, int index=-1)
Definition worldEditor.c:30
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref array< string > angles
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
int Type
enum EVehicleType IEntity
event int _WB_GetAfterWorldUpdateSpecs(IEntity owner, IEntitySource src)
Called after _WB_OnInit or also later when editor needs to know whether _WB_AfterWorldUpdate needs to...
event void _WB_OnContextMenu(IEntity owner, int id)
User has chosen any of your menu item from editor's "Component" menu which you have recently provided...
event void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
Called after updating world in Workbench. The entity must be selected. You can use editor API here an...
event array< ref WB_UIMenuItem > _WB_GetContextMenuItems(IEntity owner)
An opportunity to append items into editor's "Component" context menu. Do not call editor API here!
proto external WorldEditorAPI _WB_GetEditorAPI()
This returns world editor API, which is safe to use from editor events bellow.
Definition Math.c:13
void GetTransform(out vector transform[4])
ref array< ref SCR_CameraCoordinates > m_aPositions
static SCR_EditorCameraDefaultsComponent GetInstance()
ShapeFlags
Definition ShapeFlags.c:13
SCR_FieldOfViewSettings Attribute
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
proto native vector Vector(float x, float y, float z)
proto int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.