5class SCR_CampaignBuildingGadgetToolComponent : SCR_GadgetComponent
7 [
Attribute(defvalue:
"25",
desc:
"Max distance at which the ghost preview is shown.")]
8 protected float m_fDistanceToShowPreview;
10 [
Attribute(defvalue:
"10",
desc:
"Max distance from which the composition can be build.")]
11 protected float m_fDistanceToBuildComposition;
13 [
Attribute(defvalue:
"10",
desc:
"How much of construction value this tool adds to composition per one action")]
14 protected int m_iConstructionValue;
16 protected const static float TRACE_DELAY_VALUE = 0.5;
18 protected float m_fTraceDelay;
20 protected ref array<SCR_CampaignBuildingLayoutComponent> m_aShownPreview = {};
36 override void Update(
float timeSlice)
38 m_fTraceDelay += timeSlice;
40 if (m_fTraceDelay < TRACE_DELAY_VALUE)
62 return EGadgetType.BUILDING_TOOL;
78 if (!charOwner || charOwner !=
EntityUtils.GetPlayer())
80 super.ModeSwitch(mode, charOwner);
89 super.ModeSwitch(mode, charOwner);
91 if (mode != EGadgetMode.IN_HAND)
108 if (!
System.IsConsoleApp())
112 if (!characterController)
118 if (!editorManagerEntity)
134 if (!characterController)
143 if (!editorManagerEntity)
154 if (!gadgetComponent)
158 if (gadgetComponent.GetType() == EGadgetType.BUILDING_TOOL)
167 if (!
System.IsConsoleApp())
191 return editorManager.FindModeEntity(
EEditorMode.BUILDING);
200 layoutComponent.DeletePreview();
218 if (!controllerComponent)
223 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
224 if (!possessingManager)
227 possessingManager.GetOnPossessedProxy().Insert(
OnPossessed);
236 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
237 if (!possessingManager)
240 possessingManager.GetOnPossessedProxy().Remove(
OnPossessed);
272 if (!controllerComponent)
329 foreach (SCR_CampaignBuildingLayoutComponent component : m_aShownPreview)
332 component.SpawnPreview();
336 m_aShownPreview.Clear();
347 SCR_CampaignBuildingLayoutComponent layoutComponent = SCR_CampaignBuildingLayoutComponent.Cast(ent.
FindComponent(SCR_CampaignBuildingLayoutComponent));
348 if (!layoutComponent)
351 m_aShownPreview.Insert(layoutComponent);
360 return m_iConstructionValue;
405 if (characterController)
409 if (editorManagerEntity)
463 CharacterControllerComponent controller =
m_CharacterOwner.GetCharacterController();
467 SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
480 if (skipUniqueCountCheck)
489 if (firstPrefab != ent.GetPrefabData().GetPrefab())
511 super.ModeClear(mode);
524 PlayerController controller =
GetGame().GetPlayerController();
539 SCR_DeployablePlaceableItemComponent placeableItemComp = SCR_DeployablePlaceableItemComponent.Cast(
m_CurrentlyHandledComponent.GetOwner().FindComponent(SCR_DeployablePlaceableItemComponent));
540 if (placeableItemComp)
541 placeableItemComp.SetPlacingGadget(null);
549 placementComp.EnablePlacement(
false);
550 placementComp.SetPlacedItem(null);
566 placementComp.EnablePlacement(
true);
576 PlayerController controller =
GetGame().GetPlayerController();
595 PlayerController controller =
GetGame().GetPlayerController();
650 if (
m_CurrentlyHandledComponent.IsSurfaceValid(surfaceEnt, worldPosition, surfaceNorm, nodeIndex, colliderIndex, surfaceProps, surfaceMaterial, colliderName))
656 cantPlaceReason =
ENotification.PLACEABLE_ITEM_CANT_PLACE_GENERIC;
673 vector matCopy[4] = transform;
675 matCopy[3] = matCopy[3] - matCopy[1] * 0.01;
683 cantPlaceReason =
ENotification.PLACEABLE_ITEM_CANT_PLACE_NOT_ENOUGH_SPACE;
697 vector forward = transform[2].VectorToAngles();
705 caller.EnablePlacement(
false);
716 if (!success || !equipNext)
730 BaseContainer previousPrefab = item.GetPrefabData().GetPrefab();
738 nextPrefab = otherItem.GetPrefabData().GetPrefab();
739 if (previousPrefab != nextPrefab)
742 m_CurrentlyHandledComponent = SCR_MultiPartDeployableItemComponent.Cast(otherItem.FindComponent(SCR_MultiPartDeployableItemComponent));
750 caller.EnablePlacement(
true);
756 SCR_DeployablePlaceableItemComponent placeableItemComp = SCR_DeployablePlaceableItemComponent.Cast(nowCurrentItem.
FindComponent(SCR_DeployablePlaceableItemComponent));
757 if (!placeableItemComp)
760 placeableItemComp.SetPlacingGadget(
this);
761 caller.SetPlaceableItemComponent(placeableItemComp);
762 caller.SetPlacedItem(nowCurrentItem);
771 caller.EnablePlacement(
true);
784 if (!deployableEntity)
791 array<ref SCR_DeployableVariantContainer> variantsArrayPointer =
data.GetVariants();
792 if (!variantsArrayPointer)
795 int numberOfVariants = variantsArrayPointer.Count();
808 int nextVariantId = -1;
813 nextVariantId = i + 1;
818 if (nextVariantId < 0)
822 if (nextVariantId >= numberOfVariants)
848 if (numberOfPlaceables < 1)
855 if (numberOfPlaceables < 2)
872 for (
int i = currentId; i < numberOfPlaceables; i++)
875 if (otherItem && otherItem != currentItem && currentPrefab != otherItem.
GetPrefabData().GetPrefab())
879 if (currentId > 0 && i == numberOfPlaceables - 1)
883 numberOfPlaceables = currentId;
906 PlayerController controller =
GetGame().GetPlayerController();
916 SCR_DeployablePlaceableItemComponent placeableItemComp = SCR_DeployablePlaceableItemComponent.Cast(nowCurrentItem.
FindComponent(SCR_DeployablePlaceableItemComponent));
917 if (!placeableItemComp)
920 placeableItemComp.SetPlacingGadget(
this);
921 placementComp.SetPlaceableItemComponent(placeableItemComp);
922 placementComp.SetPlacedItem(nowCurrentItem);
935 placementComp.SetPreviewEntity(null,
false);
944 if (!deployableEntity)
952 Math3D.MatrixIdentity4(transform);
960 placementComp.SetPreviewEntity(previewEnt,
false);
ArmaReforgerScripted GetGame()
SCR_RplTestComponentClass m_CharacterOwner
SCR_CharacterControllerComponent GetCharacterController()
bool HasBuildingPreview()
override void ActivateGadgetUpdate()
override void DeactivateGadgetUpdate()
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Get all prefabs that have the spawner data
void SCR_ItemPlacementComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
proto external EntityPrefabData GetPrefabData()
Replication item identifier.
ScriptInvokerVoid GetOnPlayerDeath()
ref OnLifeStateChangedInvoker m_OnLifeStateChanged
float GetMaxAllowedTilt()
Core component to manage SCR_EditorManagerEntity.
SCR_EditorManagerEntity GetEditorManager()
void SetGadgetMode(IEntity gadget, EGadgetMode targetMode, bool doFocus=false)
IEntity GetGadgetByType(EGadgetType type)
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
SCR_GadgetComponent GetHeldGadgetComponent()
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
static IEntity GetLocalControlledEntity()
static IEntity GetLocalMainEntity()
IEntity GetOwner()
Owner entity of the fuel tank.
void OnConsciousnessChanged(bool conscious)
Will be called when the consciousness of the character changes.
SCR_FieldOfViewSettings Attribute
EEditorMode
Editor mode that defines overall functionality.