5 class 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 = {};
28 override void Update(
float timeSlice)
30 m_fTraceDelay += timeSlice;
32 if (m_fTraceDelay < TRACE_DELAY_VALUE)
54 return EGadgetType.BUILDING_TOOL;
68 override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
70 if (!charOwner || charOwner !=
EntityUtils.GetPlayer())
72 super.ModeSwitch(mode, charOwner);
81 super.ModeSwitch(mode, charOwner);
94 if (!System.IsConsoleApp())
98 if (!characterController)
104 if (!editorManagerEntity)
115 void OnPossessed(
int playerID,
bool isPossessing, RplId mainEntityID)
120 if (!characterController)
129 if (!editorManagerEntity)
139 SCR_GadgetComponent gadgetComponent = SCR_GadgetComponent.Cast(gadgetManager.GetHeldGadgetComponent());
140 if (!gadgetComponent)
144 if (gadgetComponent.GetType() == EGadgetType.BUILDING_TOOL)
145 gadgetManager.SetGadgetMode(gadgetManager.GetGadgetByType(EGadgetType.BUILDING_TOOL), EGadgetMode.IN_SLOT);
153 if (!System.IsConsoleApp())
177 return editorManager.FindModeEntity(
EEditorMode.BUILDING);
186 layoutComponent.DeletePreview();
204 if (!controllerComponent)
209 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
210 if (!possessingManager)
213 possessingManager.GetOnPossessedProxy().Insert(
OnPossessed);
222 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
223 if (!possessingManager)
226 possessingManager.GetOnPossessedProxy().Remove(
OnPossessed);
258 if (!controllerComponent)
296 BaseWorld world =
GetOwner().GetWorld();
315 foreach (SCR_CampaignBuildingLayoutComponent component : m_aShownPreview)
318 component.SpawnPreview();
322 m_aShownPreview.Clear();
333 SCR_CampaignBuildingLayoutComponent layoutComponent = SCR_CampaignBuildingLayoutComponent.Cast(ent.FindComponent(SCR_CampaignBuildingLayoutComponent));
334 if (!layoutComponent)
337 m_aShownPreview.Insert(layoutComponent);
346 return m_iConstructionValue;
391 if (characterController)
395 if (editorManagerEntity)