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;
24 protected bool m_bSuperiorCanBeCreated =
false;
25 protected bool m_bTraceEntityPosition;
30 protected ref array<ref Tuple3<IEntity, float, vector>> m_aCompositionEntities = {};
76 SCR_CampaignBuildingEditorComponent CampaignBuildingEditorComponent = SCR_CampaignBuildingEditorComponent.Cast(SCR_CampaignBuildingEditorComponent.GetInstance(SCR_CampaignBuildingEditorComponent));
77 if (!CampaignBuildingEditorComponent)
86 SCR_CampaignBuildingEditorComponent CampaignBuildingEditorComponent = SCR_CampaignBuildingEditorComponent.Cast(SCR_CampaignBuildingEditorComponent.GetInstance(SCR_CampaignBuildingEditorComponent));
87 if (!CampaignBuildingEditorComponent)
104 if (PreviewEntityComponent)
111 SCR_CampaignBuildingPlacingEditorComponent placingComponent = SCR_CampaignBuildingPlacingEditorComponent.Cast(
FindEditorComponent(SCR_CampaignBuildingPlacingEditorComponent,
true,
true));
112 if (!placingComponent)
115 m_sCompositionResourceName = placingComponent.GetSelectedPrefab();
129 m_bSuperiorCanBeCreated = val;
149 private void InitVariables()
160 bool IsPreviewOutOfRange(SCR_EditorPreviewParams instantPlacingParam, out
ENotification outNotification = -1)
163 if (instantPlacingParam)
165 vector outTransform[4];
170 outNotification =
ENotification.EDITOR_PLACING_OUT_OF_CAMPAIGN_BUILDING_ZONE;
180 outNotification =
ENotification.EDITOR_PLACING_OUT_OF_CAMPAIGN_BUILDING_ZONE;
191 m_aCompositionEntities.Clear();
192 array<IEntity> compositionEntities = {};
196 float protectionRadius;
202 foreach (
IEntity ent : compositionEntities)
211 float surfaceY = world.GetSurfaceY(entityCenter[0], entityCenter[2]);
214 if ((entityCenter[1] < 0) || entityCenter[1] < (surfaceY -
Y_BUFFER))
216 SCR_CampaignBuildingPlacingEditorComponent placingComponent = SCR_CampaignBuildingPlacingEditorComponent.Cast(
FindEditorComponent(SCR_CampaignBuildingPlacingEditorComponent,
true,
true));
217 if (!placingComponent)
220 ResourceName resName = placingComponent.GetSelectedPrefab();
221 if (resName.IsEmpty())
223 SCR_CampaignBuildingTransformingEditorComponent transformingComponent = SCR_CampaignBuildingTransformingEditorComponent.Cast(
FindEditorComponent(SCR_CampaignBuildingTransformingEditorComponent,
true,
true));
224 if (!transformingComponent)
231 IEntity pivotEnt = editablePivot.GetOwner();
238 if (resName.IsEmpty())
248 if (protectionRadius > 0)
251 ent.GetLocalTransform(entityOrigin);
256 vector entityLocalTransform[4];
257 ent.GetLocalTransform(entityLocalTransform);
258 vector transformAngles =
Math3D.MatrixToAngles(entityLocalTransform);
270 if (!entityPrefab.IsValid())
279 if (!entityComponentSource)
289 SCR_EditablePreviewComponent previewEditableEntity = SCR_EditablePreviewComponent.Cast(ent.
FindComponent(SCR_EditablePreviewComponent));
290 if (!previewEditableEntity)
303 if (m_bSuperiorCanBeCreated)
330 if (!compositionEntity.param1)
345 IsCompositionTilted(compositionEntity.param1, compositionEntity.param2, compositionEntity.param3, previewStateToShow);
358 vector vectorMin, vectorMax;
359 ent.GetBounds(vectorMin, vectorMax);
368 ent.GetWorldTransform(transformMat);
370 vector transformAngles =
Math3D.MatrixToAngles(transformMat);
371 vector transformAnglesToTest = originalTransformAngles - transformAngles;
373 if (transformAnglesToTest[1] < -m_fEntityTiltWarning || transformAnglesToTest[1] > m_fEntityTiltWarning)
379 if (transformAnglesToTest[2] < -m_fEntityTiltWarning || transformAnglesToTest[2] > m_fEntityTiltWarning)
405 m_bTraceEntityPosition =
true;
418 float val = world.GetOceanBaseHeight();
448 vector outBoundMin, outBoundMax;
449 m_PreviewEnt.GetPreviewBounds(outBoundMin, outBoundMax);
455 Math3D.MatrixIdentity3(paramOBB.Mat);
456 paramOBB.Mat[0] = transform[0];
457 paramOBB.Mat[1] = transform[1];
458 paramOBB.Mat[2] = transform[2];
459 paramOBB.Start = transform[3] + 0.05 * paramOBB.Mat[1];
461 paramOBB.Mins = outBoundMin;
462 paramOBB.Maxs = outBoundMax;
465 float val = world.GetOceanBaseHeight();
508 SCR_CampaignBuildingObstructionExceptionComponent obstructionException = SCR_CampaignBuildingObstructionExceptionComponent.Cast(ent.FindComponent(SCR_CampaignBuildingObstructionExceptionComponent));
509 if (!obstructionException)
513 if (obstructionException.IsWhitelistEmpty() || obstructionException.IsOnWhitelist(m_sCompositionResourceName))
515 m_bTraceEntityPosition =
false;
530 float traceCoef = world.TraceMove(trace, null);
556 float heightHalf = height * 0.5;
561 vector dir = {radius, heightHalf, 0};
562 trace.Start = pos + dir;
563 trace.End = pos - dir;
564 if (world.TraceMove(trace, null) < 1)
567 dir = {-radius, heightHalf, 0};
568 trace.Start = pos + dir;
569 trace.End = pos - dir;
570 if (world.TraceMove(trace, null) < 1)
573 dir = {0, heightHalf, radius};
574 trace.Start = pos + dir;
575 trace.End = pos - dir;
576 if (world.TraceMove(trace, null) < 1)
579 dir = {0, heightHalf, -radius};
580 trace.Start = pos + dir;
581 trace.End = pos - dir;
582 if (world.TraceMove(trace, null) < 1)
SCR_EAIThreatSectorFlags flags
ArmaReforgerScripted GetGame()
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_CampaignBuildingEditorComponent m_CampaignBuildingComponent
void OnPreviewCreated(SCR_EditablePreviewEntity previewEnt)
Method called when the preview of prefab to build is created.
ECantBuildNotificationType
ECantBuildNotificationType m_eBlockingReason
void SetInitialCanBeCreatedState(notnull SCR_EditablePreviewEntity previewEnt)
Set the initial state of the preview can / can't be created (based on the place where player place th...
SCR_EditablePreviewEntity m_PreviewEnt
ScriptedGameTriggerEntity m_AreaTrigger
bool CanCreate(out ENotification outNotification=-1, out SCR_EPreviewState previewStateToShow=SCR_EPreviewState.PLACEABLE)
Check the preview position. Is suitable to build the composition here?
const float PREVIEW_CHECK_FACTOR
const float MAXIMAL_HEIGHT_ABOVE_TERRAIN_TO_EVALUATE
bool IsCompositionTilted(notnull IEntity ent, float entityRadius, vector originalTransformAngles, out SCR_EPreviewState previewStateToShow=SCR_EPreviewState.PLACEABLE)
Check the tilt of the entities in compositions. If it goes over the set limits, the colour of preview...
void SetSuperiorCanBeCreated(bool val)
Set if the entity can be created, outside of the obstruction system. This is superior to internal m_b...
float GetEntityProtectionRadius(notnull IEntity ent)
Calculate a sphere radius about the entity which will be tested for obstruction.
const int MINIMAL_ENTITY_RADIUS_TO_EVALUATE_TILT
bool HasObstructionException(notnull IEntity ent)
Check if detected entity has set any obstruction exception rulles.
void GetAllEntitiesToEvaluate(notnull SCR_EditablePreviewEntity rootEnt)
const float BOUNDING_BOX_VEHICLE_FACTOR
float GetPredefineProtectionRadius(ResourceName resName)
const float SEA_LEVEL_OFFSET
const float HEIGHT_ABOVE_GROUND_VEHICLE_BUFFER
const float BOUNDING_BOX_FACTOR
bool TraceEntityOnPosition(vector position, notnull BaseWorld world, float safeZoneRadius)
Trace at the position of the preview to find any possibly cliping entities.
bool EvaluateBlockingEntity(IEntity ent)
bool IsPreviewVehicle(IEntity ent)
Check the given preview is vehicle.
bool CanBeCreated()
Return current canbeCreated value.
bool TraceCylinder(vector pos, float radius=0.5, float height=2, TraceFlags flags=TraceFlags.ENTS|TraceFlags.OCEAN, BaseWorld world=null)
vector m_vCylinderVectorOffset
bool CheckEntityPosition(vector pos, float safeZoneRadius)
Check entity position in given radius.
const float MINIMAL_PROTECTION_RADIUS_TO_EVALUATE
const float HEIGHT_ABOVE_GROUND_BUFFER
bool CheckVehiclePosition()
Check entity position in given bounding box.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
proto external EntityPrefabData GetPrefabData()
Object holding reference to resource. In destructor release the resource.
void EOnEditorOpen()
When the editor is opened.
void EOnEditorOpenServer()
When the editor is opened (called on server).
void EOnEditorClose()
When the editor is closed.
SCR_BaseEditorComponent FindEditorComponent(typename type, bool showError=false, bool modeFirst=false)
void EOnEditorActivateServer()
static IEntityComponentSource GetCampaignBuildingCompositionSource(notnull IEntitySource entitySource)
static float GetProtectionRadius(notnull IEntityComponentSource componentSource)
bool HasEntityLabel(EEditableEntityLabel label)
void GetWorldTransform(out vector outTransform[4])
static IEntity GetMainParent(IEntity entity, bool self=false)
void SetLastPreviewState(SCR_EPreviewState state)
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
SCR_FieldOfViewSettings Attribute
proto native vector Vector(float x, float y, float z)