11 [
Attribute(defvalue:
"10",
category:
"Virtual Area", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(
EAreaMeshShape),
desc:
"Area shape. If Ellipse it will use Radius while Rectangle uses diameter (width and length) rather like ellipse using half the diameter)")]
17 [
Attribute(
"12",
desc:
"How many segments in the ellipse (ELLIPSE Shapes only as RECTANGLE has a set resolution of 4).", uiwidget: UIWidgets.Slider,
params:
"4 60 1",
category:
"Virtual Area")]
20 [
Attribute(
desc:
"True to let the border copy terrain, creating a 'wall'.",
category:
"Virtual Area")]
23 [
Attribute(
desc:
"True to stretch the material along the whole circumference instead of mapping it on each segment.",
category:
"Virtual Area")]
26 [
Attribute(
desc:
"Material mapped on outside and inside of the mesh. Inside mapping is mirrored.", uiwidget: UIWidgets.ResourcePickerThumbnail,
params:
"emat",
category:
"Virtual Area")]
29 [
Attribute(
"false",
desc:
"When enabled, the component will be active from init",
category:
"Virtual Area")]
32 [
Attribute(
"0",
desc:
"If true always hide the zone in workbench. This setting is ignored when playing even within workbench",
category:
"Workbench")]
42 SetEventMask(
GetOwner(), EntityEvent.FRAME);
49 ClearEventMask(
GetOwner(), EntityEvent.FRAME);
105 dimensions[0] = width;
107 dimensions[2] = length;
140 if (dimensions[0] <= 0 || dimensions[1] <= 0 || dimensions[2] <= 0)
142 owner.SetObject(
null,
"");
146 array<vector> positions = {};
152 float dirStep = Math.PI2 / resolution;
155 for (
int v = 0; v < resolution; v++)
157 float dir = dirStep * v;
158 vector pos = Vector((Math.Sin(dir) * dimensions[0]) + offset[0], -dimensions[1], (Math.Cos(dir) * dimensions[2]) + offset[2]);
159 positions.Insert(pos);
165 float width = dimensions[0] * 0.5;
166 float length = dimensions[2] * 0.5;
168 array<vector> corners =
170 { -width + offset[0], -dimensions[1], -length + offset[2] },
171 { width + offset[0], -dimensions[1], -length + offset[2] },
172 { width + offset[0], -dimensions[1], length + offset[2] },
173 { -width + offset[0], -dimensions[1], length + offset[2] }
177 for (
int i = 0; i < 4; i++)
179 vector start = corners[i];
180 vector end = corners[(i + 1) % 4];
182 for (
float s = 0; s < 4; s++)
184 vector pos = vector.Lerp(start, end, s * 0.25);
185 positions.Insert(pos);
191 Print(
string.Format(
"'SCR_BaseAreaMeshComponent' does not support shape type %1 (%2)",
typename.EnumToString(
EAreaMeshShape,
m_eShape),
m_eShape), LogLevel.ERROR);
192 owner.SetObject(
null,
"");
200 owner.GetWorldTransform(transform);
201 vector angles = Math3D.MatrixToAngles(transform);
204 Math3D.AnglesToMatrix(angles, transform);
205 owner.SetWorldTransform(transform);
208 BaseWorld world = owner.GetWorld();
210 foreach (
int i, vector pos: positions)
212 worldPos = owner.CoordToParent(pos);
213 worldPos[1] = Math.Max(world.GetSurfaceY(worldPos[0], worldPos[2]), 0);
214 positions[i] = owner.CoordToLocal(worldPos);
219 MeshObject meshObject = res.GetResource().ToMeshObject();
222 owner.SetObject(meshObject,
"");
230 override void EOnFrame(IEntity owner,
float timeSlice)
232 if (vector.DistanceSq(
m_vLastPos, owner.GetOrigin()) > 0.1 || vector.DistanceSq(
m_vLastDir, owner.GetAngles()) > 0.1)
239 SetEventMask(owner, EntityEvent.INIT);
248 override void _WB_SetTransform(IEntity owner, inout vector mat[4], IEntitySource src)