9 private bool AdjustHeightMap;
12 private int AdjustHeightMapPriority;
15 private float FalloffStartWidth;
18 private float FalloffWidth;
32 api.RemoveTerrainFlatterEntity(
this);
43 ref array<vector> m_Bones =
new array<vector>;
48 auto boneNames =
new array<string>;
50 anim.GetBoneNames(boneNames);
51 foreach(
string bone: boneNames)
53 int idx = anim.GetBoneIndex(bone);
54 anim.GetBoneMatrix(
idx, mat);
55 m_Bones.Insert(mat[3]);
72 api.AddTerrainFlatterEntity(
this, mins, maxs, AdjustHeightMapPriority, FalloffStartWidth, FalloffWidth);
76 api.RemoveTerrainFlatterEntity(
this);
80 override bool _WB_CanAnchorSnap(IEntitySource thisSrc,
int thisAnchor, IEntitySource otherSrc,
int otherAnchor,
bool isReceiver)
82 if (isReceiver && otherSrc.GetClassName() ==
"SplineShapeEntity")
84 BaseContainerList points = otherSrc.GetObjectArray(
"Points");
85 if (otherAnchor == 0 || otherAnchor == points.Count() - 1)
92 vector GetTangent(ShapeEntity shape,
int pIdx)
94 array<vector> points =
new array<vector>();
95 shape.GetPointsPositions(points);
97 int nPoints = points.Count();
104 vector res = (points[1] - points[0]);
109 if (pIdx >= nPoints - 1)
111 vector res = (points[nPoints - 1] - points[nPoints - 2]);
119 override void _WB_OnAnchorSnapped(IEntitySource thisSrc,
int thisAnchor, IEntitySource otherSrc,
int otherAnchor,
bool isReceiver)
121 if (isReceiver && otherSrc.GetClassName() ==
"SplineShapeEntity")
123 BaseContainerList points = otherSrc.GetObjectArray(
"Points");
125 ShapeEntity shape = ShapeEntity.Cast(api.SourceToEntity(otherSrc));
126 int boneIdx = thisAnchor + 1;
129 if (points && points.Count() > otherAnchor && shape)
136 vector crossroadTangent = (m_Bones[boneIdx] - m_Bones[0]).Normalized().Multiply3(mat);
139 shape.GetWorldTransform(mat);
140 vector splineTangent = GetTangent(shape, otherAnchor).Multiply3(mat);
142 float len = Math.Max(0.2, 1.0 - Math.AbsFloat(vector.Dot(-splineTangent, crossroadTangent)));
143 vector finalSplineTangent = crossroadTangent.InvMultiply3(mat) * len * 300;
145 api.BeginEntityAction(
"Snap to crossroad");
147 BaseContainer point = points[otherAnchor];
148 BaseContainerList pointData = point.GetObjectArray(
"Data");
149 if (pointData.Count() == 0)
151 api.CreateObjectArrayVariableMember(point, null,
"Data",
"SplinePointData", 0);
155 if (otherAnchor == 0)
157 api.SetVariableValue(otherSrc, containerPath,
"OutTangent", finalSplineTangent.ToString(
false));
161 api.SetVariableValue(otherSrc, containerPath,
"InTangent", (-finalSplineTangent).
ToString(
false));
166 api.EndEntityAction();
171 override bool _WB_OnKeyChanged(BaseContainer src,
string key, BaseContainerList ownerContainers,
IEntity parent)
179 int cnt = m_Bones.Count();
181 return m_Bones.Count() - 1;
void ContainerIdPathEntry(string propertyName, int index=-1)
void CrossroadEntity(IEntitySource src, IEntity parent)
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
enum EVehicleType IEntity
event int _WB_GetAnchorCount(IEntitySource src)
Returns how many anchor points does this entity have at this time.
event bool _WB_CanAnchorSnap(IEntitySource thisSrc, int thisAnchor, IEntitySource otherSrc, int otherAnchor, bool isReceiver)
proto external WorldEditorAPI _WB_GetEditorAPI()
This returns world editor API, which is safe to use from editor events bellow.
event bool _WB_OnKeyChanged(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 ...
event void _WB_GetAnchor(inout vector position, IEntitySource src, int index)
Fills position of anchor at index index to anchorPosition.
event void _WB_OnAnchorSnapped(IEntitySource thisSrc, int thisAnchor, IEntitySource otherSrc, int otherAnchor, bool isReceiver)
proto external EntityEvent SetEventMask(EntityEvent e)
void EOnInit(IEntity owner)
proto external void GetWorldTransform(out vector mat[])
See IEntity::GetTransform.
proto external Animation GetAnimation()
proto external void GetWorldBounds(out vector mins, out vector maxs)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.