Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CampaignBuildingGadgetToolComponent.c
Go to the documentation of this file.
2{
3}
4
5class SCR_CampaignBuildingGadgetToolComponent : SCR_GadgetComponent
6{
7 [Attribute(defvalue: "25", desc: "Max distance at which the ghost preview is shown.")]
8 protected float m_fDistanceToShowPreview;
9
10 [Attribute(defvalue: "10", desc: "Max distance from which the composition can be build.")]
11 protected float m_fDistanceToBuildComposition;
12
13 [Attribute(defvalue: "10", desc: "How much of construction value this tool adds to composition per one action")]
14 protected int m_iConstructionValue;
15
16 protected const static float TRACE_DELAY_VALUE = 0.5;
17
18 protected float m_fTraceDelay;
19
20 protected ref array<SCR_CampaignBuildingLayoutComponent> m_aShownPreview = {};
21 protected ref array<SCR_CampaignBuildingLayoutComponent> m_aShownPreviewOld = {};
22
24
25 protected ref array<IEntity> m_aFoundDeployables;
26 protected SCR_MultiPartDeployableItemComponent m_CurrentlyHandledComponent;
27 protected int m_iCurrentVariant = -1;
30 protected bool m_bHasMoreItemsToPlace;
32
33// protected SCR_CampaignBuildingLayoutComponent m_LayoutComponent;
34
35 //------------------------------------------------------------------------------------------------
36 override void Update(float timeSlice)
37 {
38 m_fTraceDelay += timeSlice;
39
40 if (m_fTraceDelay < TRACE_DELAY_VALUE)
41 return;
42
44
45 m_fTraceDelay = 0.0;
46 }
47
48 //------------------------------------------------------------------------------------------------
49 override void OnToggleActive(bool state)
50 {
51 m_fTraceDelay = 0.0;
52
53 if (state)
54 ToolToHand();
55 else
57 }
58
59 //------------------------------------------------------------------------------------------------
60 override EGadgetType GetType()
61 {
62 return EGadgetType.BUILDING_TOOL;
63 }
64
65// //------------------------------------------------------------------------------------------------
66// // Perform one build step - add a given build value to a composition player is building.
67// protected void Build(notnull SCR_CampaignBuildingLayoutComponent layoutComponent)
68// {
69// layoutComponent.AddBuildingValue(m_iConstructionValue);
70// }
71
72 //------------------------------------------------------------------------------------------------
76 override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
77 {
78 if (!charOwner || charOwner != EntityUtils.GetPlayer())
79 {
80 super.ModeSwitch(mode, charOwner);
81 return;
82 }
83
85 ToolToHand();
86 else
88
89 super.ModeSwitch(mode, charOwner);
90
91 if (mode != EGadgetMode.IN_HAND)
92 return;
93
95 m_bCanEnterPlacementMode = FindDeployableItems(skipUniqueCountCheck: true) > 0;
96 }
97
98 //------------------------------------------------------------------------------------------------
101 {
102 // Disabled for future
103// EventHandlerManagerComponent eventHandlerManager = EventHandlerManagerComponent.Cast(m_CharacterOwner.FindComponent(EventHandlerManagerComponent));
104// if (eventHandlerManager)
105// eventHandlerManager.RegisterScriptHandler("OnADSChanged", this, TraceCompositionToBuild);
106
107 //ToDo: Later the frame has to run on server too because of tracing the composition to build
108 if (!System.IsConsoleApp())
110
112 if (!characterController)
113 return;
114
115 characterController.GetOnPlayerDeath().Insert(ToolToInventory);
116
117 SCR_EditorManagerEntity editorManagerEntity = SCR_EditorManagerEntity.GetInstance();
118 if (!editorManagerEntity)
119 return;
120
121 editorManagerEntity.GetOnOpened().Insert(OnEditorOpened);
122 editorManagerEntity.GetOnClosed().Insert(OnEditorClosed);
123 }
124
125 //------------------------------------------------------------------------------------------------
129 void OnPossessed(int playerID, bool isPossessing, RplId mainEntityID)
130 {
132
134 if (!characterController)
135 return;
136
137 characterController.GetOnPlayerDeath().Remove(ToolToInventory);
138
139 if (isPossessing)
140 return;
141
142 SCR_EditorManagerEntity editorManagerEntity = SCR_EditorManagerEntity.GetInstance();
143 if (!editorManagerEntity)
144 return;
145
146 editorManagerEntity.GetOnOpened().Remove(OnEditorOpened);
147 editorManagerEntity.GetOnClosed().Remove(OnEditorClosed);
148
150 if (!gadgetManager)
151 return;
152
153 SCR_GadgetComponent gadgetComponent = gadgetManager.GetHeldGadgetComponent();
154 if (!gadgetComponent)
155 return;
156
158 if (gadgetComponent.GetType() == EGadgetType.BUILDING_TOOL)
159 gadgetManager.SetGadgetMode(gadgetManager.GetGadgetByType(EGadgetType.BUILDING_TOOL), EGadgetMode.IN_SLOT);
160 }
161
162 //------------------------------------------------------------------------------------------------
165 {
166 //ToDo: Later the frame has to run on server too because of tracing the composition to build
167 if (!System.IsConsoleApp())
168 {
171
173
175 }
176 }
177
178 //------------------------------------------------------------------------------------------------
182 {
184 if (!core)
185 return null;
186
187 SCR_EditorManagerEntity editorManager = core.GetEditorManager();
188 if (!editorManager)
189 return null;
190
191 return editorManager.FindModeEntity(EEditorMode.BUILDING);
192 }
193
194 //------------------------------------------------------------------------------------------------
195 protected void RemovePreviews()
196 {
197 foreach (SCR_CampaignBuildingLayoutComponent layoutComponent : m_aShownPreviewOld)
198 {
199 if (layoutComponent)
200 layoutComponent.DeletePreview();
201 }
202
203 m_aShownPreviewOld.Clear();
204 }
205
206 //------------------------------------------------------------------------------------------------
208 protected void OnEditorOpened()
209 {
211 if (!char)
212 return;
213
216
218 if (!controllerComponent)
219 return;
220
221 controllerComponent.m_OnLifeStateChanged.Insert(OnConsciousnessChanged);
222
223 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
224 if (!possessingManager)
225 return;
226
227 possessingManager.GetOnPossessedProxy().Insert(OnPossessed);
228 }
229
230 //------------------------------------------------------------------------------------------------
232 protected void OnEditorClosed()
233 {
235
236 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
237 if (!possessingManager)
238 return;
239
240 possessingManager.GetOnPossessedProxy().Remove(OnPossessed);
241
242 // If the editor is closed, because player possessed entity, don't continue and keep this event hooked for another call.
243 if (possessingManager.IsPossessing(SCR_PlayerController.GetLocalPlayerId()))
244 {
246 return;
247 }
248
251 GetGame().GetCallqueue().CallLater(ToolToHand, 0, false);
252 }
253
254 //------------------------------------------------------------------------------------------------
255 void OnConsciousnessChanged(bool conscious)
256 {
257 if (conscious)
258 return;
259
262 }
263
264 //------------------------------------------------------------------------------------------------
266 {
268 if (!char)
269 return;
270
272 if (!controllerComponent)
273 return;
274
275 controllerComponent.m_OnLifeStateChanged.Remove(OnConsciousnessChanged);
276 }
277// //------------------------------------------------------------------------------------------------
278// // Trace a composition to build commented out for future
279// void TraceCompositionToBuild()
280// {
281// if (!m_CharacterOwner)
282// return;
283//
284// ChimeraCharacter character = ChimeraCharacter.Cast(m_CharacterOwner);
285//
286// TraceParam param = new TraceParam();
287// param.Start = character.EyePosition();
288// param.End = param.Start + GetPlayersDirection() * m_fDistanceToBuildComposition;
289//
290// param.Flags =TraceFlags.ENTS;
291// param.Exclude = character;
292// param.LayerMask = EPhysicsLayerPresets.Interaction;
293// BaseWorld world = GetOwner().GetWorld();
294// float traceDistance = world.TraceMove(param, EvaluateBuildEntity);
295//
296// // This has to be done after the trace finished, because spawning / deleting or moving with the entity while trace is running can cause an issues.
297// if (m_LayoutComponent)
298// {
299// Build(m_LayoutComponent);
300// m_LayoutComponent = null;
301// }
302//
303// }
304
305 //------------------------------------------------------------------------------------------------
309 {
310 BaseWorld world = GetOwner().GetWorld();
311 if (!world)
312 return false;
313
314 world.QueryEntitiesBySphere(GetOwner().GetOrigin(), m_fDistanceToShowPreview, EvaluatePreviewEntity);
315
316 // Delete those preview which are no more on the list of traced one and then copy the array for next iteration cycle.
317 for (int i = m_aShownPreviewOld.Count() - 1; i >= 0; i--)
318 {
320 {
321 m_aShownPreviewOld.Remove(i);
322 continue;
323 }
324
325 if (!m_aShownPreview.Contains(m_aShownPreviewOld[i]))
326 m_aShownPreviewOld[i].DeletePreview();
327 }
328
329 foreach (SCR_CampaignBuildingLayoutComponent component : m_aShownPreview)
330 {
331 if (component && !m_aShownPreviewOld.Contains(component))
332 component.SpawnPreview();
333 }
334
335 m_aShownPreviewOld.Copy(m_aShownPreview);
336 m_aShownPreview.Clear();
337
338 return true;
339 }
340
341 //------------------------------------------------------------------------------------------------
342 protected bool EvaluatePreviewEntity(IEntity ent)
343 {
344 if (!ent)
345 return true;
346
347 SCR_CampaignBuildingLayoutComponent layoutComponent = SCR_CampaignBuildingLayoutComponent.Cast(ent.FindComponent(SCR_CampaignBuildingLayoutComponent));
348 if (!layoutComponent)
349 return true;
350
351 m_aShownPreview.Insert(layoutComponent);
352
353 return true;
354 }
355
356 //------------------------------------------------------------------------------------------------
359 {
360 return m_iConstructionValue;
361 }
362
363 //------------------------------------------------------------------------------------------------
373
374// //------------------------------------------------------------------------------------------------
375// // Disabled for future
376// bool EvaluateBuildEntity(IEntity ent, vector start = "0 0 0", vector dir = "0 0 0")
377// {
378// IEntity parent = ent.GetParent();
379// if (!parent)
380// return true;
381//
382// SCR_CampaignBuildingLayoutComponent layoutComponent = SCR_CampaignBuildingLayoutComponent.Cast(parent.FindComponent(SCR_CampaignBuildingLayoutComponent));
383// if (!layoutComponent)
384// return true;
385//
386// m_LayoutComponent = layoutComponent;
387// return false;
388// }
389
390// //------------------------------------------------------------------------------------------------
391// //! Returns the direction the player is looking Disabled debug
392// private vector GetPlayersDirection()
393// {
394// vector aimMat[4];
395// ChimeraCharacter character = ChimeraCharacter.Cast(m_CharacterOwner);
396// Math3D.AnglesToMatrix(CharacterControllerComponent.Cast(character.FindComponent(CharacterControllerComponent)).GetInputContext().GetAimingAngles() * Math.RAD2DEG, aimMat);
397// return aimMat[2];
398// }
399
400 //------------------------------------------------------------------------------------------------
403 {
405 if (characterController)
406 characterController.GetOnPlayerDeath().Remove(ToolToInventory);
407
408 SCR_EditorManagerEntity editorManagerEntity = SCR_EditorManagerEntity.GetInstance();
409 if (editorManagerEntity)
410 {
411 editorManagerEntity.GetOnOpened().Remove(OnEditorOpened);
412
414 editorManagerEntity.GetOnClosed().Remove(OnEditorClosed);
415 }
416 }
417
418 //------------------------------------------------------------------------------------------------
424
425 //------------------------------------------------------------------------------------------------
428 {
430 }
431
432 //------------------------------------------------------------------------------------------------
435 {
437 }
438
439 //------------------------------------------------------------------------------------------------
445
446 //------------------------------------------------------------------------------------------------
448 SCR_MultiPartDeployableItemComponent GetCurrentlyHandledComponent()
449 {
451 }
452
453 //------------------------------------------------------------------------------------------------
458 protected int FindDeployableItems(IEntity ignoredItem = null, bool skipUniqueCountCheck = false)
459 {
460 if (!m_CharacterOwner)
461 return 0;
462
463 CharacterControllerComponent controller = m_CharacterOwner.GetCharacterController();
464 if (!controller)
465 return 0;
466
467 SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
468 if (!storageManager)
469 return 0;
470
474 else
475 m_aFoundDeployables.Clear();
476
477 int count = storageManager.FindItems(m_aFoundDeployables, searchPredicate);
478
480 if (skipUniqueCountCheck)
481 return count;
482
483 GetGame().GetInputManager().RemoveActionListener(SCR_ItemPlacementComponent.ACTION_NAME_CHANGE_ITEM, EActionTrigger.DOWN, CycleItems);
484 if (count > 1)
485 {
486 BaseContainer firstPrefab = m_aFoundDeployables[0].GetPrefabData().GetPrefab();
487 foreach (IEntity ent : m_aFoundDeployables)
488 {
489 if (firstPrefab != ent.GetPrefabData().GetPrefab())
490 {
492 GetGame().GetInputManager().AddActionListener(SCR_ItemPlacementComponent.ACTION_NAME_CHANGE_ITEM, EActionTrigger.DOWN, CycleItems);
493 return count;
494 }
495 }
496 }
497
498 return count;
499 }
500
501 //------------------------------------------------------------------------------------------------
503 override protected void ActivateAction()
504 {
506 }
507
508 //------------------------------------------------------------------------------------------------
509 override protected void ModeClear(EGadgetMode mode)
510 {
511 super.ModeClear(mode);
512
514 SetPlacementMode(false);
515 }
516
517 //------------------------------------------------------------------------------------------------
519 protected void SetPlacementMode(bool newState)
520 {
521 if (m_bPlacementModeEnabled == newState)
522 return;
523
524 PlayerController controller = GetGame().GetPlayerController();
525 if (!controller)
526 return;
527
528 SCR_ItemPlacementComponent placementComp = SCR_ItemPlacementComponent.Cast(controller.FindComponent(SCR_ItemPlacementComponent));
529 if (!placementComp)
530 return;
531
532 if (!newState)
533 {
534 EnablePreview(false, placementComp);
535
537 {
538 m_CurrentlyHandledComponent.ClearCache();
539 SCR_DeployablePlaceableItemComponent placeableItemComp = SCR_DeployablePlaceableItemComponent.Cast(m_CurrentlyHandledComponent.GetOwner().FindComponent(SCR_DeployablePlaceableItemComponent));
540 if (placeableItemComp)
541 placeableItemComp.SetPlacingGadget(null);
542
544 }
545
546 m_aFoundDeployables.Clear();
548
549 placementComp.EnablePlacement(false);
550 placementComp.SetPlacedItem(null);
551
552 InputManager inputMgr = GetGame().GetInputManager();
553 inputMgr.RemoveActionListener(SCR_ItemPlacementComponent.ACTION_NAME_CHANGE_ITEM, EActionTrigger.DOWN, CycleItems);
554 inputMgr.RemoveActionListener(SCR_ItemPlacementComponent.ACTION_NAME_CHANGE_VARIANT, EActionTrigger.DOWN, CycleVariants);
555 m_bPlacementModeEnabled = newState;
556 return;
557 }
558
561 return;
562
563 m_bPlacementModeEnabled = newState;
564 SelectNextPlaceableItem(placementComp);
565
566 placementComp.EnablePlacement(true);
567 }
568
569 //------------------------------------------------------------------------------------------------
574 protected void CycleItems(float value = 0.0, EActionTrigger reason = 0, string actionName = string.Empty)
575 {
576 PlayerController controller = GetGame().GetPlayerController();
577 if (!controller)
578 return;
579
580 SCR_ItemPlacementComponent placementComp = SCR_ItemPlacementComponent.Cast(controller.FindComponent(SCR_ItemPlacementComponent));
581 if (!placementComp)
582 return;
583
584 EnablePreview(false, placementComp);
585 SelectNextPlaceableItem(placementComp);
586 }
587
588 //------------------------------------------------------------------------------------------------
593 protected void CycleVariants(float value = 0.0, EActionTrigger reason = 0, string actionName = string.Empty)
594 {
595 PlayerController controller = GetGame().GetPlayerController();
596 if (!controller)
597 return;
598
599 SCR_ItemPlacementComponent placementComp = SCR_ItemPlacementComponent.Cast(controller.FindComponent(SCR_ItemPlacementComponent));
600 if (!placementComp)
601 return;
602
603 EnablePreview(false, placementComp);
604
605 if (!SelectNextVariant())
606 {
607 SetPlacementMode(false);
608 return;
609 }
610
611 EnablePreview(true, placementComp);
612 }
613
614 //------------------------------------------------------------------------------------------------
617 {
619 return -1;
620
622 if (!data)
623 return -1;
624
625 SCR_DeployableVariantContainer container = data.GetVariantContainer(m_iCurrentVariant);
626 if (!container)
627 return -1;
628
629 return container.GetMaxAllowedTilt();
630 }
631
632 //------------------------------------------------------------------------------------------------
645 bool ValidateSurface(notnull SCR_ItemPlacementComponent caller, out ENotification cantPlaceReason, IEntity surfaceEnt, vector worldPosition, vector surfaceNorm, int nodeIndex, int colliderIndex, SurfaceProperties surfaceProps, string surfaceMaterial, string colliderName)
646 {
648 return false;
649
650 if (m_CurrentlyHandledComponent.IsSurfaceValid(surfaceEnt, worldPosition, surfaceNorm, nodeIndex, colliderIndex, surfaceProps, surfaceMaterial, colliderName))
651 {
652 m_CurrentlyHandledComponent.SetPreviewState(SCR_EPreviewState.PLACEABLE);
653 return true;
654 }
655
656 cantPlaceReason = ENotification.PLACEABLE_ITEM_CANT_PLACE_GENERIC;
657 m_CurrentlyHandledComponent.SetPreviewState(SCR_EPreviewState.BLOCKED);
658 return true;
659 }
660
661 //------------------------------------------------------------------------------------------------
667 bool ValidateSpace(notnull SCR_ItemPlacementComponent caller, inout vector transform[4], out ENotification cantPlaceReason)
668 {
670 return false;
671
672 vector angle = Math3D.MatrixToAngles(transform);
673 vector matCopy[4] = transform;
674 // remove the offset to ensure that CheckAvailableSpace will have the same position when it is called by the user action
675 matCopy[3] = matCopy[3] - matCopy[1] * 0.01;
676
677 if (m_CurrentlyHandledComponent.CheckAvailableSpace(matCopy, angle))
678 {
679 m_CurrentlyHandledComponent.SetPreviewState(SCR_EPreviewState.PLACEABLE);
680 return true;
681 }
682
683 cantPlaceReason = ENotification.PLACEABLE_ITEM_CANT_PLACE_NOT_ENOUGH_SPACE;
684 m_CurrentlyHandledComponent.SetPreviewState(SCR_EPreviewState.BLOCKED);
685 return true;
686 }
687
688 //------------------------------------------------------------------------------------------------
692 void OverridePreviewTransform(notnull SCR_ItemPlacementComponent caller, inout vector transform[4])
693 {
695 return;
696
697 vector forward = transform[2].VectorToAngles();
698 m_CurrentlyHandledComponent.ComputeTransform(transform, forward);
699 }
700
701 //------------------------------------------------------------------------------------------------
704 {
705 caller.EnablePlacement(false);
706 EnablePreview(false, caller);
707 }
708
709 //------------------------------------------------------------------------------------------------
714 void OnAfterItemPlaced(notnull SCR_ItemPlacementComponent caller, notnull IEntity item, bool success, bool equipNext)
715 {
716 if (!success || !equipNext)
717 {
718 SetPlacementMode(false);
719 return;
720 }
721
724 {
725 SetPlacementMode(false);
726 return;
727 }
728
729 //find the same prefab
730 BaseContainer previousPrefab = item.GetPrefabData().GetPrefab();
731 BaseContainer nextPrefab;
733 EnablePreview(false, caller);
734
736 foreach (IEntity otherItem : m_aFoundDeployables)
737 {
738 nextPrefab = otherItem.GetPrefabData().GetPrefab();
739 if (previousPrefab != nextPrefab)
740 continue;
741
742 m_CurrentlyHandledComponent = SCR_MultiPartDeployableItemComponent.Cast(otherItem.FindComponent(SCR_MultiPartDeployableItemComponent));
743 break;
744 }
745
747 {
750 caller.EnablePlacement(true);
751
752 return;
753 }
754
755 IEntity nowCurrentItem = m_CurrentlyHandledComponent.GetOwner();
756 SCR_DeployablePlaceableItemComponent placeableItemComp = SCR_DeployablePlaceableItemComponent.Cast(nowCurrentItem.FindComponent(SCR_DeployablePlaceableItemComponent));
757 if (!placeableItemComp)
758 return;
759
760 placeableItemComp.SetPlacingGadget(this);
761 caller.SetPlaceableItemComponent(placeableItemComp);
762 caller.SetPlacedItem(nowCurrentItem);
763
764 if (!m_CurrentlyHandledComponent.FetchVariantData(m_iCurrentVariant))
765 {
766 SetPlacementMode(false);
767 return;
768 }
769
770 EnablePreview(true, caller);
771 caller.EnablePlacement(true);
772 }
773
774 //------------------------------------------------------------------------------------------------
778 {
780 return false;
781
782 GetGame().GetInputManager().RemoveActionListener(SCR_ItemPlacementComponent.ACTION_NAME_CHANGE_VARIANT, EActionTrigger.DOWN, CycleVariants);
783 IEntity deployableEntity = m_CurrentlyHandledComponent.GetOwner();
784 if (!deployableEntity)
785 return false;
786
788 if (!data)
789 return false;
790
791 array<ref SCR_DeployableVariantContainer> variantsArrayPointer = data.GetVariants();
792 if (!variantsArrayPointer)
793 return false;
794
795 int numberOfVariants = variantsArrayPointer.Count();
796 m_bHasMoreVariantsToChoose = numberOfVariants > 1;
797
799 {
800 m_iCurrentVariant = variantsArrayPointer[0].GetVariantId();
803 GetGame().GetInputManager().AddActionListener(SCR_ItemPlacementComponent.ACTION_NAME_CHANGE_VARIANT, EActionTrigger.DOWN, CycleVariants);
804
805 return true;
806 }
807
808 int nextVariantId = -1;
809 foreach (int i, SCR_DeployableVariantContainer variant : variantsArrayPointer)
810 {
811 if (variant.GetVariantId() == m_iCurrentVariant)
812 {
813 nextVariantId = i + 1;
814 break;
815 }
816 }
817
818 if (nextVariantId < 0)
819 return false;
820
821 GetGame().GetInputManager().AddActionListener(SCR_ItemPlacementComponent.ACTION_NAME_CHANGE_VARIANT, EActionTrigger.DOWN, CycleVariants);
822 if (nextVariantId >= numberOfVariants)
823 nextVariantId = 0;
824
825 SCR_DeployableVariantContainer variantPointer = variantsArrayPointer[nextVariantId];
826 if (!variantPointer)
827 return false;
828
829 m_iCurrentVariant = variantPointer.GetVariantId();
830
831 return m_CurrentlyHandledComponent.FetchVariantData(m_iCurrentVariant);
832 }
833
834 //------------------------------------------------------------------------------------------------
837 protected void SelectNextPlaceableItem(notnull SCR_ItemPlacementComponent placementComp)
838 {
840 return;
841
843 return;
844
845 int numberOfPlaceables = m_aFoundDeployables.Count();
847 {
848 if (numberOfPlaceables < 1)
849 return;
850
851 m_CurrentlyHandledComponent = SCR_MultiPartDeployableItemComponent.Cast(m_aFoundDeployables[0].FindComponent(SCR_MultiPartDeployableItemComponent));
852 }
853 else
854 {
855 if (numberOfPlaceables < 2)
856 return;
857
858 IEntity currentItem = m_CurrentlyHandledComponent.GetOwner();
859 if (!currentItem)
860 return;
861
862 int currentId = m_aFoundDeployables.Find(currentItem);
863 if (currentId < 0)
864 {
866 SelectNextPlaceableItem(placementComp);
867 return;
868 }
869
870 BaseContainer currentPrefab = currentItem.GetPrefabData().GetPrefab();
871 IEntity otherItem;
872 for (int i = currentId; i < numberOfPlaceables; i++)
873 {
874 otherItem = m_aFoundDeployables[i];
875 if (otherItem && otherItem != currentItem && currentPrefab != otherItem.GetPrefabData().GetPrefab())
876 break;
877
878 otherItem = null;
879 if (currentId > 0 && i == numberOfPlaceables - 1)
880 {
881 //restart from the begining
882 i = -1;
883 numberOfPlaceables = currentId;
884 currentId = -1;
885 }
886 }
887
888 if (!otherItem)
889 return;
890
891 m_CurrentlyHandledComponent = SCR_MultiPartDeployableItemComponent.Cast(otherItem.FindComponent(SCR_MultiPartDeployableItemComponent));
892 }
893
895 return;
896
898 if (!SelectNextVariant())
899 {
900 SetPlacementMode(false);
901 return;
902 }
903
904 if (!placementComp)
905 {
906 PlayerController controller = GetGame().GetPlayerController();
907 if (!controller)
908 return;
909
910 placementComp = SCR_ItemPlacementComponent.Cast(controller.FindComponent(SCR_ItemPlacementComponent));
911 if (!placementComp)
912 return;
913 }
914
915 IEntity nowCurrentItem = m_CurrentlyHandledComponent.GetOwner();
916 SCR_DeployablePlaceableItemComponent placeableItemComp = SCR_DeployablePlaceableItemComponent.Cast(nowCurrentItem.FindComponent(SCR_DeployablePlaceableItemComponent));
917 if (!placeableItemComp)
918 return;
919
920 placeableItemComp.SetPlacingGadget(this);
921 placementComp.SetPlaceableItemComponent(placeableItemComp);
922 placementComp.SetPlacedItem(nowCurrentItem);
923
925 }
926
927 //------------------------------------------------------------------------------------------------
931 protected void EnablePreview(bool enabled, notnull SCR_ItemPlacementComponent placementComp)
932 {
933 if (!enabled)
934 {
935 placementComp.SetPreviewEntity(null, false);
937 return;
938 }
939
941 return;
942
943 IEntity deployableEntity = m_CurrentlyHandledComponent.GetOwner();
944 if (!deployableEntity)
945 return;
946
948 if (!data)
949 return;
950
951 vector transform[4];
952 Math3D.MatrixIdentity4(transform);
953 m_CurrentlyHandledComponent.VisualizeReplacementEntity(transform);
954
955 IEntity previewEnt = data.GetPreviewEntity();
956 if (!previewEnt)
957 return;
958
959 data.SetPreviewState(SCR_EPreviewState.PLACEABLE);
960 placementComp.SetPreviewEntity(previewEnt, false);
961 }
962}
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_RplTestComponentClass m_CharacterOwner
vector GetOrigin()
SCR_CharacterControllerComponent GetCharacterController()
void OnAfterItemPlaced(notnull SCR_ItemPlacementComponent caller, notnull IEntity item, bool success, bool equipNext)
void ModeClear(EGadgetMode mode)
void ActivateAction()
Action listener callback.
void SetPlacementMode(bool newState)
override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
bool ValidateSpace(notnull SCR_ItemPlacementComponent caller, inout vector transform[4], out ENotification cantPlaceReason)
SCR_CharacterControllerComponent GetCharacterControllerComponent()
ref array< SCR_CampaignBuildingLayoutComponent > m_aShownPreviewOld
SCR_MultiPartDeployableItemComponent GetCurrentlyHandledComponent()
SCR_MultiPartDeployableItemComponent m_CurrentlyHandledComponent
void OverridePreviewTransform(notnull SCR_ItemPlacementComponent caller, inout vector transform[4])
override EGadgetType GetType()
override void OnToggleActive(bool state)
ref array< IEntity > m_aFoundDeployables
void OnItemPlacementStart(notnull SCR_ItemPlacementComponent caller)
void ToolToHand()
Building tool taken to hand - show preview etc.
void EnablePreview(bool enabled, notnull SCR_ItemPlacementComponent placementComp)
void CycleVariants(float value=0.0, EActionTrigger reason=0, string actionName=string.Empty)
void CycleItems(float value=0.0, EActionTrigger reason=0, string actionName=string.Empty)
void OnEditorClosed()
Method called when character has a shovel in hands and any editor mode is closed.
SCR_EditorModeEntity GetBuildingModeEntity()
void OnEditorOpened()
Method called when character has a shovel in hands and any editor mode is opned.
void ToolToInventory()
Building tool out of hands - show preview.
bool EvaluatePreviewEntity(IEntity ent)
bool ValidateSurface(notnull SCR_ItemPlacementComponent caller, out ENotification cantPlaceReason, IEntity surfaceEnt, vector worldPosition, vector surfaceNorm, int nodeIndex, int colliderIndex, SurfaceProperties surfaceProps, string surfaceMaterial, string colliderName)
void SelectNextPlaceableItem(notnull SCR_ItemPlacementComponent placementComp)
int FindDeployableItems(IEntity ignoredItem=null, bool skipUniqueCountCheck=false)
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)
func OnPossessed
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
proto external EntityPrefabData GetPrefabData()
Input management system for user interactions.
Replication item identifier.
Definition RplId.c:14
ref OnLifeStateChangedInvoker m_OnLifeStateChanged
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.
Definition EEditorMode.c:6
EActionTrigger