1[
EntityEditorProps(
category:
"GameScripted/Building", description:
"Component attached to a composition layout, holding information about the final composition to be built")]
8 [
RplProp(onRplName:
"SpawnPreviewIfBuildingModeOpened")]
12 protected int m_iToBuildValue;
16 protected float m_fCurrentBuildValue;
20 protected static const int EMPTY_BUILDING_VALUE = 0;
21 protected static const int INVALID_PREFAB_ID = -1;
48 if (editorManagerEntity)
55 return editorManagerEntity != null;
62 if (!m_OnAddBuildingValueInt)
65 return m_OnAddBuildingValueInt;
72 if (!m_OnAddBuildingValueVoid)
75 return m_OnAddBuildingValueVoid;
82 if (!m_OnCompositionIdSet)
85 return m_OnCompositionIdSet;
106 SCR_CampaignBuildingEditorComponent buildingEditorComponent = SCR_CampaignBuildingEditorComponent.Cast(editorModeEntity.FindComponent(SCR_CampaignBuildingEditorComponent));
107 if (!buildingEditorComponent)
110 SCR_CampaignBuildingProviderComponent providerComponent = buildingEditorComponent.GetProviderComponent();
111 if (!providerComponent)
114 return vector.DistanceSq(
GetOwner().
GetOrigin(), providerComponent.GetOwner().GetOrigin()) <= providerComponent.GetBuildingRadius() * providerComponent.GetBuildingRadius();
137 if (currentBuildValue > m_iToBuildValue * 0.5)
140 if (currentBuildValue < m_iToBuildValue)
154 if (resName.IsEmpty())
155 return EMPTY_BUILDING_VALUE;
158 if (!buildingManagerComponent)
159 return EMPTY_BUILDING_VALUE;
163 return EMPTY_BUILDING_VALUE;
175 if (!buildingManagerComponent)
178 return buildingManagerComponent.GetCompositionResourceName(prefabID);
184 BaseGameMode gameMode =
GetGame().GetGameMode();
188 return SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
199 if (m_OnCompositionIdSet)
200 m_OnCompositionIdSet.Invoke(prefabId);
222 SCR_EditorLinkComponent linkComponent = SCR_EditorLinkComponent.Cast(ent.
FindComponent(SCR_EditorLinkComponent));
226 linkComponent.SpawnComposition();
238 SCR_RefPreviewEntity.SpawnAndApplyReference(entity,
params);
256 if (resName.IsEmpty())
263 BaseGameMode gameMode =
GetGame().GetGameMode();
267 SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
268 if (!buildingManagerComponent)
272 spawnParams.TransformMode = ETransformMode.WORLD;
289 if (!characterController)
303 if (modeEntity.IsOpened())
319 if (!characterController)
345 m_fCurrentBuildValue += value;
346 m_fCurrentBuildValue =
Math.Clamp(m_fCurrentBuildValue, 0, m_iToBuildValue);
348 if (m_OnAddBuildingValueInt)
349 m_OnAddBuildingValueInt.Invoke(m_fCurrentBuildValue);
351 if (m_OnAddBuildingValueVoid)
352 m_OnAddBuildingValueVoid.Invoke();
362 newValue =
Math.Clamp(newValue, 0, m_iToBuildValue);
363 m_fCurrentBuildValue = newValue;
365 if (m_OnAddBuildingValueInt)
366 m_OnAddBuildingValueInt.Invoke(m_fCurrentBuildValue);
368 if (m_OnAddBuildingValueVoid)
369 m_OnAddBuildingValueVoid.Invoke();
378 return m_iToBuildValue;
385 return m_fCurrentBuildValue;
401 return editorManager.FindModeEntity(
EEditorMode.BUILDING);
413 SCR_CampaignBuildingCompositionComponent compositionComponent = SCR_CampaignBuildingCompositionComponent.Cast(rootEnt.
FindComponent(SCR_CampaignBuildingCompositionComponent));
414 if (!compositionComponent)
417 compositionComponent.SetInteractionLockServer(
true);
428 Math3D.MatrixIdentity4(transform);
436 transform[3][1] = world.GetSurfaceY(transform[3][0], transform[3][2]);
443 super.OnChildAdded(parent, child);
447 if (!rplComp || rplComp.IsProxy())
457 vector boundMin, boundMax;
459 float previewSize =
vector.DistanceXZ(boundMin, boundMax) * 1.25;
465 GetGame().GetAIWorld().RequestBroadcastDangerEvent(unsafeAreaEvent);
ArmaReforgerScripted GetGame()
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
void SetPrefabId(int prefabId)
void SpawnComposition()
Spawn the composition belonging to this layout.
void ~SCR_CampaignBuildingLayoutComponent()
void AddBuildingValue(int value)
void SpawnPreviewIfBuildingModeOpened()
Spawn the composition preview if the building mode is active (open).
void LockCompositionInteraction()
bool SetOnEditorOpenEvent()
ResourceName GetCompositionResourceName(int prefabID)
SCR_CampaignBuildingManagerComponent GetBuildingManagerComponent()
int GetBuildingValue(int prefabID)
ScriptInvokerVoid GetOnCompositionIdSet()
float GetCurrentBuildValue()
bool IsLayoutInBuildingRange(notnull SCR_EditorModeEntity editorModeEntity)
bool HasBuildingPreview()
void SnapEntityToTerrain(IEntity entity)
void SpawnPreview()
Create a preview if it does not exist.
void OnEditorModeChanged(SCR_EditorModeEntity currentModeEntity, SCR_EditorModeEntity prevModeEntity)
void SetBuildingValue(float newValue)
void EvaluateBuildingStatus(int currentBuildValue)
void CreateUnsafeAreaEvent()
Create a danger event for AI to clear the area where the composition is about to spawn.
ScriptInvokerVoid GetOnAddBuildingValueVoid()
ScriptInvokerInt GetOnAddBuildingValueInt()
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerIntMethod > ScriptInvokerInt
proto external GenericComponent FindComponent(typename typeName)
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external int AddChild(notnull IEntity child, TNodeId pivot, EAddChildFlags flags=EAddChildFlags.AUTO_TRANSFORM)
Add Entity to hierarchy. Pivot is pivot index, or -1 for center of parent.
proto external void GetWorldTransform(out vector mat[])
See IEntity::GetTransform.
proto external BaseWorld GetWorld()
proto external bool SetTransform(vector mat[4])
proto external void GetWorldBounds(out vector mins, out vector maxs)
proto external void RemoveChild(notnull IEntity child, bool keepTransform=false)
Remove Entity from hierarchy.
proto external IEntity GetRootParent()
Object holding reference to resource. In destructor release the resource.
void SetRadius(float radius)
int GetCompositionBuildingValue(ResourceName originalComposition)
Search all SCR_CampaignBuildingCompositionLayoutManager entry and try to find a building value for gi...
ScriptInvokerVoid GetOnPlayerDeath()
static SCR_EditableEntityComponent GetEditableEntity(IEntity owner)
Core component to manage SCR_EditorManagerEntity.
SCR_EditorManagerEntity GetEditorManager()
Network packet of variables for entity placing and transformation.
static SCR_EditorPreviewParams CreateParams(vector transform[4], RplId parentID=Replication.INVALID_ID, EEditorTransformVertical verticalMode=EEditorTransformVertical.SEA, bool isUnderwater=false, SCR_EditableEntityComponent target=null, EEditableEntityInteraction targetInteraction=EEditableEntityInteraction.NONE)
static IEntity GetLocalMainEntity()
void OnChildAdded(IEntity parent, IEntity child)
Called on parent entity when child entity is added into hierarchy.
proto external GenericEntity GetOwner()
Get owner entity.
EEditorMode
Editor mode that defines overall functionality.
EEditorTransformVertical
Vertical transformation mode.