6 class SCR_PlaceableInventoryItemComponent : SCR_BaseInventoryItemComponent
9 protected bool m_bSnapToGround;
11 [
Attribute(
"1",
"Only works with Snap to ground")]
12 protected bool m_bAlignToNormal;
14 protected vector m_vMat[4];
15 protected bool m_bUseTransform =
false;
29 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
30 void RPC_DoPlaceItem(vector right, vector up, vector forward, vector
position)
37 itemComponent.EnablePhysics();
38 itemComponent.ActivateOwner(
true);
44 m_bUseTransform =
true;
55 Rpc(RPC_DoPlaceItem, right, up, forward,
position);
56 RPC_DoPlaceItem(right, up, forward,
position);
65 void SnapToGround(out vector normal, array<IEntity> excludeArray =
null,
float maxLength = 10, vector startOffset =
"0 0 0", vector
direction = -vector.Up)
68 vector origin = owner.GetOrigin();
71 TraceParam param =
new TraceParam();
72 param.Start = origin + startOffset;
73 param.End = origin +
direction * maxLength;
74 param.Flags = TraceFlags.WORLD | TraceFlags.ENTS;
78 excludeArray.Insert(owner);
79 param.ExcludeArray = excludeArray;
82 param.Exclude = owner;
84 param.LayerMask = EPhysicsLayerPresets.Projectile;
85 BaseWorld world = owner.GetWorld();
90 if (
float.AlmostEqual(traceDistance, 1.0))
93 normal = param.TraceNorm;
95 owner.SetOrigin(traceDistance * (param.End - param.Start) + param.Start);
104 Physics physics = entity.GetPhysics();
105 if (physics && (physics.IsDynamic() || physics.IsKinematic()))
110 if (mainEntity && mainEntity != entity)
112 physics = mainEntity.GetPhysics();
113 if (physics && physics.IsDynamic())
126 Physics physics = e.GetPhysics();
129 if (physics.GetInteractionLayer() & EPhysicsLayerDefs.Water)
145 Physics physics = owner.GetPhysics();
154 garbageSystem.Withdraw(owner);
156 Math3D.MatrixCopy(m_vMat, computedTransform);
157 m_bUseTransform =
false;
163 caller.GetTransform(computedTransform);
164 vector normal = vector.Up;
166 computedTransform[3] = owner.GetOrigin();
168 if (m_bAlignToNormal)