10 Managed foundComponent;
15 foundComponent = entity.FindComponent(componentType);
17 return foundComponent;
23 SlotManagerComponent slotManager = SlotManagerComponent.Cast(entity.FindComponent(SlotManagerComponent));
26 array<EntitySlotInfo> slotInfos = {};
27 slotManager.GetSlotInfos(slotInfos);
32 slotEntity = slotInfo.GetAttachedEntity();
38 return foundComponent;
52 return foundComponent;
69 return foundComponent;
83 return foundComponent;
98 return foundComponent;
112 return foundComponent;
138 return foundComponent;
155 static int GetChildrenCount(
IEntity parent,
bool recursive =
false)
166 num += GetChildrenCount(child);
177 static void DeleteEntityAndChildren(
IEntity entity)
179 RplComponent.DeleteRplEntity(entity,
false);
185 static void DeleteBuilding(
IEntity entity)
195 if (destructibleComp)
200 RplComponent.DeleteRplEntity(entity,
false);
210 entity.GetBounds(entMins, entMaxs);
212 return entMaxs - entMins;
222 entity.GetBounds(entMins, entMaxs);
223 return entity.CoordToParent((entMaxs + entMins) * 0.5);
229 static float GetEntityRadius(notnull
IEntity entity)
231 return GetEntitySize(entity).Length() * 0.5;
238 static void GetHierarchyEntityList(notnull
IEntity entity, notnull inout array<IEntity> output)
243 GetHierarchyEntityList(child, output);
244 output.Insert(child);
257 static void SnapToGround(notnull
IEntity entity, array<IEntity> excludeArray = null,
float maxLength = 10,
vector startOffset =
"0 0 0",
bool onlyStatic =
false)
259 vector origin = entity.GetOrigin();
263 param.Start = origin + startOffset;
264 param.End = origin -
vector.Up * maxLength;
269 excludeArray.Insert(entity);
270 param.ExcludeArray = excludeArray;
274 param.Exclude = entity;
284 traceDistance = world.TraceMove(param, null);
286 if (
float.AlmostEqual(traceDistance, 1.0))
289 entity.SetOrigin(traceDistance * (param.End - param.Start) + param.Start);
295 static void OrientUpToVector(
vector newUp, inout
vector mat[4])
298 vector perpend = newUp.Perpend();
299 Math3D.DirectionAndUpMatrix(perpend, newUp, mat);
302 Math3D.AnglesToMatrix({ -perpend.VectorToAngles()[0], 0, 0 }, basis);
303 Math3D.MatrixMultiply3(mat, basis, mat);
313 Physics physics = entity.GetPhysics();
314 if (physics && physics.IsDynamic())
331 if (parent != entity)
348 entity.GetTransform(oldTransform);
349 entity.SetTransform(newTransform);
368 Physics entPhys = entity.GetPhysics();
371 if (entPhys.IsDynamic())
374 entity.GetTransform(mat);
377 Math3D.MatrixInvMultiply4(oldTransform, mat, diffMat);
378 Math3D.MatrixMultiply4(newTransform, diffMat, mat);
380 entity.SetTransform(mat);
401 if (!owner || !member)
409 owner.GetWorldTransform(ownerTransform);
411 vector memberTransform[4];
412 member.GetWorldTransform(memberTransform);
414 Math3D.MatrixInvMultiply4(ownerTransform, memberTransform, relativeTransform);
419 Math3D.MatrixIdentity4(relativeTransform);
426 if (parent == member)
427 return EntityUtils.GetAncestorToChildTransform(owner, member, relativeTransform);
433 vector ownerToRootTransform[4];
434 Math3D.MatrixIdentity4(ownerToRootTransform);
435 bool ownerToRoot =
EntityUtils.GetAncestorToChildTransform(owner, root, ownerToRootTransform);
438 vector rootToMemberTransform[4];
439 Math3D.MatrixIdentity4(rootToMemberTransform);
440 bool rootToMember =
EntityUtils.GetChildToAncestorTransform(member, root, rootToMemberTransform);
443 Math3D.MatrixMultiply4(ownerToRootTransform, rootToMemberTransform, relativeTransform);
445 return ownerToRoot && rootToMember;
453 RplComponent rplComp;
454 BaseGameEntity gameEntity = BaseGameEntity.Cast(entity);
456 rplComp = gameEntity.GetRplComponent();
459 rplComp = RplComponent.Cast(entity.FindComponent(RplComponent));
488 protected static int Partition(notnull inout array<IEntity> arr,
vector pos,
int low,
int high)
493 for (
int j = low; j <= high - 1; j++)
495 if (
vector.DistanceSq(arr[j].GetOrigin(), pos) <= pivot)
502 arr.SwapItems(i + 1, high);
517 return RplId.Invalid();
523 RplComponent rplComp = RplComponent.Cast(
Replication.FindItem(
id));
527 return rplComp.GetEntity();
531class SCR_EntityHelperT<
Class T>
539 IEntity child = parent.GetChildren();
543 return T.Cast(child);