Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ResourceComponent.c
Go to the documentation of this file.
3 CONSUMER = 1 << 0,
4 CONTAINER = 1 << 1,
5 GENERATOR = 1 << 2,
6 ENCAPSULATOR = 1 << 3,
7}
8
9//~ ScriptInvokers
10void SCR_Resources_OnResourceEnabledChanged(SCR_ResourceComponent resourceComponent, array<EResourceType> disabledResourceTypes);
12
15[ComponentEditorProps(category: "GameScripted/Resources", description: "")]
17{
21 [Attribute(uiwidget: UIWidgets.Object, category: "Containers")]
22 protected ref array<ref SCR_ResourceContainer> m_aContainers;
23
24 //------------------------------------------------------------------------------------------------
27 array<ref SCR_ResourceContainer> GetContainers()
28 {
29 return m_aContainers;
30 }
31
32 //------------------------------------------------------------------------------------------------
33 override static array<typename> Requires(IEntityComponentSource src)
34 {
35 return { RplComponent };
36 }
37}
38
43class SCR_ResourceComponent : ScriptComponent
44{
45 const float UPDATE_DISTANCE_TRESHOLD = 2.5;
47 protected const float UPDATE_PERIOD = 10.0 / 60.0;
48 protected bool m_bIsNetDirty;
49 protected int m_iGridUpdateId = int.MIN;
50
51 protected int m_iGridContainersBoundsMins = 0xFFFFFFFF;
52 protected int m_iGridContainersBoundsMaxs = 0xFFFFFFFF;
55
57
59 [Attribute(uiwidget: UIWidgets.Object, category: "Encapsulators")]
60 protected ref array<ref SCR_ResourceEncapsulator> m_aEncapsulators;
61
63 [Attribute(uiwidget: UIWidgets.Object, category: "Consumers"), RplProp(onRplName: "TEMP_OnInteractorReplicated")]
64 protected ref array<ref SCR_ResourceConsumer> m_aConsumers;
65
67 [Attribute(uiwidget: UIWidgets.Object, category: "Generators"), RplProp(onRplName: "TEMP_OnInteractorReplicated")]
68 protected ref array<ref SCR_ResourceGenerator> m_aGenerators;
69
70 //~ Any Resource Types that is set here is a disabled resource type
71 [Attribute(desc: "List of all disabled resource types", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EResourceType)), RplProp(onRplName: "OnResourceTypeEnabledChanged")]
72 protected ref array<EResourceType> m_aDisabledResourceTypes;
73
74 //~ Any ResourceType that is set here cannot be enabled or disabled in runtime for this entity by editor
75 [Attribute(desc: "Any ResourceType that is set here cannot be enabled or disabled in runtime for this entity by editor", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EResourceType))]
76 protected ref array<EResourceType> m_aDisallowChangingEnableResource;
77
80
81 protected ref ScriptInvokerBase<SCR_Resources_OnResourceEnabledChanged> m_OnResourceTypeEnabledChanged;
82
83 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
84 //------------------------------------------------------------------------------------------------
93
94 //------------------------------------------------------------------------------------------------
101 //---- REFACTOR NOTE END ----
102
104 [Attribute(uiwidget: UIWidgets.CheckBox, category: "Debugging")]
106
108 [Attribute(defvalue: "-1", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EResourceDebugVisualizationFlags), category: "Debugging")]
110
112 [Attribute(defvalue: "0.4 0.0 0.467 0.267 ", uiwidget: UIWidgets.ColorPicker, category: "Debugging")]
113 protected ref Color m_DebugColor;
114
115 [RplProp(onRplName: "OnVisibilityChanged")]
116 protected bool m_bIsVisible = true;
117
120 protected ref array<ref SCR_ResourceContainer> m_aContainerInstances = {};
121
123 protected RplComponent m_ReplicationComponent;
124 protected FactionAffiliationComponent m_FactionAffiliationComponent;
125
126 protected vector m_LastPosition = vector.Zero;
127 protected bool m_bHasParent;
128 protected bool m_bIsOwnerActive;
129
130 // TODO: Remove after fixing initialisation and hierarchy issues.
131 protected bool m_bIsInitialized;
132
133 // TODO: Remove after fixing initialisation and hierarchy issues.
135
136 //------------------------------------------------------------------------------------------------
140 {
141 if (!SCR_ResourceSystemHelper.IsGlobalResourceTypeEnabled(resourceType))
142 return false;
143
144 return !m_aDisabledResourceTypes.Contains(resourceType);
145 }
146
147 //------------------------------------------------------------------------------------------------
150 int GetDisabledResourceTypes(inout notnull array<EResourceType> disabledResourceTypes)
151 {
152 disabledResourceTypes.Copy(m_aDisabledResourceTypes);
153 return disabledResourceTypes.Count();
154 }
155
156 //------------------------------------------------------------------------------------------------
160 {
161 return !m_aDisallowChangingEnableResource.Contains(resourceType);
162 }
163
164 //------------------------------------------------------------------------------------------------
168 bool CanBeUsedByCharacter(notnull SCR_ChimeraCharacter character)
169 {
170 FactionAffiliationComponent factionAffiliation = GetFactionAffiliationComponent();
171 if (!factionAffiliation)
172 return true; // supplies in item form, or some caches dont have faction affiliation
173
174 Faction suppliesFaction = factionAffiliation.GetAffiliatedFaction();
175 if (!suppliesFaction)
176 return true; // for example empty vehicles
177
178 Faction playerFaction = character.GetFaction();
179 if (playerFaction != suppliesFaction)
180 return factionAffiliation.GetOwner().FindComponent(SCR_CampaignSourceBaseComponent) != null; // harbors are unprotected, and thus there shouldn't be anything preventing you from taking their supplies
181
182 return true;
183 }
184
185 //------------------------------------------------------------------------------------------------
189 void SetResourceTypeEnabled(bool enable, EResourceType resourceType = EResourceType.SUPPLIES)
190 {
191 if (!CanResourceTypeEnabledBeChanged(resourceType))
192 return;
193
194 int index = m_aDisabledResourceTypes.Find(resourceType);
195
196 //~ Already Enabled/Disabled
197 if ((index < 0) == enable)
198 return;
199
200 if (!enable)
201 m_aDisabledResourceTypes.Insert(resourceType);
202 else
204
205 Replication.BumpMe();
206
207 //~ Enable/Disable resource type for all encapsulated resourceComponents
208 /*array<SCR_ResourceEncapsulator> encapsulators = GetEncapsulators();
209 SCR_ResourceComponent resourceComponent;
210 foreach (SCR_ResourceEncapsulator encapsulator : encapsulators)
211 {
212 resourceComponent = encapsulator.GetComponent();
213 if (!resourceComponent || !resourceComponent.CanResourceTypeEnabledBeChanged(resourceType))
214 continue;
215
216 resourceComponent.SetResourceTypeEnabled(enable, resourceType);
217 }*/
218
220 if ((gameMode && gameMode.IsMaster()) || (!gameMode && Replication.IsServer()))
222 }
223
224 //------------------------------------------------------------------------------------------------
230
231 //------------------------------------------------------------------------------------------------
233 ScriptInvokerBase<SCR_Resources_OnResourceEnabledChanged> GetOnResourceTypeEnabledChanged()
234 {
236 m_OnResourceTypeEnabledChanged = new ScriptInvokerBase<SCR_Resources_OnResourceEnabledChanged>();
237
239 }
240
241 //------------------------------------------------------------------------------------------------
246 static SCR_ResourceComponent FindResourceComponent(IEntity entity, bool ignoreChildIfHasStorage = false)
247 {
248 //~ Function is used in many places. Not all can guarantee that entity is not null
249 if (!entity)
250 return null;
251
252 //~ Get resource component
253 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(entity.FindComponent(SCR_ResourceComponent));
254 if (resourceComponent)
255 return resourceComponent;
256
257 //~ Loop over slotted entities if entity is a vehicle. Note that slotted entities are not yet in hierarchy the moment they are created for clients
258 if (Vehicle.Cast(entity))
259 {
260 SlotManagerComponent slotManager = SlotManagerComponent.Cast(entity.FindComponent(SlotManagerComponent));
261 if (!slotManager)
262 return null;
263
264 array<EntitySlotInfo> outSlotInfos = {};
265 slotManager.GetSlotInfos(outSlotInfos);
266 IEntity slot;
267
268 foreach (EntitySlotInfo slotInfo : outSlotInfos)
269 {
270 slot = slotInfo.GetAttachedEntity();
271
272 if (!slot)
273 continue;
274
275 resourceComponent = SCR_ResourceComponent.Cast(slot.FindComponent(SCR_ResourceComponent));
276 if (resourceComponent)
277 {
278 //~ It does not care if the slotted entity has a storage or not
279 if (!ignoreChildIfHasStorage)
280 return resourceComponent;
281
282 //~ Has no storage so this is a valid resource component
283 if (!slot.FindComponent(ScriptedBaseInventoryStorageComponent))
284 return resourceComponent;
285 }
286 }
287 }
288 //~ Check if parent is vehicle than get resource component from parent or any other slot
289 else if (Vehicle.Cast(entity.GetParent()))
290 {
291 InventoryItemComponent inventoryItem = InventoryItemComponent.Cast(entity.FindComponent(InventoryItemComponent));
292 if (inventoryItem)
293 {
294 //~ Is item in inventory thus ignore getting vehicle parent
295 if (inventoryItem.GetParentSlot())
296 return null;
297 }
298
299 return SCR_ResourceComponent.FindResourceComponent(entity.GetParent(), ignoreChildIfHasStorage);
300 }
301
302 return null;
303 }
304
305 //------------------------------------------------------------------------------------------------
311
312 //------------------------------------------------------------------------------------------------
318
319 //------------------------------------------------------------------------------------------------
322 void GetGridContainersBounds(out int mins, out int maxs)
323 {
326 }
327
328 //------------------------------------------------------------------------------------------------
336
337 //------------------------------------------------------------------------------------------------
341 {
342 vector ownerOrigin = GetOwner().GetOrigin();
343 mins = ownerOrigin + m_vGridContainersBoundingVolumeMins;
344 maxs = ownerOrigin + m_vGridContainersBoundingVolumeMaxs;
345 }
346
347 //------------------------------------------------------------------------------------------------
350 {
352 }
353
354 //------------------------------------------------------------------------------------------------
356 FactionAffiliationComponent GetFactionAffiliationComponent()
357 {
359 }
360
361 //------------------------------------------------------------------------------------------------
365 {
366 if (resourceType == EResourceType.INVALID || !m_aEncapsulators)
367 return null;
368
369 int higherLimitPosition = m_aEncapsulators.Count();
370
371 if (higherLimitPosition == 0)
372 return null;
373
374 int position;
375 SCR_ResourceEncapsulator encapsulator;
376
377 while (position < higherLimitPosition)
378 {
379 if (GetNextEncapsulatorCandidate(position, higherLimitPosition, encapsulator, resourceType))
380 break;
381 }
382
383 if (!encapsulator
384 || position == m_aEncapsulators.Count()
385 || resourceType != encapsulator.GetResourceType())
386 return null;
387
388 return encapsulator;
389 }
390
391 //------------------------------------------------------------------------------------------------
395 bool GetEncapsulator(EResourceType resourceType, out SCR_ResourceEncapsulator encapsulator)
396 {
397 encapsulator = null;
398
399 if (resourceType == EResourceType.INVALID || !m_aEncapsulators)
400 return false;
401
402 int higherLimitPosition = m_aEncapsulators.Count();
403
404 if (higherLimitPosition == 0)
405 return false;
406
407 int position;
408
409 while (position < higherLimitPosition)
410 {
411 if (GetNextEncapsulatorCandidate(position, higherLimitPosition, encapsulator, resourceType))
412 break;
413 }
414
415 if (!encapsulator
416 || position == m_aEncapsulators.Count()
417 || resourceType != encapsulator.GetResourceType())
418 return false;
419
420 return true;
421 }
422
423 //------------------------------------------------------------------------------------------------
424 protected bool GetNextEncapsulatorCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceEncapsulator encapsulator, EResourceType resourceType)
425 {
426 int comparePosition = position + ((higherLimitPosition - position) >> 1);
427 encapsulator = m_aEncapsulators[comparePosition];
428
429 if (!encapsulator)
430 return null;
431
432 EResourceType compareResourceType = encapsulator.GetResourceType();
433
434 if (resourceType > compareResourceType)
435 position = comparePosition + 1;
436 else if (resourceType < compareResourceType)
437 higherLimitPosition = comparePosition;
438 else
439 {
440 encapsulator = m_aEncapsulators[comparePosition];
441
442 return true;
443 }
444
445 encapsulator = null;
446
447 return false;
448 }
449
450 //------------------------------------------------------------------------------------------------
452 array<SCR_ResourceEncapsulator> GetEncapsulators()
453 {
454 if (!m_aEncapsulators)
455 return null;
456
457 int encapsulatorCount = m_aEncapsulators.Count();
458
459 if (encapsulatorCount == 0)
460 return null;
461
462 array<SCR_ResourceEncapsulator> encapsulators = {};
463
464 encapsulators.Reserve(encapsulatorCount);
465
466 foreach (SCR_ResourceEncapsulator encapsulator: m_aEncapsulators)
467 {
468 encapsulators.Insert(encapsulator);
469 }
470
471 return encapsulators;
472 }
473
474 //------------------------------------------------------------------------------------------------
479 {
480 if (resourceType == EResourceType.INVALID || !m_aContainerInstances)
481 return null;
482
483 int higherLimitPosition = m_aContainerInstances.Count();
484
485 if (higherLimitPosition == 0)
486 return null;
487
488 int position;
489 SCR_ResourceContainer container;
490
491 while (position < higherLimitPosition)
492 {
493 if (GetNextContainerCandidate(position, higherLimitPosition, container, resourceType))
494 break;
495 }
496
497 if (!container
498 || position == m_aContainerInstances.Count()
499 || resourceType != container.GetResourceType())
500 return null;
501
502 return container;
503 }
504
505 //------------------------------------------------------------------------------------------------
510 bool GetContainer(EResourceType resourceType, out SCR_ResourceContainer container)
511 {
512 container = null;
513
514 if (resourceType == EResourceType.INVALID || !m_aContainerInstances)
515 return false;
516
517 int higherLimitPosition = m_aContainerInstances.Count();
518 if (higherLimitPosition == 0)
519 return false;
520
521 int position;
522
523 while (position < higherLimitPosition)
524 {
525 if (GetNextContainerCandidate(position, higherLimitPosition, container, resourceType))
526 break;
527 }
528
529 if (!container
530 || position == m_aContainerInstances.Count()
531 || resourceType != container.GetResourceType())
532 return false;
533
534 return true;
535 }
536
537 //------------------------------------------------------------------------------------------------
538 protected bool GetNextContainerCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceContainer container, EResourceType resourceType)
539 {
540 int comparePosition = position + ((higherLimitPosition - position) >> 1);
541 container = m_aContainerInstances[comparePosition];
542
543 if (!container)
544 return null;
545
546 EResourceType compareResourceType = container.GetResourceType();
547
548 if (resourceType > compareResourceType)
549 {
550 position = comparePosition + 1;
551 }
552 else if (resourceType < compareResourceType)
553 {
554 higherLimitPosition = comparePosition;
555 }
556 else
557 {
558 container = m_aContainerInstances[comparePosition];
559
560 return true;
561 }
562
563 container = null;
564
565 return false;
566 }
567
568 //------------------------------------------------------------------------------------------------
570 array<SCR_ResourceContainer> GetContainers()
571 {
572 int containerCount = m_aContainerInstances.Count();
573
574 if (containerCount == 0)
575 return null;
576
577 array<SCR_ResourceContainer> containers = {};
578
579 containers.Reserve(containerCount);
580
582 {
583 containers.Insert(container);
584 }
585
586 return containers;
587 }
588
589 //------------------------------------------------------------------------------------------------
593 SCR_ResourceConsumer GetConsumer(EResourceGeneratorID identifier, EResourceType resourceType)
594 {
595 if (identifier == EResourceGeneratorID.INVALID || resourceType == EResourceType.INVALID || !m_aConsumers)
596 return null;
597
598 int higherLimitPosition = m_aConsumers.Count();
599 if (higherLimitPosition == 0)
600 return null;
601
602 int position;
603 SCR_ResourceConsumer consumer;
604
605 while (position < higherLimitPosition)
606 {
607 if (GetNextConsumerCandidate(position, higherLimitPosition, consumer, identifier, resourceType))
608 break;
609 }
610
611 if (!consumer
612 || position == m_aConsumers.Count()
613 || identifier != consumer.GetGeneratorIdentifier()
614 || resourceType != consumer.GetResourceType())
615 return null;
616
617 return consumer;
618 }
619
620 //------------------------------------------------------------------------------------------------
626 bool GetConsumer(EResourceGeneratorID identifier, EResourceType resourceType, inout SCR_ResourceConsumer consumer)
627 {
628 consumer = null;
629
630 if (identifier == EResourceGeneratorID.INVALID || resourceType == EResourceType.INVALID || !m_aConsumers)
631 return false;
632
633 int higherLimitPosition = m_aConsumers.Count();
634 if (higherLimitPosition == 0)
635 return false;
636
637 int position;
638
639 while (position < higherLimitPosition)
640 {
641 if (GetNextConsumerCandidate(position, higherLimitPosition, consumer, identifier, resourceType))
642 break;
643 }
644
645 if (!consumer
646 || position == m_aConsumers.Count()
647 || identifier != consumer.GetGeneratorIdentifier()
648 || resourceType != consumer.GetResourceType())
649 return false;
650
651 return true;
652 }
653
654 //------------------------------------------------------------------------------------------------
655 protected bool GetNextConsumerCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceConsumer consumer, EResourceGeneratorID identifier, EResourceType resourceType)
656 {
657 int comparePosition = position + ((higherLimitPosition - position) >> 1);
658 consumer = m_aConsumers[comparePosition];
659
660 if (!consumer)
661 return false;
662
663 EResourceType compareResourceType = consumer.GetResourceType();
664 EResourceGeneratorID comapareIdentifier = consumer.GetGeneratorIdentifier();
665
666 if (identifier > comapareIdentifier)
667 {
668 position = comparePosition + 1;
669 }
670 else if (identifier < comapareIdentifier)
671 {
672 higherLimitPosition = comparePosition;
673 }
674 else if (resourceType > compareResourceType)
675 {
676 position = comparePosition + 1;
677 }
678 else if (resourceType < compareResourceType)
679 {
680 higherLimitPosition = comparePosition;
681 }
682 else
683 {
684 consumer = m_aConsumers[comparePosition];
685
686 return true;
687 }
688
689 consumer = null;
690
691 return false;
692 }
693
694 //------------------------------------------------------------------------------------------------
696 array<SCR_ResourceConsumer> GetConsumers()
697 {
698 int consumerCount = m_aConsumers.Count();
699 if (consumerCount == 0)
700 return null;
701
702 array<SCR_ResourceConsumer> consumers = {};
703 consumers.Reserve(consumerCount);
704
705 foreach (SCR_ResourceConsumer container: m_aConsumers)
706 {
707 consumers.Insert(container);
708 }
709
710 return consumers;
711 }
712
713 //------------------------------------------------------------------------------------------------
718 {
719 if (identifier == EResourceGeneratorID.INVALID || resourceType == EResourceType.INVALID || !m_aGenerators)
720 return null;
721
722 int higherLimitPosition = m_aGenerators.Count();
723 if (higherLimitPosition == 0)
724 return null;
725
726 int position;
727 SCR_ResourceGenerator generator;
728
729 while (position < higherLimitPosition)
730 {
731 if (GetNextGeneratorCandidate(position, higherLimitPosition, generator, identifier, resourceType))
732 break;
733 }
734
735 if (!generator
736 || position == m_aGenerators.Count()
737 || identifier != generator.GetIdentifier()
738 || resourceType != generator.GetResourceType())
739 return null;
740
741 return generator;
742 }
743
744 //------------------------------------------------------------------------------------------------
749 bool GetGenerator(EResourceGeneratorID identifier, EResourceType resourceType, out SCR_ResourceGenerator generator)
750 {
751 generator = null;
752
753 if (identifier == EResourceGeneratorID.INVALID || resourceType == EResourceType.INVALID || !m_aGenerators)
754 return false;
755
756 int higherLimitPosition = m_aGenerators.Count();
757 if (higherLimitPosition == 0)
758 return false;
759
760 int position;
761
762 while (position < higherLimitPosition)
763 {
764 if (GetNextGeneratorCandidate(position, higherLimitPosition, generator, identifier, resourceType))
765 break;
766 }
767
768 if (!generator
769 || position == m_aGenerators.Count()
770 || identifier != generator.GetIdentifier()
771 || resourceType != generator.GetResourceType())
772 return false;
773
774 return true;
775 }
776
777 //------------------------------------------------------------------------------------------------
778 protected bool GetNextGeneratorCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceGenerator generator, EResourceGeneratorID identifier, EResourceType resourceType)
779 {
780 int comparePosition = position + ((higherLimitPosition - position) >> 1);
781 generator = m_aGenerators[comparePosition];
782
783 if (!generator)
784 return false;
785
786 EResourceType compareResourceType = generator.GetResourceType();
787 EResourceGeneratorID comapareIdentifier = generator.GetIdentifier();
788
789 if (identifier > comapareIdentifier)
790 {
791 position = comparePosition + 1;
792 }
793 else if (identifier < comapareIdentifier)
794 {
795 higherLimitPosition = comparePosition;
796 }
797 else if (resourceType > compareResourceType)
798 {
799 position = comparePosition + 1;
800 }
801 else if (resourceType < compareResourceType)
802 {
803 higherLimitPosition = comparePosition;
804 }
805 else
806 {
807 generator = m_aGenerators[comparePosition];
808
809 return true;
810 }
811
812 generator = null;
813
814 return false;
815 }
816
817 //------------------------------------------------------------------------------------------------
821 array<SCR_ResourceGenerator> GetGenerators()
822 {
823 int generatorCount = m_aGenerators.Count();
824
825 if (generatorCount == 0)
826 return null;
827
828 array<SCR_ResourceGenerator> generators = {};
829
830 generators.Reserve(generatorCount);
831
832 foreach (SCR_ResourceGenerator generator: m_aGenerators)
833 {
834 generators.Insert(generator);
835 }
836
837 return generators;
838 }
839
840 //------------------------------------------------------------------------------------------------
843 {
844 return m_iGridUpdateId;
845 }
846
847 //------------------------------------------------------------------------------------------------
850 {
851 return m_LastPosition;
852 }
853
854 //------------------------------------------------------------------------------------------------
857 {
858 return m_bHasParent;
859 }
860
861 //------------------------------------------------------------------------------------------------
864 {
865 return Color.FromInt(m_DebugColor.PackToInt());
866 }
867
868 //------------------------------------------------------------------------------------------------
871 bool IsGridUpdateIdGreaterThan(int gridUpdateId)
872 {
873 return m_iGridUpdateId > gridUpdateId;
874 }
875
876 //------------------------------------------------------------------------------------------------
882
883 //------------------------------------------------------------------------------------------------
886 {
887 return m_bIsVisible;
888 }
889
890 //------------------------------------------------------------------------------------------------
893 {
894 return m_bIsOwnerActive;
895 }
896
897 //------------------------------------------------------------------------------------------------
899 {
900 return m_aConsumers != null;
901 }
902
903 //------------------------------------------------------------------------------------------------
905 {
906 return m_aGenerators != null;
907 }
908
909 //------------------------------------------------------------------------------------------------
911 void SetGridUpdateId(int gridUpdateId)
912 {
913 if (m_iGridUpdateId > gridUpdateId)
914 return;
915
916 m_iGridUpdateId = gridUpdateId;
917 }
918
919 //------------------------------------------------------------------------------------------------
921 void SetIsVisible(bool state)
922 {
923 m_bIsVisible = state;
924 m_bIsNetDirty = true;
925
926 ReplicateEx();
928 }
929
930 //------------------------------------------------------------------------------------------------
933 {
935 }
936
937 //------------------------------------------------------------------------------------------------
940 {
942 }
943
944 //------------------------------------------------------------------------------------------------
947 void SetGridContainersBounds(int mins, int maxs)
948 {
951 }
952
953 //------------------------------------------------------------------------------------------------
959
960 //------------------------------------------------------------------------------------------------
963 {
965 return;
966
967 GetGame().GetResourceGrid().FlagResourceItem(this);
968
970 }
971
972 //------------------------------------------------------------------------------------------------
975 {
977 return;
978
979 GetGame().GetResourceGrid().UnflagResourceItem(this);
980
982 }
983
984 //------------------------------------------------------------------------------------------------
987 {
988 if (!m_aConsumers)
989 return;
990
991 delete m_aConsumers;
992 }
993
994 //------------------------------------------------------------------------------------------------
997 {
998 if (!m_aGenerators)
999 return;
1000
1001 delete m_aGenerators;
1002 }
1003
1004 //------------------------------------------------------------------------------------------------
1007 {
1008 delete m_aConsumers;
1009 delete m_aGenerators;
1010 }
1011
1012 //------------------------------------------------------------------------------------------------
1016 override event protected void OnPostInit(IEntity owner)
1017 {
1018 super.OnPostInit(owner);
1019 Initialize(owner);
1020 SetEventMask(owner, EntityEvent.INIT);
1021
1022 //~ Remove any duplicate entries
1023 if (m_aDisabledResourceTypes.IsEmpty())
1024 {
1025 //~ TODO: Make this cleaner
1026
1027 set<EResourceType> duplicateRemoveSet = new set<EResourceType>();
1028
1029 foreach (EResourceType resourceType : m_aDisabledResourceTypes)
1030 {
1031 duplicateRemoveSet.Insert(resourceType);
1032 }
1033
1035 foreach (EResourceType resourceType : duplicateRemoveSet)
1036 {
1037 m_aDisabledResourceTypes.Insert(resourceType);
1038 }
1039 }
1040 }
1041
1042 //------------------------------------------------------------------------------------------------
1045 void Initialize(notnull IEntity owner)
1046 {
1047 if (m_bIsInitialized)
1048 return;
1049
1050 //The replication component is a must, as the authority is the only one allowed to perform an update on the container and/or consumer.
1051 m_ReplicationComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
1052 FactionAffiliationComponent factionAffiliationComponentTemp;
1053 IEntity parentEntity = owner.GetParent();
1054
1055 while (parentEntity)
1056 {
1057 factionAffiliationComponentTemp = FactionAffiliationComponent.Cast(parentEntity.FindComponent(FactionAffiliationComponent));
1058
1059 if (factionAffiliationComponentTemp)
1060 m_FactionAffiliationComponent = factionAffiliationComponentTemp;
1061
1062 parentEntity = parentEntity.GetParent();
1063 }
1064
1065 // In the case that no parent has a faction affiliation component, then get the owner's.
1067 m_FactionAffiliationComponent = FactionAffiliationComponent.Cast(owner.FindComponent(FactionAffiliationComponent));
1068
1069 Physics physics = owner.GetPhysics();
1070 vector tempBoundsMaxs, tempBoundsMins;
1071
1072 // ---------------------------------------------------------------- Container initialisation.
1073 // The container is configured through SCR_ResourceComponentClass.
1074 // Note: Order matters, containers should be processed first for the optimization on when the self resource right is enabled on them.
1076
1077 if (prefabData)
1078 {
1079 // Container instances holding the initial configuration for this component instance's containers.
1080 array<ref SCR_ResourceContainer> containers = prefabData.GetContainers();
1081
1082 if (containers)
1083 {
1084 SCR_ResourceContainer containerInstance;
1085 typename containerInstanceTypename;
1086
1087 m_aContainerInstances.Reserve(containers.Count());
1088
1089 foreach (SCR_ResourceContainer container: containers)
1090 {
1091 containerInstanceTypename = container.Type();
1092
1093 containerInstance = SCR_ResourceContainer.Cast(containerInstanceTypename.Spawn());
1094
1095 // The copying of the container configuration in the prefab data happens here.
1096 containerInstance.Initialize(owner, container);
1097
1098 int maxPosition = m_aContainerInstances.Count();
1099 int position;
1100 EResourceType resourceType = container.GetResourceType();
1101 EResourceType compareResourceType;
1102 int comparePosition;
1103 SCR_ResourceContainer compareContainer;
1104
1105 while (position < maxPosition)
1106 {
1107 comparePosition = position + ((maxPosition - position) >> 1);
1108 compareContainer = m_aContainerInstances[comparePosition];
1109 compareResourceType = compareContainer.GetResourceType();
1110
1111 if (resourceType > compareResourceType)
1112 position = comparePosition + 1;
1113
1114 else if (resourceType < compareResourceType)
1115 maxPosition = comparePosition;
1116
1117 else
1118 break;
1119 }
1120
1121 // Clean container instance to copy the prefab container configuration to.
1122 m_aContainerInstances.InsertAt(containerInstance, position);
1123
1124 if (container.IsIsolated())
1125 continue;
1126
1127 containerInstance.GetAxisAlignedBoundingVolume(tempBoundsMins, tempBoundsMaxs);
1128 }
1129
1130 m_vGridContainersBoundingVolumeMaxs = tempBoundsMaxs;
1131 m_vGridContainersBoundingVolumeMins = tempBoundsMins;
1132 }
1133 }
1134
1135 // ------------------------------------------------------------- Encapsulator initialization.
1136 if (m_aEncapsulators)
1137 {
1138 array<ref SCR_ResourceEncapsulator> encapsulators = {};
1139 encapsulators.Reserve(m_aEncapsulators.Count());
1140
1141 foreach (SCR_ResourceEncapsulator encapsulator: m_aEncapsulators)
1142 {
1143 encapsulator.Initialize(owner);
1144
1145 int position;
1146 int maxPosition = encapsulators.Count();
1147 EResourceType resourceType = encapsulator.GetResourceType();
1148 EResourceType compareResourceType;
1149 int comparePosition;
1150 SCR_ResourceEncapsulator compareEncapsulator;
1151
1152 while (position < maxPosition)
1153 {
1154 comparePosition = position + ((maxPosition - position) >> 1);
1155 compareEncapsulator = encapsulators[comparePosition];
1156 compareResourceType = compareEncapsulator.GetResourceType();
1157
1158 if (resourceType > compareResourceType)
1159 position = comparePosition + 1;
1160
1161 else if (resourceType < compareResourceType)
1162 maxPosition = comparePosition;
1163
1164 else
1165 break;
1166 }
1167
1168 encapsulators.InsertAt(encapsulator, position);
1169 }
1170
1171 m_aEncapsulators = encapsulators;
1172 }
1173
1174 // ----------------------------------------------------------------- Consumer initialization.
1175 if (m_aConsumers)
1176 {
1177 array<ref SCR_ResourceConsumer> consumers = {};
1178 consumers.Reserve(m_aConsumers.Count());
1179
1180 foreach (SCR_ResourceConsumer consumer: m_aConsumers)
1181 {
1182 SCR_ResourceContainer container = GetContainer(consumer.GetResourceType());
1183
1184 if (container && container.IsEncapsulated())
1185 continue;
1186
1187 consumer.Initialize(owner);
1188
1189 int position;
1190 int maxPosition = consumers.Count();
1191 EResourceGeneratorID generatorIdentifier = consumer.GetGeneratorIdentifier();
1192 EResourceGeneratorID compareGeneratorIdentifier;
1193 EResourceType resourceType = consumer.GetResourceType();
1194 EResourceType compareResourceType;
1195 int comparePosition;
1196 SCR_ResourceConsumer compareConsumer;
1197
1198 while (position < maxPosition)
1199 {
1200 comparePosition = position + ((maxPosition - position) >> 1);
1201 compareConsumer = consumers[comparePosition];
1202 compareGeneratorIdentifier = compareConsumer.GetGeneratorIdentifier();
1203 compareResourceType = compareConsumer.GetResourceType();
1204
1205 if (generatorIdentifier > compareGeneratorIdentifier)
1206 position = comparePosition + 1;
1207 else if (generatorIdentifier < compareGeneratorIdentifier)
1208 maxPosition = comparePosition;
1209 else if (resourceType > compareResourceType)
1210 position = comparePosition + 1;
1211 else if (resourceType < compareResourceType)
1212 maxPosition = comparePosition;
1213 else
1214 break;
1215 }
1216
1217 consumers.InsertAt(consumer, position);
1218 }
1219
1220 m_aConsumers = consumers;
1221 }
1222
1223 // ---------------------------------------------------------------- Generator initialization.
1224 if (m_aGenerators)
1225 {
1226 array<ref SCR_ResourceGenerator> generators = {};
1227 generators.Reserve(m_aGenerators.Count());
1228
1229 foreach (SCR_ResourceGenerator generator: m_aGenerators)
1230 {
1231 SCR_ResourceContainer container = GetContainer(generator.GetResourceType());
1232
1233 if (container && container.IsEncapsulated())
1234 continue;
1235
1236 generator.Initialize(owner);
1237
1238 int position;
1239 int maxPosition = generators.Count();
1240 EResourceGeneratorID identifier = generator.GetIdentifier();
1241 EResourceGeneratorID comapareIdentifier;
1242 EResourceType resourceType = generator.GetResourceType();
1243 EResourceType compareResourceType;
1244 int comparePosition;
1245 SCR_ResourceGenerator compareGenerator;
1246
1247 while (position < maxPosition)
1248 {
1249 comparePosition = position + ((maxPosition - position) >> 1);
1250 compareGenerator = generators[comparePosition];
1251 comapareIdentifier = compareGenerator.GetIdentifier();
1252 compareResourceType = compareGenerator.GetResourceType();
1253
1254 if (identifier > comapareIdentifier)
1255 position = comparePosition + 1;
1256 else if (identifier < comapareIdentifier)
1257 maxPosition = comparePosition;
1258 else if (resourceType > compareResourceType)
1259 position = comparePosition + 1;
1260 else if (resourceType < compareResourceType)
1261 maxPosition = comparePosition;
1262 else
1263 break;
1264 }
1265
1266 generators.InsertAt(generator, position);
1267 }
1268
1269 m_aGenerators = generators;
1270 }
1271
1274
1275 Vehicle vehicle = Vehicle.Cast(GetOwner());
1276
1277 if (vehicle)
1278 vehicle.GetOnPhysicsActive().Insert(OnVehiclePhysicsActive);
1279
1280 m_bIsInitialized = true;
1281
1282 Replicate();
1283 }
1284
1285 //------------------------------------------------------------------------------------------------
1289 override event protected void OnChildAdded(IEntity parent, IEntity child)
1290 {
1291 SCR_ResourceComponent childResourceComponent = SCR_ResourceComponent.Cast(child.FindComponent(SCR_ResourceComponent));
1292 if (!childResourceComponent)
1293 return;
1294
1296 }
1297
1298 //------------------------------------------------------------------------------------------------
1301 override event protected void EOnInit(IEntity owner)
1302 {
1303 SCR_ResourceContainer container;
1305
1306 foreach (SCR_ResourceEncapsulator encapsulator: m_aEncapsulators)
1307 {
1308 queue = encapsulator.GetContainerQueue();
1309
1310 for (int i = queue.GetContainerCount() - 1; i >= 0; --i)
1311 {
1312 container = queue.GetContainerAt(i);
1313
1314 if (container.GetResourceValue() == 0.0 && GetGame().GetWorld() && !GetGame().GetWorld().IsEditMode() && container.GetOnEmptyBehavior() == EResourceContainerOnEmptyBehavior.HIDE)
1315 container.GetComponent().SetIsVisible(false);
1316 }
1317 }
1318
1319 bool isCompletelyIsolated = true;
1320
1321 for (int i = m_aContainerInstances.Count() - 1; i >= 0; --i)
1322 {
1323 container = m_aContainerInstances[i];
1324 isCompletelyIsolated &= container.IsIsolated();
1325 }
1326
1327 if (isCompletelyIsolated)
1328 {
1330
1331 return;
1332 }
1333
1334 Vehicle vehicle = Vehicle.Cast(GetOwner().GetRootParent());
1335 if (vehicle)
1336 vehicle.GetOnPhysicsActive().Insert(OnVehiclePhysicsActive);
1337
1339 }
1340
1341 //------------------------------------------------------------------------------------------------
1349 protected void DebugDraw()
1350 {
1351 // Height for the white arrow.
1352 float height;
1353
1354 // The white arrow will point to this position, the origin of the owner entity in this case.
1355 vector origin = GetOwner().GetOrigin();
1356
1357 // TODO: Cache the height value and only change it on a event basis.
1359 {
1360 foreach (SCR_ResourceConsumer consumer: m_aConsumers)
1361 {
1362 // Processes and presents the debugging visualization for the consumer.
1363 consumer.DebugDraw();
1364
1365 // Sets the height of the arrow to be the same as the consumer resource range if the current height is less than it.
1366 height = Math.Max(height, consumer.GetResourceRange());
1367 }
1368 }
1369
1372 {
1373 foreach (SCR_ResourceEncapsulator encapsulator: m_aEncapsulators)
1374 {
1376 encapsulator.DebugDraw();
1377 }
1378 }
1379
1380 // TODO: Cache the height value and only change it on a event basis.
1382 {
1383 foreach (SCR_ResourceGenerator generator: m_aGenerators)
1384 {
1385 // Processes and presents the debugging visualisation for the generator.
1386 generator.DebugDraw();
1387
1388 // Sets the height of the arrow to be the same as the generator resource range if the current height is less than it.
1389 height = Math.Max(height, generator.GetStorageRange());
1390 }
1391 }
1392
1393 // TODO: Cache the height value and only change it on a event basis.
1395 {
1396 foreach (SCR_ResourceContainer container: m_aContainerInstances)
1397 {
1398 // Processes and presents the debugging visualisation for the container.
1399 container.DebugDraw();
1400
1401 // Sets the height of the arrow to be the same as the container storage range if the
1402 // current height (Same as resource range of the consumer if a consumer is present on the
1403 // component or 0.0 otherwise) is less than it.
1404 //height = Math.Max(height, container.GetStorageRange());
1405 }
1406 }
1407
1409 Shape.CreateArrow((origin + vector.Up * height), origin, 1.0, 0xFFFFFFFF, ShapeFlags.ONCE | ShapeFlags.NOZBUFFER);
1410 }
1411
1412 //------------------------------------------------------------------------------------------------
1415 {
1417 return;
1418
1419 m_bIsNetDirty = true;
1420 }
1421
1422 //------------------------------------------------------------------------------------------------
1428 {
1429 if (!m_bIsNetDirty)
1430 return;
1431
1432 Replication.BumpMe();
1433
1434 m_bIsNetDirty = false;
1435
1437 }
1438
1439#ifdef WORKBENCH
1440 override int _WB_GetAfterWorldUpdateSpecs(IEntity owner, IEntitySource src)
1441 {
1442 return EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE;
1443 }
1444
1445 //------------------------------------------------------------------------------------------------
1450 override event void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
1451 {
1453 DebugDraw();
1454
1455 super._WB_AfterWorldUpdate(timeSlice);
1456 }
1457
1458 //------------------------------------------------------------------------------------------------
1460 override event bool _WB_OnKeyChanged(IEntity owner, BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
1461 {
1462 SCR_ResourceGrid grid = GetGame().GetResourceGrid();
1463
1464 if (m_aConsumers)
1465 {
1466 foreach (SCR_ResourceConsumer consumer: m_aConsumers)
1467 {
1468 consumer.GetContainerQueue().Clear();
1469 }
1470 }
1471
1472 if (m_aGenerators)
1473 {
1474 foreach (SCR_ResourceGenerator generator: m_aGenerators)
1475 {
1476 generator.GetContainerQueue().Clear();
1477 }
1478 }
1479
1480 grid.IncreaseGridUpdateId();
1481 grid.UnregisterResourceItem(this);
1482
1483 return super._WB_OnKeyChanged(owner, src, key, ownerContainers, parent);
1484 }
1485#endif
1486
1487 //------------------------------------------------------------------------------------------------
1489 {
1490 IEntity owner = GetOwner();
1491
1492 if (m_bIsVisible)
1493 {
1494 owner.SetFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE, true);
1495 SCR_PhysicsHelper.ChangeSimulationState(owner, SimulationState.COLLISION, true);
1496
1497 return;
1498 }
1499
1500 owner.ClearFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE, true);
1501 SCR_PhysicsHelper.ChangeSimulationState(owner, SimulationState.NONE, true);
1502 }
1503
1504 //------------------------------------------------------------------------------------------------
1505 override event protected void OnAddedToParent(IEntity child, IEntity parent)
1506 {
1508 return;
1509
1510 if (m_bIsInitialized)
1511 OnAddedToParentEx(child, parent);
1512 else
1514 }
1515
1516 //------------------------------------------------------------------------------------------------
1517 protected void OnAddedToParentEx(IEntity child, IEntity parent)
1518 {
1519 foreach (SCR_ResourceContainer container: m_aContainerInstances)
1520 {
1521 if (!container || container.GetStorageType() != EResourceContainerStorageType.ORPHAN)
1522 continue;
1523
1524 container.EnableDecay(false);
1525 }
1526
1528 m_bHasParent = true;
1529 bool isCompletelyIsolated = true;
1530
1531 foreach (SCR_ResourceContainer container: m_aContainerInstances)
1532 {
1533 isCompletelyIsolated &= container.IsEncapsulated();
1534 }
1535
1536 if (isCompletelyIsolated)
1537 return;
1538
1539 Vehicle vehicle = Vehicle.Cast(GetOwner().GetRootParent());
1540
1541 if (!vehicle)
1542 return;
1543
1544 vehicle.GetOnPhysicsActive().Insert(OnVehiclePhysicsActive);
1545 }
1546
1547 //------------------------------------------------------------------------------------------------
1548 override event protected void OnRemovedFromParent(IEntity child, IEntity parent)
1549 {
1551 return;
1552
1553 m_bHasParent = false;
1554
1555 foreach (SCR_ResourceContainer container: m_aContainerInstances)
1556 {
1557 if (!container || container.GetStorageType() != EResourceContainerStorageType.ORPHAN)
1558 continue;
1559
1560 container.EnableDecay(true);
1561 }
1562 }
1563
1564 //------------------------------------------------------------------------------------------------
1567 void OnVehiclePhysicsActive(IEntity owner, bool activeState)
1568 {
1569 ChimeraWorld world = ChimeraWorld.CastFrom(GetGame().GetWorld());
1570 if (!world)
1571 return;
1572
1573 SCR_ResourceSystem updateSystem = SCR_ResourceSystem.Cast(world.FindSystem(SCR_ResourceSystem));
1574
1575 m_bIsOwnerActive = activeState;
1576 }
1577
1578 //------------------------------------------------------------------------------------------------
1579 override event protected void OnDelete(IEntity owner)
1580 {
1582
1583 ArmaReforgerScripted game = GetGame();
1584 if (!game)
1585 return;
1586
1587 ChimeraWorld world = ChimeraWorld.CastFrom(game.GetWorld());
1588 if (!world)
1589 return;
1590
1591 SCR_ResourceGrid grid = GetGame().GetResourceGrid();
1592
1593 grid.IncreaseGridUpdateId();
1594 grid.UnregisterResourceItem(this);
1595
1596 SCR_ResourceSystem updateSystem = SCR_ResourceSystem.Cast(world.FindSystem(SCR_ResourceSystem));
1597 if (!updateSystem)
1598 return;
1599
1600 delete m_aConsumers;
1601 delete m_aGenerators;
1602 delete m_aEncapsulators;
1603 delete m_aContainerInstances;
1604 }
1605}
ref DSGameConfig game
Definition DSConfig.c:81
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
void TEMP_OnInteractorReplicated()
FactionAffiliationComponent m_FactionAffiliationComponent
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
override void OnChildAdded(IEntity parent, IEntity child)
const float UPDATE_PERIOD
SCR_CharacterSoundComponentClass GetComponentData()
override bool _WB_OnKeyChanged(IEntity owner, BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
Any property value has been changed. You can use editor API here and do some additional edit actions ...
vector position
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_EditableEntityVehicleCompartmentVisibilityChildComponentClass SCR_EditableEntityVisibilityChildComponentClass OnAddedToParent(IEntity child, IEntity parent)
Faction GetParent()
bool m_bIsVisible
void SetGridContainersBoundsMins(int mins)
bool m_bEnableDebugVisualization
Setting for enabling the debugging visualization of the container and/or consumer.
RplComponent m_ReplicationComponent
Replication component attached to the owner entity.
void DeleteConsumers()
bool IsDebugVisualizationEnabled()
void OnRemovedFromParent(IEntity child, IEntity parent)
ref array< EResourceType > m_aDisallowChangingEnableResource
void SetGridUpdateId(int gridUpdateId)
EResourceDebugVisualizationFlags
ref array< ref SCR_ResourceConsumer > m_aConsumers
Refer to SCR_ResourceConsumer for documentation.
ref array< ref SCR_ResourceGenerator > m_aGenerators
Refer to SCR_ResourceGenerator for documentation.
void Replicate()
ScriptInvoker TEMP_GetOnInteractorReplicated()
HOTFIX: Until replication issues are resolved.
SCR_ResourceConsumer GetConsumer(EResourceGeneratorID identifier, EResourceType resourceType)
void DeleteGenerators()
int m_iGridContainersBoundsMins
bool GetNextConsumerCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceConsumer consumer, EResourceGeneratorID identifier, EResourceType resourceType)
bool m_bIsOwnerActive
void OnAddedToParentEx(IEntity child, IEntity parent)
void SetGridContainersBoundsMaxs(int maxs)
FactionAffiliationComponent GetFactionAffiliationComponent()
const float UPDATE_DISTANCE_TRESHOLD_SQUARE
bool IsGridUpdateIdGreaterThan(int gridUpdateId)
bool m_bIsFlaggedForProcessing
void OnVisibilityChanged()
int m_iGridUpdateId
vector m_vGridContainersBoundingVolumeMaxs
int GetDisabledResourceTypes(inout notnull array< EResourceType > disabledResourceTypes)
vector m_vGridContainersBoundingVolumeMins
ref array< ref SCR_ResourceEncapsulator > m_aEncapsulators
Refer to SCR_ResourceEncapsulator for documentation.
void DeleteQueryInteractors()
void GetGridContainersWorldBoundingBox(out vector mins, out vector maxs)
ref array< ref SCR_ResourceContainer > m_aContainerInstances
void SetResourceTypeEnabled(bool enable, EResourceType resourceType=EResourceType.SUPPLIES)
ref ScriptInvoker m_TEMP_OnInteractorReplicated
HOTFIX: Until replication issues are resolved.
ref Color m_DebugColor
Setting for the base color for the debugging visualization of the container and/or consumer.
bool m_bIsNetDirty
bool m_bHasParent
bool GetNextGeneratorCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceGenerator generator, EResourceGeneratorID identifier, EResourceType resourceType)
int GetGridContainersBoundsMins()
void FlagForProcessing()
int GetGridUpdateId()
void OnVehiclePhysicsActive(IEntity owner, bool activeState)
bool IsResourceTypeEnabled(EResourceType resourceType=EResourceType.SUPPLIES)
func SCR_Resources_OnResourceEnabledChanged
bool GetNextContainerCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceContainer container, EResourceType resourceType)
SCR_ResourceGenerator GetGenerator(EResourceGeneratorID identifier, EResourceType resourceType)
void DebugDraw()
ref ScriptInvokerBase< SCR_Resources_OnResourceEnabledChanged > m_OnResourceTypeEnabledChanged
void SetIsVisible(bool state)
array< SCR_ResourceContainer > GetContainers()
bool IsOwnerActive()
bool CanBeUsedByCharacter(notnull SCR_ChimeraCharacter character)
RplComponent GetReplicationComponent()
void UnflagForProcessing()
bool ShouldGeneratorsBeReplicated()
SCR_ResourceContainer GetContainer(EResourceType resourceType)
ScriptInvokerBase< SCR_Resources_OnResourceEnabledChanged > GetOnResourceTypeEnabledChanged()
int m_iGridContainersBoundsMaxs
bool HasParent()
SCR_ResourceEncapsulator GetEncapsulator(EResourceType resourceType)
ref array< EResourceType > m_aDisabledResourceTypes
void SetGridContainersBounds(int mins, int maxs)
vector m_LastPosition
Color GetDebugColor()
int GetGridContainersBoundsMaxs()
void GetGridContainersBoundingBox(out vector mins, out vector maxs)
bool GetNextEncapsulatorCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceEncapsulator encapsulator, EResourceType resourceType)
array< SCR_ResourceEncapsulator > GetEncapsulators()
bool m_bIsAddedToParentBuffered
bool CanResourceTypeEnabledBeChanged(EResourceType resourceType=EResourceType.SUPPLIES)
array< SCR_ResourceGenerator > GetGenerators()
bool ShouldConsumersBeReplicated()
void ReplicateEx()
SCR_ResourceComponentClass UPDATE_DISTANCE_TRESHOLD
array< SCR_ResourceConsumer > GetConsumers()
void OnResourceTypeEnabledChanged()
void GetGridContainersBounds(out int mins, out int maxs)
bool m_bIsInitialized
void UpdateLastPosition()
Updates the serial number for the current processing call of the resource grid onto this component.
vector GetLastPosition()
bool IsVisible()
EResourceDebugVisualizationFlags m_eDebugVisualizationFlags
Flags for enabling the debugging visualization.
EResourceContainerStorageType
EResourceContainerOnEmptyBehavior
EResourceGeneratorID
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void GetChildren(out array< SCR_ScenarioFrameworkLayerBase > children)
enum EVehicleType IEntity
Definition Color.c:13
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
proto external IEntity GetParent()
proto external EntityFlags ClearFlags(EntityFlags flags, bool recursively=false)
Definition Math.c:13
Main replication API.
Definition Replication.c:14
sealed bool IsMaster()
array< ref SCR_ResourceContainer > GetContainers()
ref array< ref SCR_ResourceContainer > m_aContainers
static override array< typename > Requires(IEntityComponentSource src)
void Initialize(notnull IEntity owner, notnull SCR_ResourceContainer container)
EResourceContainerOnEmptyBehavior GetOnEmptyBehavior()
void GetAxisAlignedBoundingVolume(inout vector mins, inout vector maxs)
SCR_ResourceContainer GetContainerAt(int index)
override EResourceGeneratorID GetIdentifier()
void UnregisterResourceItem(notnull SCR_ResourceComponent item)
Instance of created debug visualizer.
Definition Shape.c:14
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
ShapeFlags
Definition ShapeFlags.c:13
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EntityFlags
Various entity flags.
Definition EntityFlags.c:14
SimulationState
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134