Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ShedulePreloadEntity.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Utility", description: "Schedules a spherical region of the world for preload.", color: "100 255 255 255", style: "sphere" )]
2 class SCR_ShedulePreloadEntityClass: GenericEntityClass
3 {
4 };
5 
6 //------------------------------------------------------------------------------------------------
8 {
9  [Attribute("500", UIWidgets.Slider, "The radius in metres from the center of this entity which should be scheduled to preload.", "0 1500 1")]
10  private float m_fPreloadRadius;
11 
12  [Attribute("0", UIWidgets.CheckBox, "Positions first used camera to this preload location.")]
13  private bool m_bPositionCamera;
14 
15 
16  #ifdef WORKBENCH
17  override void _WB_AfterWorldUpdate(float timeSlice)
18  {
19  ref auto pShape = Shape.CreateSphere(ARGB(100,0,255,0), ShapeFlags.ONCE | ShapeFlags.WIREFRAME, GetOrigin(), m_fPreloadRadius);
20 
21  if (m_bPositionCamera)
22  {
23  vector pos, rot;
24  GetDesiredCameraTransform(pos, rot);
25 
26  auto dir = rot.AnglesToVector();
27  auto color = ARGB(100,0,255,64);
28  auto flags = ShapeFlags.ONCE | ShapeFlags.WIREFRAME;
29  ref auto pCamShape = Shape.CreateSphere(color, flags, pos, 0.01);
30  ref auto pCamArrow = Shape.CreateArrow(pos, pos + dir, 0.01, color, flags);
31  }
32  }
33  #endif
34 
35  //------------------------------------------------------------------------------------------------
36  protected void GetDesiredCameraTransform(out vector position, out vector angles)
37  {
38  vector offset = 0.5 * m_fPreloadRadius * vector.Up;
39  position = GetOrigin() + offset;
40  angles = "0 -90 0";
41  }
42 
43  //------------------------------------------------------------------------------------------------
44  void SCR_ShedulePreloadEntity(IEntitySource src, IEntity parent)
45  {
46  auto pGame = GetGame();
47  if (!pGame)
48  return;
49 
50  auto pWorld = pGame.GetWorld();
51  if (!pWorld)
52  return;
53 
54  if (m_bPositionCamera)
55  {
56  int cameraId = pWorld.GetCurrentCameraId();
57  if (cameraId >= 0)
58  {
59  vector pos, rot;
60  GetDesiredCameraTransform(pos, rot);
61  pWorld.SetCamera(cameraId, pos, rot);
62  }
63  }
64 
65  pWorld.SchedulePreload(GetOrigin(), m_fPreloadRadius);
66  }
67 
68 };
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
GetOrigin
vector GetOrigin()
Definition: SCR_AIUtilityComponent.c:279
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ShedulePreloadEntity
Definition: SCR_ShedulePreloadEntity.c:7
SCR_ShedulePreloadEntityClass
Definition: SCR_ShedulePreloadEntity.c:2
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180