1 [
EntityEditorProps(
category:
"GameScripted/Utility", description:
"Schedules a spherical region of the world for preload.", color:
"100 255 255 255", style:
"sphere" )]
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;
12 [
Attribute(
"0", UIWidgets.CheckBox,
"Positions first used camera to this preload location.")]
13 private bool m_bPositionCamera;
17 override void _WB_AfterWorldUpdate(
float timeSlice)
19 ref
auto pShape = Shape.CreateSphere(ARGB(100,0,255,0), ShapeFlags.ONCE | ShapeFlags.WIREFRAME,
GetOrigin(), m_fPreloadRadius);
21 if (m_bPositionCamera)
24 GetDesiredCameraTransform(pos, rot);
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);
36 protected void GetDesiredCameraTransform(out vector
position, out vector angles)
38 vector offset = 0.5 * m_fPreloadRadius * vector.Up;
50 auto pWorld = pGame.GetWorld();
54 if (m_bPositionCamera)
56 int cameraId = pWorld.GetCurrentCameraId();
60 GetDesiredCameraTransform(pos, rot);
61 pWorld.SetCamera(cameraId, pos, rot);
65 pWorld.SchedulePreload(
GetOrigin(), m_fPreloadRadius);