6class SCR_LineTerrainShaperGeneratorBaseEntity : SCR_LineGeneratorBaseEntity
12 [
Attribute(defvalue:
"0",
desc:
"Adjust terrain's Y around the track to fit the spline's location and clearance",
category:
"Terrain Sculpting")]
13 protected bool m_bSculptTerrain;
16 protected int m_iTerrainSculptingPriority;
18 [
Attribute(defvalue:
"10", uiwidget:
UIWidgets.EditBox,
desc:
"Width of the path before fall-off, the flat surface around the shape",
category:
"Terrain Sculpting",
params:
"0 100 0.1")]
19 protected float m_fTerrainSculptingPathWidth;
22 protected float m_fTerrainSculptingFallOffWidth;
28 protected ShapeEntity m_ShapeEntity;
30 protected static const ref array<string> TERRAIN_UPDATE_KEYS = {
31 "m_bSculptTerrain",
"m_iTerrainSculptingPriority",
32 "m_fTerrainSculptingPathWidth",
"m_fTerrainSculptingFallOffWidth",
34 protected static const string OFFSET_SHAPE_COLOUR =
"1 0 1 1";
37 protected override void OnShapeInitInternal(IEntitySource shapeEntitySrc, ShapeEntity shapeEntity)
39 super.OnShapeInitInternal(shapeEntitySrc, shapeEntity);
41 UpdateTerrainSimple();
45 protected override void OnShapeTransformInternal(IEntitySource shapeEntitySrc, ShapeEntity shapeEntity, array<vector> mins, array<vector> maxes)
47 super.OnShapeTransformInternal(shapeEntitySrc, shapeEntity, mins, maxes);
49 UpdateTerrainSimple(
false);
53 protected override void OnShapeChangedInternal(IEntitySource shapeEntitySrc, ShapeEntity shapeEntity, array<vector> mins, array<vector> maxes)
55 super.OnShapeChangedInternal(shapeEntitySrc, shapeEntity, mins, maxes);
57 UpdateTerrainSimple(
false);
61 override void _WB_OnInit(inout vector mat[4], IEntitySource src)
63 super._WB_OnInit(mat, src);
65 UpdateTerrainSimple();
69 override bool _WB_OnKeyChanged(BaseContainer src,
string key, BaseContainerList ownerContainers,
IEntity parent)
71 if (!super._WB_OnKeyChanged(src, key, ownerContainers, parent))
74 WorldEditorAPI worldEditorAPI = _WB_GetEditorAPI();
75 if (!worldEditorAPI || worldEditorAPI.UndoOrRedoIsRestoring())
78 if (!worldEditorAPI.AreGeneratorEventsEnabled())
81 BaseContainerTools.WriteToInstance(
this, src);
83 if (TERRAIN_UPDATE_KEYS.Contains(key))
86 if (key ==
"m_bSculptTerrain")
94 worldEditorAPI.RemoveTerrainFlatterEntity(
this,
true);
110 UpdateTerrainSimple(forceUpdate);
117 override void _WB_OnCreate(IEntitySource src)
119 super._WB_OnCreate(src);
121 UpdateTerrainSimple();
125 override void _WB_OnParentChange(IEntitySource src, IEntitySource prevParentSrc)
127 super._WB_OnParentChange(src, prevParentSrc);
129 WorldEditorAPI worldEditorAPI = _WB_GetEditorAPI();
133 if (m_ParentShapeSource)
134 UpdateTerrainSimple(
true);
136 worldEditorAPI.RemoveTerrainFlatterEntity(
this,
true);
140 override void _WB_OnDelete(IEntitySource src)
142 super._WB_OnDelete(src);
144 WorldEditorAPI worldEditorAPI = _WB_GetEditorAPI();
148 worldEditorAPI.RemoveTerrainFlatterEntity(
this,
true);
154 protected void UpdateTerrainSimple(
bool forceUpdate =
false)
156 if (!m_bSculptTerrain || !m_ParentShapeSource)
159 WorldEditorAPI worldEditorAPI = _WB_GetEditorAPI();
188 ShapeEntity shapeEntity = ShapeEntity.Cast(worldEditorAPI.SourceToEntity(m_ParentShapeSource));
191 array<vector> updateMins = {};
192 array<vector> updateMaxes = {};
194 shapeEntity.GetAllInfluenceBBoxes(m_ParentShapeSource, updateMins, updateMaxes);
196 UpdateTerrain(shapeEntity, forceUpdate, updateMins, updateMaxes);
208 protected void UpdateTerrain(notnull ShapeEntity shapeEntity,
bool forceUpdate, notnull array<vector> updateMins, notnull array<vector> updateMaxes)
210 m_ShapeEntity = shapeEntity;
212 if (!m_bSculptTerrain)
215 WorldEditorAPI worldEditorAPI = _WB_GetEditorAPI();
219 array<vector> points = {};
220 shapeEntity.GenerateTesselatedShape(points);
222 if (points.Count() < 2)
224 Print(
"Terrain Flattener requires a shape with at least two points",
LogLevel.WARNING);
228 vector firstPoint = shapeEntity.CoordToParent(points[0]);
229 vector mins = firstPoint;
230 vector maxs = firstPoint;
232 foreach (vector point : points)
234 vector pos = shapeEntity.CoordToParent(point);
235 for (
int i = 0; i < 3; ++i)
247 worldEditorAPI.AddTerrainFlatterEntity(
this, mins, maxs, m_iTerrainSculptingPriority, m_fTerrainSculptingPathWidth * 0.5, m_fTerrainSculptingFallOffWidth, forceUpdate, updateMins, updateMaxes);
252 protected void SCR_LineTerrainShaperGeneratorBaseEntity(IEntitySource src,
IEntity parent)
254 if (!_WB_GetEditorAPI())
257 m_ShapeEntity = ShapeEntity.Cast(parent);
override void _WB_OnInit(IEntity owner, inout vector mat[4], IEntitySource src)
override bool _WB_OnKeyChanged(IEntity owner, BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
Any property value has been changed. You can use editor API here and do some additional edit actions ...
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
enum EVehicleType IEntity
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
void OnShapeTransformInternal(IEntitySource shapeEntitySrc, ShapeEntity shapeEntity, array< vector > mins, array< vector > maxes)
void OnShapeInitInternal(IEntitySource shapeEntitySrc, ShapeEntity shapeEntity)
void OnShapeChangedInternal(IEntitySource shapeEntitySrc, ShapeEntity shapeEntity, array< vector > mins, array< vector > maxes)