1 [
ComponentEditorProps(
category:
"GameScripted/Editor", description:
"Placing obstruction. Disallow placing of the composition in define cases.", icon:
"WBData/ComponentEditorProps/componentEditor.png")]
15 [
Attribute(defvalue:
"20",
desc:
"Entity tilt greater then this value in angles will trigger a warning.")]
16 protected float m_fEntityTiltWarning;
18 [
Attribute(defvalue:
"25",
desc:
"A difference between max and min tilt of two entities in composition to trigger a warning")]
19 protected float m_fTiltDifferenceWarning;
21 protected ResourceName m_sCompositionResourceName;
24 protected bool m_bSuperiorCanBeCreated =
false;
25 protected bool m_bTraceEntityPosition;
30 protected ref array<ref Tuple3<IEntity, float, vector>> m_aCompositionEntities = {};
75 SCR_CampaignBuildingEditorComponent CampaignBuildingEditorComponent = SCR_CampaignBuildingEditorComponent.Cast(SCR_CampaignBuildingEditorComponent.GetInstance(SCR_CampaignBuildingEditorComponent));
76 if (!CampaignBuildingEditorComponent)
85 SCR_CampaignBuildingEditorComponent CampaignBuildingEditorComponent = SCR_CampaignBuildingEditorComponent.Cast(SCR_CampaignBuildingEditorComponent.GetInstance(SCR_CampaignBuildingEditorComponent));
86 if (!CampaignBuildingEditorComponent)
103 if (PreviewEntityComponent)
110 SCR_CampaignBuildingPlacingEditorComponent placingComponent = SCR_CampaignBuildingPlacingEditorComponent.Cast(FindEditorComponent(SCR_CampaignBuildingPlacingEditorComponent,
true,
true));
111 if (!placingComponent)
114 m_sCompositionResourceName = placingComponent.GetSelectedPrefab();
128 m_bSuperiorCanBeCreated = val;
150 m_CampaignBuildingComponent = SCR_CampaignBuildingEditorComponent.Cast(FindEditorComponent(SCR_CampaignBuildingEditorComponent,
true,
true));
166 outNotification =
ENotification.EDITOR_PLACING_OUT_OF_CAMPAIGN_BUILDING_ZONE;
177 m_aCompositionEntities.Clear();
178 array<IEntity> compositionEntities = {};
179 vector entityOrigin[4];
183 foreach (IEntity ent : compositionEntities)
191 if (entityCenter[1] < 0)
196 if (protectionRadius > 0)
199 ent.GetLocalTransform(entityOrigin);
204 vector entityWorldTransform[4];
205 ent.GetWorldTransform(entityWorldTransform);
206 vector transformAngles = Math3D.MatrixToAngles(entityWorldTransform);
208 m_aCompositionEntities.Insert(
new Tuple3<IEntity, float, vector>(ent, protectionRadius, transformAngles));
217 SCR_EditablePreviewComponent previewEditableEntity = SCR_EditablePreviewComponent.Cast(ent.FindComponent(SCR_EditablePreviewComponent));
218 if (!previewEditableEntity)
231 if (m_bSuperiorCanBeCreated)
256 foreach (Tuple3<IEntity, float, vector> compositionEntity : m_aCompositionEntities)
258 if (compositionEntity.param1 && !
CheckEntityPosition(compositionEntity.param1.GetOrigin(), compositionEntity.param2))
269 if (
IsCompositionTilted(compositionEntity.param1, compositionEntity.param2, compositionEntity.param3, previewStateToShow))
286 vector vectorMin, vectorMax;
287 ent.GetBounds(vectorMin, vectorMax);
295 vector transformMat[4];
296 ent.GetWorldTransform(transformMat);
298 vector transformAngles = Math3D.MatrixToAngles(transformMat);
299 vector transformAnglesToTest = transformAngles - originalTransofrmAngles;
301 if (transformAnglesToTest[1] < -m_fEntityTiltWarning || transformAnglesToTest[1] > m_fEntityTiltWarning)
307 if (transformAnglesToTest[2] < -m_fEntityTiltWarning || transformAnglesToTest[2] > m_fEntityTiltWarning)
333 m_bTraceEntityPosition =
true;
335 BaseWorld world =
GetGame().GetWorld();
342 float val = world.GetOceanBaseHeight();
365 BaseWorld world =
GetGame().GetWorld();
372 vector outBoundMin, outBoundMax;
373 m_PreviewEnt.GetPreviewBounds(outBoundMin, outBoundMax);
417 if (!ent.GetPhysics())
427 SCR_CampaignBuildingObstructionExceptionComponent obstructionException = SCR_CampaignBuildingObstructionExceptionComponent.Cast(ent.FindComponent(SCR_CampaignBuildingObstructionExceptionComponent));
428 if (!obstructionException)
432 if (obstructionException.IsWhitelistEmpty() || obstructionException.IsOnWhitelist(m_sCompositionResourceName))
434 m_bTraceEntityPosition =
false;
445 TraceParam trace =
new TraceParam();
448 trace.Flags = TraceFlags.ENTS | TraceFlags.OCEAN | TraceFlags.WORLD;
449 float traceCoef = world.TraceMove(trace,
null);
470 bool TraceCylinder(vector pos,
float radius = 0.5,
float height = 2, TraceFlags flags = TraceFlags.ENTS | TraceFlags.OCEAN, BaseWorld world =
null)
475 float heightHalf = height * 0.5;
477 TraceParam trace =
new TraceParam();
480 vector dir = {radius, heightHalf, 0};
481 trace.Start = pos + dir;
482 trace.End = pos - dir;
483 if (world.TraceMove(trace,
null) < 1)
486 dir = {-radius, heightHalf, 0};
487 trace.Start = pos + dir;
488 trace.End = pos - dir;
489 if (world.TraceMove(trace,
null) < 1)
492 dir = {0, heightHalf, radius};
493 trace.Start = pos + dir;
494 trace.End = pos - dir;
495 if (world.TraceMove(trace,
null) < 1)
498 dir = {0, heightHalf, -radius};
499 trace.Start = pos + dir;
500 trace.End = pos - dir;
501 if (world.TraceMove(trace,
null) < 1)