Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditorCameraDefaultsComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor", description: "")]
2 class SCR_EditorCameraDefaultsComponentClass: ScriptComponentClass
3 {
4 };
5 
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  }
35  static SCR_EditorCameraDefaultsComponent GetInstance()
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  {
49  result = SCR_EditorCameraDefaultsComponent.Cast(world.FindComponent(SCR_EditorCameraDefaultsComponent));
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 void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
92  {
93  if (!m_aPositions) return;
94 
95  GenericEntity genericOwner = GenericEntity.Cast(owner);
96  if (!genericOwner) return;
97 
98  WorldEditorAPI api = genericOwner._WB_GetEditorAPI();
99  if (!api || !api.IsEntitySelected(api.EntityToSource(owner))) return;
100 
101  float length = 200;
102  float width = 160;
103  float height = 90;
104 
105  vector transform[4];
106  foreach (SCR_CameraCoordinates coordinate: m_aPositions)
107  {
108  coordinate.GetTransform(transform);
109 
110  vector points[12];
111 
112  points[0] = transform[3];
113  points[1] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * -width;
114  points[2] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * width;
115 
116  points[3] = transform[3];
117  points[4] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * width;
118  points[5] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * width;
119 
120  points[6] = transform[3];
121  points[7] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * -width;
122  points[8] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * width;
123 
124  points[9] = transform[3];
125  points[10] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * -width;
126  points[11] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * -width;
127 
128  Shape.CreateTris(ARGBF(0.1, 1, 0, 1), ShapeFlags.ONCE | ShapeFlags.TRANSP | ShapeFlags.DOUBLESIDE, points, 4);
129  Shape.CreateSphere(ARGBF(1, 1, 0, 1), ShapeFlags.ONCE, transform[3], 1);
130  }
131  }
132 #endif
133 };
134 
137 {
138  [Attribute(desc: "Camera position in format lateral, vertical, longitudinal")]
139  protected vector m_vCameraPosition;
140 
141  [Attribute(desc: "Camera angles in format pitch, yaw, roll\n(the same as World Editor camera, you can copy the value from there)")]
142  protected vector m_vCameraAngles;
143 
144  void GetTransform(out vector transform[4])
145  {
146  vector angles = Vector(m_vCameraAngles[1], m_vCameraAngles[0], m_vCameraAngles[2]);
147  Math3D.AnglesToMatrix(angles, transform);
148  transform[3] = m_vCameraPosition;
149  }
150 };
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_EditorCameraDefaultsComponentClass
Definition: SCR_EditorCameraDefaultsComponent.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
Attribute
typedef Attribute
Post-process effect of scripted camera.
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_EditorCameraDefaultsComponent
Definition: SCR_EditorCameraDefaultsComponent.c:12
SCR_CameraCoordinates
Definition: SCR_EditorCameraDefaultsComponent.c:136
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180