Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ResourceComponent.c
Go to the documentation of this file.
2 {
3  CONSUMER = 1 << 0,
4  CONTAINER = 1 << 1,
5  GENERATOR = 1 << 2,
6  ENCAPSULATOR = 1 << 3,
7 }
8 
9 //~ ScriptInvokers
10 void SCR_Resources_OnResourceEnabledChanged(SCR_ResourceComponent resourceComponent, array<EResourceType> disabledResourceTypes);
12 
15 [ComponentEditorProps(category: "GameScripted/Resources", description: "")]
16 class SCR_ResourceComponentClass : ScriptComponentClass
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 
43 class 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_bIsDynamic;
49  protected bool m_bIsNetDirty;
50  protected int m_iGridUpdateId = int.MIN;
51 
52  protected int m_iGridContainersBoundsMins = 0xFFFFFFFF;
53  protected int m_iGridContainersBoundsMaxs = 0xFFFFFFFF;
56 
57  protected bool m_bIsFlaggedForProcessing;
58 
60  [Attribute(uiwidget: UIWidgets.Object, category: "Encapsulators")]
61  protected ref array<ref SCR_ResourceEncapsulator> m_aEncapsulators;
62 
64  [Attribute(uiwidget: UIWidgets.Object, category: "Consumers"), RplProp(onRplName: "TEMP_OnInteractorReplicated")]
65  protected ref array<ref SCR_ResourceConsumer> m_aConsumers;
66 
68  [Attribute(uiwidget: UIWidgets.Object, category: "Generators"), RplProp(onRplName: "TEMP_OnInteractorReplicated")]
69  protected ref array<ref SCR_ResourceGenerator> m_aGenerators;
70 
71  //~ Any Resource Types that is set here is a disabled resource type
72  [Attribute(desc: "List of all disabled resource types", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EResourceType)), RplProp(onRplName: "OnResourceTypeEnabledChanged")]
73  protected ref array<EResourceType> m_aDisabledResourceTypes;
74 
75  //~ Any ResourceType that is set here cannot be enabled or disabled in runtime for this entity by editor
76  [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))]
77  protected ref array<EResourceType> m_aDisallowChangingEnableResource;
78 
80  protected ref ScriptInvoker m_TEMP_OnInteractorReplicated;
81 
82  protected ref ScriptInvokerBase<SCR_Resources_OnResourceEnabledChanged> m_OnResourceTypeEnabledChanged;
83 
84  //------------------------------------------------------------------------------------------------
87  {
89  m_TEMP_OnInteractorReplicated = new ScriptInvoker();
90 
92  }
93 
94  //------------------------------------------------------------------------------------------------
97  {
100  }
101 
103  [Attribute(uiwidget: UIWidgets.CheckBox, category: "Debugging")]
105 
107  [Attribute(defvalue: "-1", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EResourceDebugVisualizationFlags), category: "Debugging")]
109 
111  [Attribute(defvalue: "0.4 0.0 0.467 0.267 ", uiwidget: UIWidgets.ColorPicker, category: "Debugging")]
112  protected ref Color m_DebugColor;
113 
114  [RplProp(onRplName: "OnVisibilityChanged")]
115  protected bool m_bIsVisible = true;
116 
119  protected ref array<ref SCR_ResourceContainer> m_aContainerInstances = {};
120 
122  protected RplComponent m_ReplicationComponent;
123  protected FactionAffiliationComponent m_FactionAffiliationComponent;
124 
125  protected vector m_LastPosition = vector.Zero;
126  protected bool m_bHasParent;
127  protected bool m_bIsOwnerActive;
128 
129  // TODO: Remove after fixing initialisation and hierarchy issues.
130  protected bool m_bIsInitialized;
131 
132  // TODO: Remove after fixing initialisation and hierarchy issues.
134 
135  //------------------------------------------------------------------------------------------------
138  bool IsResourceTypeEnabled(EResourceType resourceType = EResourceType.SUPPLIES)
139  {
140  if (!SCR_ResourceSystemHelper.IsGlobalResourceTypeEnabled(resourceType))
141  return false;
142 
143  return !m_aDisabledResourceTypes.Contains(resourceType);
144  }
145 
146  //------------------------------------------------------------------------------------------------
149  int GetDisabledResourceTypes(inout notnull array<EResourceType> disabledResourceTypes)
150  {
151  disabledResourceTypes.Copy(m_aDisabledResourceTypes);
152  return disabledResourceTypes.Count();
153  }
154 
155  //------------------------------------------------------------------------------------------------
159  {
160  return !m_aDisallowChangingEnableResource.Contains(resourceType);
161  }
162 
163  //------------------------------------------------------------------------------------------------
167  void SetResourceTypeEnabled(bool enable, EResourceType resourceType = EResourceType.SUPPLIES)
168  {
169  if (!CanResourceTypeEnabledBeChanged(resourceType))
170  return;
171 
172  int index = m_aDisabledResourceTypes.Find(resourceType);
173 
174  //~ Already Enabled/Disabled
175  if ((index < 0) == enable)
176  return;
177 
178  if (!enable)
179  m_aDisabledResourceTypes.Insert(resourceType);
180  else
182 
183  Replication.BumpMe();
184 
185  //~ Enable/Disable resource type for all encapsulated resourceComponents
186  /*array<SCR_ResourceEncapsulator> encapsulators = GetEncapsulators();
187  SCR_ResourceComponent resourceComponent;
188  foreach (SCR_ResourceEncapsulator encapsulator : encapsulators)
189  {
190  resourceComponent = encapsulator.GetComponent();
191  if (!resourceComponent || !resourceComponent.CanResourceTypeEnabledBeChanged(resourceType))
192  continue;
193 
194  resourceComponent.SetResourceTypeEnabled(enable, resourceType);
195  }*/
196 
198  if ((gameMode && gameMode.IsMaster()) || (!gameMode && Replication.IsServer()))
200  }
201 
202  //------------------------------------------------------------------------------------------------
204  {
207  }
208 
209  //------------------------------------------------------------------------------------------------
211  ScriptInvokerBase<SCR_Resources_OnResourceEnabledChanged> GetOnResourceTypeEnabledChanged()
212  {
214  m_OnResourceTypeEnabledChanged = new ScriptInvokerBase<SCR_Resources_OnResourceEnabledChanged>();
215 
217  }
218 
219  //------------------------------------------------------------------------------------------------
224  static SCR_ResourceComponent FindResourceComponent(IEntity entity, bool ignoreChildIfHasStorage = false)
225  {
226  //~ Function is used in many places. Not all can guarantee that entity is not null
227  if (!entity)
228  return null;
229 
230  //~ Get resource component
231  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(entity.FindComponent(SCR_ResourceComponent));
232  if (resourceComponent)
233  return resourceComponent;
234 
235  //~ 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
236  if (Vehicle.Cast(entity))
237  {
238  SlotManagerComponent slotManager = SlotManagerComponent.Cast(entity.FindComponent(SlotManagerComponent));
239  if (!slotManager)
240  return null;
241 
242  array<EntitySlotInfo> outSlotInfos = {};
243  slotManager.GetSlotInfos(outSlotInfos);
244  IEntity slot;
245 
246  foreach (EntitySlotInfo slotInfo : outSlotInfos)
247  {
248  slot = slotInfo.GetAttachedEntity();
249 
250  if (!slot)
251  continue;
252 
253  resourceComponent = SCR_ResourceComponent.Cast(slot.FindComponent(SCR_ResourceComponent));
254  if (resourceComponent)
255  {
256  //~ It does not care if the slotted entity has a storage or not
257  if (!ignoreChildIfHasStorage)
258  return resourceComponent;
259 
260  //~ Has no storage so this is a valid resource component
261  if (!slot.FindComponent(ScriptedBaseInventoryStorageComponent))
262  return resourceComponent;
263  }
264  }
265  }
266  //~ Check if parent is vehicle than get resource component from parent or any other slot
267  else if (Vehicle.Cast(entity.GetParent()))
268  {
269  InventoryItemComponent inventoryItem = InventoryItemComponent.Cast(entity.FindComponent(InventoryItemComponent));
270  if (inventoryItem)
271  {
272  //~ Is item in inventory thus ignore getting vehicle parent
273  if (inventoryItem.GetParentSlot())
274  return null;
275  }
276 
277  return SCR_ResourceComponent.FindResourceComponent(entity.GetParent(), ignoreChildIfHasStorage);
278  }
279 
280  return null;
281  }
282 
283  //------------------------------------------------------------------------------------------------
286  {
288  }
289 
290  //------------------------------------------------------------------------------------------------
293  {
295  }
296 
297  //------------------------------------------------------------------------------------------------
300  void GetGridContainersBounds(out int mins, out int maxs)
301  {
304  }
305 
306  //------------------------------------------------------------------------------------------------
309  void GetGridContainersBoundingBox(out vector mins, out vector maxs)
310  {
313  }
314 
315  //------------------------------------------------------------------------------------------------
318  void GetGridContainersWorldBoundingBox(out vector mins, out vector maxs)
319  {
320  vector ownerOrigin = GetOwner().GetOrigin();
321  mins = ownerOrigin + m_vGridContainersBoundingVolumeMins;
322  maxs = ownerOrigin + m_vGridContainersBoundingVolumeMaxs;
323  }
324 
325  //------------------------------------------------------------------------------------------------
327  bool IsDynamic()
328  {
329  return m_bIsDynamic;
330  }
331 
332  //------------------------------------------------------------------------------------------------
334  RplComponent GetReplicationComponent()
335  {
336  return m_ReplicationComponent;
337  }
338 
339  //------------------------------------------------------------------------------------------------
341  FactionAffiliationComponent GetFactionAffiliationComponent()
342  {
344  }
345 
346  //------------------------------------------------------------------------------------------------
350  {
351  if (resourceType == EResourceType.INVALID || !m_aEncapsulators)
352  return null;
353 
354  int higherLimitPosition = m_aEncapsulators.Count();
355 
356  if (higherLimitPosition == 0)
357  return null;
358 
359  int position;
360  SCR_ResourceEncapsulator encapsulator;
361 
362  while (position < higherLimitPosition)
363  {
364  if (GetNextEncapsulatorCandidate(position, higherLimitPosition, encapsulator, resourceType))
365  break;
366  }
367 
368  if (!encapsulator
369  || position == m_aEncapsulators.Count()
370  || resourceType != encapsulator.GetResourceType())
371  return null;
372 
373  return encapsulator;
374  }
375 
376  //------------------------------------------------------------------------------------------------
380  bool GetEncapsulator(EResourceType resourceType, out SCR_ResourceEncapsulator encapsulator)
381  {
382  encapsulator = null;
383 
384  if (resourceType == EResourceType.INVALID || !m_aEncapsulators)
385  return false;
386 
387  int higherLimitPosition = m_aEncapsulators.Count();
388 
389  if (higherLimitPosition == 0)
390  return false;
391 
392  int position;
393 
394  while (position < higherLimitPosition)
395  {
396  if (GetNextEncapsulatorCandidate(position, higherLimitPosition, encapsulator, resourceType))
397  break;
398  }
399 
400  if (!encapsulator
401  || position == m_aEncapsulators.Count()
402  || resourceType != encapsulator.GetResourceType())
403  return false;
404 
405  return true;
406  }
407 
408  //------------------------------------------------------------------------------------------------
409  protected bool GetNextEncapsulatorCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceEncapsulator encapsulator, EResourceType resourceType)
410  {
411  int comparePosition = position + ((higherLimitPosition - position) >> 1);
412  encapsulator = m_aEncapsulators[comparePosition];
413 
414  if (!encapsulator)
415  return null;
416 
417  EResourceType compareResourceType = encapsulator.GetResourceType();
418 
419  if (resourceType > compareResourceType)
420  position = comparePosition + 1;
421  else if (resourceType < compareResourceType)
422  higherLimitPosition = comparePosition;
423  else
424  {
425  encapsulator = m_aEncapsulators[comparePosition];
426 
427  return true;
428  }
429 
430  encapsulator = null;
431 
432  return false;
433  }
434 
435  //------------------------------------------------------------------------------------------------
437  array<SCR_ResourceEncapsulator> GetEncapsulators()
438  {
439  if (!m_aEncapsulators)
440  return null;
441 
442  int encapsulatorCount = m_aEncapsulators.Count();
443 
444  if (encapsulatorCount == 0)
445  return null;
446 
447  array<SCR_ResourceEncapsulator> encapsulators = {};
448 
449  encapsulators.Reserve(encapsulatorCount);
450 
451  foreach (SCR_ResourceEncapsulator encapsulator: m_aEncapsulators)
452  {
453  encapsulators.Insert(encapsulator);
454  }
455 
456  return encapsulators;
457  }
458 
459  //------------------------------------------------------------------------------------------------
464  {
465  if (resourceType == EResourceType.INVALID || !m_aContainerInstances)
466  return null;
467 
468  int higherLimitPosition = m_aContainerInstances.Count();
469 
470  if (higherLimitPosition == 0)
471  return null;
472 
473  int position;
474  SCR_ResourceContainer container;
475 
476  while (position < higherLimitPosition)
477  {
478  if (GetNextContainerCandidate(position, higherLimitPosition, container, resourceType))
479  break;
480  }
481 
482  if (!container
483  || position == m_aContainerInstances.Count()
484  || resourceType != container.GetResourceType())
485  return null;
486 
487  return container;
488  }
489 
490  //------------------------------------------------------------------------------------------------
495  bool GetContainer(EResourceType resourceType, out SCR_ResourceContainer container)
496  {
497  container = null;
498 
499  if (resourceType == EResourceType.INVALID || !m_aContainerInstances)
500  return false;
501 
502  int higherLimitPosition = m_aContainerInstances.Count();
503  if (higherLimitPosition == 0)
504  return false;
505 
506  int position;
507 
508  while (position < higherLimitPosition)
509  {
510  if (GetNextContainerCandidate(position, higherLimitPosition, container, resourceType))
511  break;
512  }
513 
514  if (!container
515  || position == m_aContainerInstances.Count()
516  || resourceType != container.GetResourceType())
517  return false;
518 
519  return true;
520  }
521 
522  //------------------------------------------------------------------------------------------------
523  protected bool GetNextContainerCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceContainer container, EResourceType resourceType)
524  {
525  int comparePosition = position + ((higherLimitPosition - position) >> 1);
526  container = m_aContainerInstances[comparePosition];
527 
528  if (!container)
529  return null;
530 
531  EResourceType compareResourceType = container.GetResourceType();
532 
533  if (resourceType > compareResourceType)
534  {
535  position = comparePosition + 1;
536  }
537  else if (resourceType < compareResourceType)
538  {
539  higherLimitPosition = comparePosition;
540  }
541  else
542  {
543  container = m_aContainerInstances[comparePosition];
544 
545  return true;
546  }
547 
548  container = null;
549 
550  return false;
551  }
552 
553  //------------------------------------------------------------------------------------------------
555  array<SCR_ResourceContainer> GetContainers()
556  {
557  int containerCount = m_aContainerInstances.Count();
558 
559  if (containerCount == 0)
560  return null;
561 
562  array<SCR_ResourceContainer> containers = {};
563 
564  containers.Reserve(containerCount);
565 
566  foreach (SCR_ResourceContainer container: m_aContainerInstances)
567  {
568  containers.Insert(container);
569  }
570 
571  return containers;
572  }
573 
574  //------------------------------------------------------------------------------------------------
578  SCR_ResourceConsumer GetConsumer(EResourceGeneratorID identifier, EResourceType resourceType)
579  {
580  if (identifier == EResourceGeneratorID.INVALID || resourceType == EResourceType.INVALID || !m_aConsumers)
581  return null;
582 
583  int higherLimitPosition = m_aConsumers.Count();
584  if (higherLimitPosition == 0)
585  return null;
586 
587  int position;
588  SCR_ResourceConsumer consumer;
589 
590  while (position < higherLimitPosition)
591  {
592  if (GetNextConsumerCandidate(position, higherLimitPosition, consumer, identifier, resourceType))
593  break;
594  }
595 
596  if (!consumer
597  || position == m_aConsumers.Count()
598  || identifier != consumer.GetGeneratorIdentifier()
599  || resourceType != consumer.GetResourceType())
600  return null;
601 
602  return consumer;
603  }
604 
605  //------------------------------------------------------------------------------------------------
611  bool GetConsumer(EResourceGeneratorID identifier, EResourceType resourceType, inout SCR_ResourceConsumer consumer)
612  {
613  consumer = null;
614 
615  if (identifier == EResourceGeneratorID.INVALID || resourceType == EResourceType.INVALID || !m_aConsumers)
616  return false;
617 
618  int higherLimitPosition = m_aConsumers.Count();
619  if (higherLimitPosition == 0)
620  return false;
621 
622  int position;
623 
624  while (position < higherLimitPosition)
625  {
626  if (GetNextConsumerCandidate(position, higherLimitPosition, consumer, identifier, resourceType))
627  break;
628  }
629 
630  if (!consumer
631  || position == m_aConsumers.Count()
632  || identifier != consumer.GetGeneratorIdentifier()
633  || resourceType != consumer.GetResourceType())
634  return false;
635 
636  return true;
637  }
638 
639  //------------------------------------------------------------------------------------------------
640  protected bool GetNextConsumerCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceConsumer consumer, EResourceGeneratorID identifier, EResourceType resourceType)
641  {
642  int comparePosition = position + ((higherLimitPosition - position) >> 1);
643  consumer = m_aConsumers[comparePosition];
644 
645  if (!consumer)
646  return false;
647 
648  EResourceType compareResourceType = consumer.GetResourceType();
649  EResourceGeneratorID comapareIdentifier = consumer.GetGeneratorIdentifier();
650 
651  if (identifier > comapareIdentifier)
652  {
653  position = comparePosition + 1;
654  }
655  else if (identifier < comapareIdentifier)
656  {
657  higherLimitPosition = comparePosition;
658  }
659  else if (resourceType > compareResourceType)
660  {
661  position = comparePosition + 1;
662  }
663  else if (resourceType < compareResourceType)
664  {
665  higherLimitPosition = comparePosition;
666  }
667  else
668  {
669  consumer = m_aConsumers[comparePosition];
670 
671  return true;
672  }
673 
674  consumer = null;
675 
676  return false;
677  }
678 
679  //------------------------------------------------------------------------------------------------
681  array<SCR_ResourceConsumer> GetConsumers()
682  {
683  int consumerCount = m_aConsumers.Count();
684  if (consumerCount == 0)
685  return null;
686 
687  array<SCR_ResourceConsumer> consumers = {};
688  consumers.Reserve(consumerCount);
689 
690  foreach (SCR_ResourceConsumer container: m_aConsumers)
691  {
692  consumers.Insert(container);
693  }
694 
695  return consumers;
696  }
697 
698  //------------------------------------------------------------------------------------------------
703  {
704  if (identifier == EResourceGeneratorID.INVALID || resourceType == EResourceType.INVALID || !m_aGenerators)
705  return null;
706 
707  int higherLimitPosition = m_aGenerators.Count();
708  if (higherLimitPosition == 0)
709  return null;
710 
711  int position;
712  SCR_ResourceGenerator generator;
713 
714  while (position < higherLimitPosition)
715  {
716  if (GetNextGeneratorCandidate(position, higherLimitPosition, generator, identifier, resourceType))
717  break;
718  }
719 
720  if (!generator
721  || position == m_aGenerators.Count()
722  || identifier != generator.GetIdentifier()
723  || resourceType != generator.GetResourceType())
724  return null;
725 
726  return generator;
727  }
728 
729  //------------------------------------------------------------------------------------------------
734  bool GetGenerator(EResourceGeneratorID identifier, EResourceType resourceType, out SCR_ResourceGenerator generator)
735  {
736  generator = null;
737 
738  if (identifier == EResourceGeneratorID.INVALID || resourceType == EResourceType.INVALID || !m_aGenerators)
739  return false;
740 
741  int higherLimitPosition = m_aGenerators.Count();
742  if (higherLimitPosition == 0)
743  return false;
744 
745  int position;
746 
747  while (position < higherLimitPosition)
748  {
749  if (GetNextGeneratorCandidate(position, higherLimitPosition, generator, identifier, resourceType))
750  break;
751  }
752 
753  if (!generator
754  || position == m_aGenerators.Count()
755  || identifier != generator.GetIdentifier()
756  || resourceType != generator.GetResourceType())
757  return false;
758 
759  return true;
760  }
761 
762  //------------------------------------------------------------------------------------------------
763  protected bool GetNextGeneratorCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceGenerator generator, EResourceGeneratorID identifier, EResourceType resourceType)
764  {
765  int comparePosition = position + ((higherLimitPosition - position) >> 1);
766  generator = m_aGenerators[comparePosition];
767 
768  if (!generator)
769  return false;
770 
771  EResourceType compareResourceType = generator.GetResourceType();
772  EResourceGeneratorID comapareIdentifier = generator.GetIdentifier();
773 
774  if (identifier > comapareIdentifier)
775  {
776  position = comparePosition + 1;
777  }
778  else if (identifier < comapareIdentifier)
779  {
780  higherLimitPosition = comparePosition;
781  }
782  else if (resourceType > compareResourceType)
783  {
784  position = comparePosition + 1;
785  }
786  else if (resourceType < compareResourceType)
787  {
788  higherLimitPosition = comparePosition;
789  }
790  else
791  {
792  generator = m_aGenerators[comparePosition];
793 
794  return true;
795  }
796 
797  generator = null;
798 
799  return false;
800  }
801 
802  //------------------------------------------------------------------------------------------------
806  array<SCR_ResourceGenerator> GetGenerators()
807  {
808  int generatorCount = m_aGenerators.Count();
809 
810  if (generatorCount == 0)
811  return null;
812 
813  array<SCR_ResourceGenerator> generators = {};
814 
815  generators.Reserve(generatorCount);
816 
817  foreach (SCR_ResourceGenerator generator: m_aGenerators)
818  {
819  generators.Insert(generator);
820  }
821 
822  return generators;
823  }
824 
825  //------------------------------------------------------------------------------------------------
828  {
829  return m_iGridUpdateId;
830  }
831 
832  //------------------------------------------------------------------------------------------------
835  {
836  return m_LastPosition;
837  }
838 
839  //------------------------------------------------------------------------------------------------
841  bool HasParent()
842  {
843  return m_bHasParent;
844  }
845 
846  //------------------------------------------------------------------------------------------------
849  {
850  return Color.FromInt(m_DebugColor.PackToInt());
851  }
852 
853  //------------------------------------------------------------------------------------------------
856  bool IsGridUpdateIdGreaterThan(int gridUpdateId)
857  {
858  return m_iGridUpdateId > gridUpdateId;
859  }
860 
861  //------------------------------------------------------------------------------------------------
864  {
866  }
867 
868  //------------------------------------------------------------------------------------------------
870  bool IsVisible()
871  {
872  return m_bIsVisible;
873  }
874 
875  //------------------------------------------------------------------------------------------------
878  {
879  return m_bIsOwnerActive;
880  }
881 
882  //------------------------------------------------------------------------------------------------
884  {
885  return m_aConsumers != null;
886  }
887 
888  //------------------------------------------------------------------------------------------------
890  {
891  return m_aGenerators != null;
892  }
893 
894  //------------------------------------------------------------------------------------------------
896  void SetGridUpdateId(int gridUpdateId)
897  {
898  if (m_iGridUpdateId > gridUpdateId)
899  return;
900 
901  m_iGridUpdateId = gridUpdateId;
902  }
903 
904  //------------------------------------------------------------------------------------------------
906  void SetIsVisible(bool state)
907  {
908  m_bIsVisible = state;
909  m_bIsNetDirty = true;
910 
911  ReplicateEx();
913  }
914 
915  //------------------------------------------------------------------------------------------------
918  {
920  }
921 
922  //------------------------------------------------------------------------------------------------
925  {
927  }
928 
929  //------------------------------------------------------------------------------------------------
932  void SetGridContainersBounds(int mins, int maxs)
933  {
936  }
937 
938  //------------------------------------------------------------------------------------------------
941  {
942  m_LastPosition = GetOwner().GetOrigin();
943  }
944 
945  //------------------------------------------------------------------------------------------------
948  {
950  return;
951 
952  GetGame().GetResourceGrid().FlagResourceItem(this);
953 
955  }
956 
957  //------------------------------------------------------------------------------------------------
960  {
962  return;
963 
964  GetGame().GetResourceGrid().UnflagResourceItem(this);
965 
967  }
968 
969  //------------------------------------------------------------------------------------------------
972  {
973  if (!m_aConsumers)
974  return;
975 
976  delete m_aConsumers;
977  }
978 
979  //------------------------------------------------------------------------------------------------
982  {
983  if (!m_aGenerators)
984  return;
985 
986  delete m_aGenerators;
987  }
988 
989  //------------------------------------------------------------------------------------------------
992  {
993  delete m_aConsumers;
994  delete m_aGenerators;
995  }
996 
997  //------------------------------------------------------------------------------------------------
1001  override event protected void OnPostInit(IEntity owner)
1002  {
1003  super.OnPostInit(owner);
1004  Initialize(owner);
1005  SetEventMask(owner, EntityEvent.INIT);
1006 
1007  //~ Remove any duplicate entries
1008  if (m_aDisabledResourceTypes.IsEmpty())
1009  {
1010  //~ TODO: Make this cleaner
1011 
1012  set<EResourceType> duplicateRemoveSet = new set<EResourceType>();
1013 
1014  foreach (EResourceType resourceType : m_aDisabledResourceTypes)
1015  {
1016  duplicateRemoveSet.Insert(resourceType);
1017  }
1018 
1019  m_aDisabledResourceTypes.Clear();
1020  foreach (EResourceType resourceType : duplicateRemoveSet)
1021  {
1022  m_aDisabledResourceTypes.Insert(resourceType);
1023  }
1024  }
1025  }
1026 
1027  //------------------------------------------------------------------------------------------------
1030  void Initialize(notnull IEntity owner)
1031  {
1032  if (m_bIsInitialized)
1033  return;
1034 
1035  //The replication component is a must, as the authority is the only one allowed to perform an update on the container and/or consumer.
1036  m_ReplicationComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
1037  FactionAffiliationComponent factionAffiliationComponentTemp;
1038  IEntity parentEntity = owner.GetParent();
1039 
1040  while (parentEntity)
1041  {
1042  factionAffiliationComponentTemp = FactionAffiliationComponent.Cast(parentEntity.FindComponent(FactionAffiliationComponent));
1043 
1044  if (factionAffiliationComponentTemp)
1045  m_FactionAffiliationComponent = factionAffiliationComponentTemp;
1046 
1047  parentEntity = parentEntity.GetParent();
1048  }
1049 
1050  // In the case that no parent has a faction affiliation component, then get the owner's.
1052  m_FactionAffiliationComponent = FactionAffiliationComponent.Cast(owner.FindComponent(FactionAffiliationComponent));
1053 
1054  Physics physics = owner.GetPhysics();
1055  float maxLength;
1056  vector tempBoundsMaxs, tempBoundsMins;
1057 
1058  // ---------------------------------------------------------------- Container initialisation.
1059  // The container is configured through SCR_ResourceComponentClass.
1060  // Note: Order matters, containers should be processed first for the optimization on when the self resource right is enabled on them.
1061  SCR_ResourceComponentClass prefabData = SCR_ResourceComponentClass.Cast(GetComponentData(owner));
1062 
1063  if (prefabData)
1064  {
1065  // Container instances holding the initial configuration for this component instance's containers.
1066  array<ref SCR_ResourceContainer> containers = prefabData.GetContainers();
1067 
1068  if (containers)
1069  {
1070  SCR_ResourceContainer containerInstance;
1071  typename containerInstanceTypename;
1072 
1073  m_aContainerInstances.Reserve(containers.Count());
1074 
1075  foreach (SCR_ResourceContainer container: containers)
1076  {
1077  containerInstanceTypename = container.Type();
1078 
1079  containerInstance = SCR_ResourceContainer.Cast(containerInstanceTypename.Spawn());
1080 
1081  // The copying of the container configuration in the prefab data happens here.
1082  containerInstance.Initialize(owner, container);
1083 
1084  int maxPosition = m_aContainerInstances.Count();
1085  int position;
1086  EResourceType resourceType = container.GetResourceType();
1087  EResourceType compareResourceType;
1088  int comparePosition;
1089  SCR_ResourceContainer compareContainer;
1090 
1091  while (position < maxPosition)
1092  {
1093  comparePosition = position + ((maxPosition - position) >> 1);
1094  compareContainer = m_aContainerInstances[comparePosition];
1095  compareResourceType = compareContainer.GetResourceType();
1096 
1097  if (resourceType > compareResourceType)
1098  position = comparePosition + 1;
1099 
1100  else if (resourceType < compareResourceType)
1101  maxPosition = comparePosition;
1102 
1103  else
1104  break;
1105  }
1106 
1107  // Clean container instance to copy the prefab container configuration to.
1108  m_aContainerInstances.InsertAt(containerInstance, position);
1109 
1110  if (container.IsIsolated())
1111  continue;
1112 
1113  containerInstance.GetAxisAlignedBoundingVolume(tempBoundsMins, tempBoundsMaxs);
1114  }
1115 
1116  m_vGridContainersBoundingVolumeMaxs = tempBoundsMaxs;
1117  m_vGridContainersBoundingVolumeMins = tempBoundsMins;
1118  }
1119  }
1120 
1121  // ------------------------------------------------------------- Encapsulator initialization.
1122  if (m_aEncapsulators)
1123  {
1124  array<ref SCR_ResourceEncapsulator> encapsulators = {};
1125  encapsulators.Reserve(m_aEncapsulators.Count());
1126 
1127  foreach (SCR_ResourceEncapsulator encapsulator: m_aEncapsulators)
1128  {
1129  encapsulator.Initialize(owner);
1130 
1131  int position;
1132  int maxPosition = encapsulators.Count();
1133  EResourceType resourceType = encapsulator.GetResourceType();
1134  EResourceType compareResourceType;
1135  int comparePosition;
1136  SCR_ResourceEncapsulator compareEncapsulator;
1137 
1138  while (position < maxPosition)
1139  {
1140  comparePosition = position + ((maxPosition - position) >> 1);
1141  compareEncapsulator = encapsulators[comparePosition];
1142  compareResourceType = compareEncapsulator.GetResourceType();
1143 
1144  if (resourceType > compareResourceType)
1145  position = comparePosition + 1;
1146 
1147  else if (resourceType < compareResourceType)
1148  maxPosition = comparePosition;
1149 
1150  else
1151  break;
1152  }
1153 
1154  encapsulators.InsertAt(encapsulator, position);
1155  }
1156 
1157  m_aEncapsulators = encapsulators;
1158  }
1159 
1160  // ----------------------------------------------------------------- Consumer initialization.
1161  if (m_aConsumers)
1162  {
1163  array<ref SCR_ResourceConsumer> consumers = {};
1164  consumers.Reserve(m_aConsumers.Count());
1165 
1166  foreach (SCR_ResourceConsumer consumer: m_aConsumers)
1167  {
1168  SCR_ResourceContainer container = GetContainer(consumer.GetResourceType());
1169 
1170  if (container && container.IsEncapsulated())
1171  continue;
1172 
1173  consumer.Initialize(owner);
1174 
1175  int position;
1176  int maxPosition = consumers.Count();
1177  EResourceGeneratorID generatorIdentifier = consumer.GetGeneratorIdentifier();
1178  EResourceGeneratorID compareGeneratorIdentifier;
1179  EResourceType resourceType = consumer.GetResourceType();
1180  EResourceType compareResourceType;
1181  int comparePosition;
1182  SCR_ResourceConsumer compareConsumer;
1183 
1184  while (position < maxPosition)
1185  {
1186  comparePosition = position + ((maxPosition - position) >> 1);
1187  compareConsumer = consumers[comparePosition];
1188  compareGeneratorIdentifier = compareConsumer.GetGeneratorIdentifier();
1189  compareResourceType = compareConsumer.GetResourceType();
1190 
1191  if (generatorIdentifier > compareGeneratorIdentifier)
1192  position = comparePosition + 1;
1193  else if (generatorIdentifier < compareGeneratorIdentifier)
1194  maxPosition = comparePosition;
1195  else if (resourceType > compareResourceType)
1196  position = comparePosition + 1;
1197  else if (resourceType < compareResourceType)
1198  maxPosition = comparePosition;
1199  else
1200  break;
1201  }
1202 
1203  consumers.InsertAt(consumer, position);
1204  }
1205 
1206  m_aConsumers = consumers;
1207  }
1208 
1209  // ---------------------------------------------------------------- Generator initialization.
1210  if (m_aGenerators)
1211  {
1212  array<ref SCR_ResourceGenerator> generators = {};
1213  generators.Reserve(m_aGenerators.Count());
1214 
1215  foreach (SCR_ResourceGenerator generator: m_aGenerators)
1216  {
1217  SCR_ResourceContainer container = GetContainer(generator.GetResourceType());
1218 
1219  if (container && container.IsEncapsulated())
1220  continue;
1221 
1222  generator.Initialize(owner);
1223 
1224  int position;
1225  int maxPosition = generators.Count();
1226  EResourceGeneratorID identifier = generator.GetIdentifier();
1227  EResourceGeneratorID comapareIdentifier;
1228  EResourceType resourceType = generator.GetResourceType();
1229  EResourceType compareResourceType;
1230  int comparePosition;
1231  SCR_ResourceGenerator compareGenerator;
1232 
1233  while (position < maxPosition)
1234  {
1235  comparePosition = position + ((maxPosition - position) >> 1);
1236  compareGenerator = generators[comparePosition];
1237  comapareIdentifier = compareGenerator.GetIdentifier();
1238  compareResourceType = compareGenerator.GetResourceType();
1239 
1240  if (identifier > comapareIdentifier)
1241  position = comparePosition + 1;
1242  else if (identifier < comapareIdentifier)
1243  maxPosition = comparePosition;
1244  else if (resourceType > compareResourceType)
1245  position = comparePosition + 1;
1246  else if (resourceType < compareResourceType)
1247  maxPosition = comparePosition;
1248  else
1249  break;
1250  }
1251 
1252  generators.InsertAt(generator, position);
1253  }
1254 
1255  m_aGenerators = generators;
1256  }
1257 
1259  OnAddedToParentEx(GetOwner().GetChildren(), GetOwner().GetParent());
1260 
1261  Vehicle vehicle = Vehicle.Cast(GetOwner());
1262 
1263  if (vehicle)
1264  vehicle.GetOnPhysicsActive().Insert(OnVehiclePhysicsActive);
1265 
1266  m_bIsInitialized = true;
1267 
1268  Replicate();
1269  }
1270 
1271  //------------------------------------------------------------------------------------------------
1275  override event protected void OnChildAdded(IEntity parent, IEntity child)
1276  {
1277  SCR_ResourceComponent childResourceComponent = SCR_ResourceComponent.Cast(child.FindComponent(SCR_ResourceComponent));
1278  if (!childResourceComponent)
1279  return;
1280 
1281  Initialize(GetOwner());
1282  }
1283 
1284  //------------------------------------------------------------------------------------------------
1287  override event protected void EOnInit(IEntity owner)
1288  {
1289  SCR_ResourceContainer container;
1291 
1292  foreach (SCR_ResourceEncapsulator encapsulator: m_aEncapsulators)
1293  {
1294  queue = encapsulator.GetContainerQueue();;
1295 
1296  for (int i = queue.GetContainerCount() - 1; i >= 0; --i)
1297  {
1298  container = queue.GetContainerAt(i);
1299 
1300  if (container.GetResourceValue() == 0.0 && GetGame().GetWorld() && !GetGame().GetWorld().IsEditMode() && container.GetOnEmptyBehavior() == EResourceContainerOnEmptyBehavior.HIDE)
1301  container.GetComponent().SetIsVisible(false);
1302  }
1303  }
1304 
1305  bool isCompletelyIsolated = true;
1306 
1307  for (int i = m_aContainerInstances.Count() - 1; i >= 0; --i)
1308  {
1309  container = m_aContainerInstances[i];
1310  isCompletelyIsolated &= container.IsIsolated();
1311  }
1312 
1313  if (isCompletelyIsolated)
1314  {
1316 
1317  return;
1318  }
1319 
1320  Vehicle vehicle = Vehicle.Cast(GetOwner().GetRootParent());
1321  if (vehicle)
1322  vehicle.GetOnPhysicsActive().Insert(OnVehiclePhysicsActive);
1323 
1325  }
1326 
1327  //------------------------------------------------------------------------------------------------
1335  protected void DebugDraw()
1336  {
1337  // Height for the white arrow.
1338  float height;
1339 
1340  // The white arrow will point to this position, the origin of the owner entity in this case.
1341  vector origin = GetOwner().GetOrigin();
1342 
1343  // TODO: Cache the height value and only change it on a event basis.
1345  {
1346  foreach (SCR_ResourceConsumer consumer: m_aConsumers)
1347  {
1348  // Processes and presents the debugging visualization for the consumer.
1349  consumer.DebugDraw();
1350 
1351  // Sets the height of the arrow to be the same as the consumer resource range if the current height is less than it.
1352  height = Math.Max(height, consumer.GetResourceRange());
1353  }
1354  }
1355 
1358  {
1359  foreach (SCR_ResourceEncapsulator encapsulator: m_aEncapsulators)
1360  {
1362  encapsulator.DebugDraw();
1363  }
1364  }
1365 
1366  // TODO: Cache the height value and only change it on a event basis.
1368  {
1369  foreach (SCR_ResourceGenerator generator: m_aGenerators)
1370  {
1371  // Processes and presents the debugging visualisation for the generator.
1372  generator.DebugDraw();
1373 
1374  // Sets the height of the arrow to be the same as the generator resource range if the current height is less than it.
1375  height = Math.Max(height, generator.GetStorageRange());
1376  }
1377  }
1378 
1379  // TODO: Cache the height value and only change it on a event basis.
1381  {
1382  foreach (SCR_ResourceContainer container: m_aContainerInstances)
1383  {
1384  // Processes and presents the debugging visualisation for the container.
1385  container.DebugDraw();
1386 
1387  // Sets the height of the arrow to be the same as the container storage range if the
1388  // current height (Same as resource range of the consumer if a consumer is present on the
1389  // component or 0.0 otherwise) is less than it.
1390  //height = Math.Max(height, container.GetStorageRange());
1391  }
1392  }
1393 
1395  Shape.CreateArrow((origin + vector.Up * height), origin, 1.0, 0xFFFFFFFF, ShapeFlags.ONCE | ShapeFlags.NOZBUFFER);
1396  }
1397 
1398  //------------------------------------------------------------------------------------------------
1400  void Replicate()
1401  {
1403  return;
1404 
1405  m_bIsNetDirty = true;
1406  }
1407 
1408  //------------------------------------------------------------------------------------------------
1414  {
1415  if (!m_bIsNetDirty)
1416  return;
1417 
1418  Replication.BumpMe();
1419 
1420  m_bIsNetDirty = false;
1421 
1423  }
1424 
1425 #ifdef WORKBENCH
1426  //------------------------------------------------------------------------------------------------
1431  override event void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
1432  {
1434  DebugDraw();
1435 
1436  super._WB_AfterWorldUpdate(timeSlice);
1437  }
1438 
1439  //------------------------------------------------------------------------------------------------
1441  override event bool _WB_OnKeyChanged(IEntity owner, BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
1442  {
1443  SCR_ResourceGrid grid = GetGame().GetResourceGrid();
1444 
1445  if (m_aConsumers)
1446  {
1447  foreach (SCR_ResourceConsumer consumer: m_aConsumers)
1448  {
1449  consumer.GetContainerQueue().Clear();
1450  }
1451  }
1452 
1453  if (m_aGenerators)
1454  {
1455  foreach (SCR_ResourceGenerator generator: m_aGenerators)
1456  {
1457  generator.GetContainerQueue().Clear();
1458  }
1459  }
1460 
1461  grid.IncreaseGridUpdateId();
1462  grid.UnregisterResourceItem(this);
1463 
1464  return super._WB_OnKeyChanged(owner, src, key, ownerContainers, parent);
1465  }
1466 #endif
1467 
1468  //------------------------------------------------------------------------------------------------
1470  {
1471  IEntity owner = GetOwner();
1472 
1473  if (m_bIsVisible)
1474  {
1475  owner.SetFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE, true);
1476  SCR_PhysicsHelper.ChangeSimulationState(owner, SimulationState.COLLISION, true);
1477 
1478  return;
1479  }
1480 
1481  owner.ClearFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE, true);
1482  SCR_PhysicsHelper.ChangeSimulationState(owner, SimulationState.NONE, true);
1483  }
1484 
1485  //------------------------------------------------------------------------------------------------
1486  override event protected void OnAddedToParent(IEntity child, IEntity parent)
1487  {
1489  return;
1490 
1491  if (m_bIsInitialized)
1492  OnAddedToParentEx(child, parent);
1493  else
1495  }
1496 
1497  //------------------------------------------------------------------------------------------------
1498  protected void OnAddedToParentEx(IEntity child, IEntity parent)
1499  {
1500  foreach (SCR_ResourceContainer container: m_aContainerInstances)
1501  {
1502  if (!container || container.GetStorageType() != EResourceContainerStorageType.ORPHAN)
1503  continue;
1504 
1505  container.EnableDecay(false);
1506  }
1507 
1509  m_bHasParent = true;
1510  bool isCompletelyIsolated = true;
1511 
1512  foreach (SCR_ResourceContainer container: m_aContainerInstances)
1513  {
1514  isCompletelyIsolated &= container.IsEncapsulated();
1515  }
1516 
1517  if (isCompletelyIsolated)
1518  return;
1519 
1520  Vehicle vehicle = Vehicle.Cast(GetOwner().GetRootParent());
1521 
1522  if (!vehicle)
1523  return;
1524 
1525  GetGame().GetResourceGrid().PromoteResourceItemToDynamic(this);
1526  m_bIsDynamic = true;
1527 
1528  vehicle.GetOnPhysicsActive().Insert(OnVehiclePhysicsActive);
1529  }
1530 
1531  //------------------------------------------------------------------------------------------------
1532  override event protected void OnRemovedFromParent(IEntity child, IEntity parent)
1533  {
1535  return;
1536 
1537  m_bHasParent = false;
1538 
1539  foreach (SCR_ResourceContainer container: m_aContainerInstances)
1540  {
1541  if (!container || container.GetStorageType() != EResourceContainerStorageType.ORPHAN)
1542  continue;
1543 
1544  container.EnableDecay(true);
1545  }
1546  }
1547 
1548  //------------------------------------------------------------------------------------------------
1551  void OnVehiclePhysicsActive(IEntity owner, bool activeState)
1552  {
1553  ChimeraWorld world = ChimeraWorld.CastFrom(GetGame().GetWorld());
1554  if (!world)
1555  return;
1556 
1557  SCR_ResourceSystem updateSystem = SCR_ResourceSystem.Cast(world.FindSystem(SCR_ResourceSystem));
1558 
1559  m_bIsOwnerActive = activeState;
1560 
1561  if (m_bIsOwnerActive)
1562  {
1563  m_bIsDynamic = true;
1564 
1565  GetGame().GetResourceGrid().PromoteResourceItemToDynamic(this);
1566  updateSystem.RegisterDynamicComponent(this);
1567  }
1568  else
1569  {
1570  m_bIsDynamic = false;
1571  GetGame().GetResourceGrid().PromoteResourceItemToStatic(this);
1572  updateSystem.UnregisterDynamicComponent(this);
1573  }
1574  }
1575 
1576  //------------------------------------------------------------------------------------------------
1577  override event protected void OnDelete(IEntity owner)
1578  {
1580 
1581  ArmaReforgerScripted game = GetGame();
1582  if (!game)
1583  return;
1584 
1585  ChimeraWorld world = ChimeraWorld.CastFrom(game.GetWorld());
1586  if (!world)
1587  return;
1588 
1589  SCR_ResourceGrid grid = GetGame().GetResourceGrid();
1590 
1591  grid.IncreaseGridUpdateId();
1592  grid.UnregisterResourceItem(this);
1593 
1594  SCR_ResourceSystem updateSystem = SCR_ResourceSystem.Cast(world.FindSystem(SCR_ResourceSystem));
1595  if (!updateSystem)
1596  return;
1597 
1598  updateSystem.UnregisterDynamicComponent(this);
1599 
1600  delete m_aConsumers;
1601  delete m_aGenerators;
1602  delete m_aEncapsulators;
1603  delete m_aContainerInstances;
1604  }
1605 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SetGridContainersBoundsMins
void SetGridContainersBoundsMins(int mins)
Definition: SCR_ResourceComponent.c:917
ChimeraWorld
Definition: ChimeraWorld.c:12
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
OnAddedToParent
override event protected void OnAddedToParent(IEntity child, IEntity parent)
Definition: SCR_ResourceComponent.c:1486
SCR_ResourceGrid
void SCR_ResourceGrid()
Definition: SCR_ResourceGrid.c:785
m_bIsFlaggedForProcessing
protected bool m_bIsFlaggedForProcessing
Definition: SCR_ResourceComponent.c:57
GetEncapsulators
array< SCR_ResourceEncapsulator > GetEncapsulators()
Definition: SCR_ResourceComponent.c:437
GetConsumers
array< SCR_ResourceConsumer > GetConsumers()
Definition: SCR_ResourceComponent.c:681
GENERATOR
GENERATOR
Definition: SCR_ResourceComponent.c:4
DeleteConsumers
void DeleteConsumers()
Definition: SCR_ResourceComponent.c:971
Replicate
void Replicate()
Definition: SCR_ResourceComponent.c:1400
ENCAPSULATOR
ENCAPSULATOR
Definition: SCR_ResourceComponent.c:5
IsDynamic
bool IsDynamic()
Definition: SCR_ResourceComponent.c:327
CONSUMER
CONSUMER
Definition: SCR_ResourceComponent.c:2
GetDebugColor
Color GetDebugColor()
Definition: SCR_ResourceComponent.c:848
SCR_ResourceSystemHelper
Definition: SCR_ResourceSystemHelper.c:1
GetGridContainersBoundingBox
void GetGridContainersBoundingBox(out vector mins, out vector maxs)
Definition: SCR_ResourceComponent.c:309
m_aConsumers
protected ref array< ref SCR_ResourceConsumer > m_aConsumers
Refer to SCR_ResourceConsumer for documentation.
Definition: SCR_ResourceComponent.c:65
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
ShouldGeneratorsBeReplicated
protected bool ShouldGeneratorsBeReplicated()
Definition: SCR_ResourceComponent.c:889
GetGridUpdateId
int GetGridUpdateId()
Definition: SCR_ResourceComponent.c:827
DebugDraw
protected void DebugDraw()
Definition: SCR_ResourceComponent.c:1335
RplProp
SCR_RplTestEntityClass RplProp
Used for handling entity spawning requests for SCR_CatalogEntitySpawnerComponent and inherited classe...
m_vGridContainersBoundingVolumeMaxs
protected vector m_vGridContainersBoundingVolumeMaxs
Definition: SCR_ResourceComponent.c:55
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GetFactionAffiliationComponent
FactionAffiliationComponent GetFactionAffiliationComponent()
Definition: SCR_ResourceComponent.c:341
m_aContainerInstances
protected ref array< ref SCR_ResourceContainer > m_aContainerInstances
Definition: SCR_ResourceComponent.c:119
m_bIsDynamic
protected bool m_bIsDynamic
Definition: SCR_ResourceComponent.c:48
OnDelete
override event protected void OnDelete(IEntity owner)
Definition: SCR_ResourceComponent.c:1577
UPDATE_PERIOD
const protected float UPDATE_PERIOD
Definition: SCR_ResourceComponent.c:47
TEMP_OnInteractorReplicated
void TEMP_OnInteractorReplicated()
HOTFIX: Until replication issues are resolved.
Definition: SCR_ResourceComponent.c:96
m_bIsOwnerActive
protected bool m_bIsOwnerActive
Definition: SCR_ResourceComponent.c:127
m_ReplicationComponent
protected RplComponent m_ReplicationComponent
Replication component attached to the owner entity.
Definition: SCR_ResourceComponent.c:122
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GetConsumer
SCR_ResourceConsumer GetConsumer(EResourceGeneratorID identifier, EResourceType resourceType)
Definition: SCR_ResourceComponent.c:578
EResourceContainerStorageType
EResourceContainerStorageType
Definition: SCR_ResourceContainer.c:17
GetGenerator
SCR_ResourceGenerator GetGenerator(EResourceGeneratorID identifier, EResourceType resourceType)
Definition: SCR_ResourceComponent.c:702
SetGridUpdateId
void SetGridUpdateId(int gridUpdateId)
Definition: SCR_ResourceComponent.c:896
SCR_ResourceContainerQueueBase
Definition: SCR_ResourceContainerQueue.c:2
func
func
Definition: SCR_AIThreatSystem.c:5
m_bIsInitialized
protected bool m_bIsInitialized
Definition: SCR_ResourceComponent.c:130
EntitySlotInfo
Adds ability to attach an object to a slot.
Definition: EntitySlotInfo.c:8
IsGridUpdateIdGreaterThan
bool IsGridUpdateIdGreaterThan(int gridUpdateId)
Definition: SCR_ResourceComponent.c:856
GetGenerators
array< SCR_ResourceGenerator > GetGenerators()
Definition: SCR_ResourceComponent.c:806
UPDATE_DISTANCE_TRESHOLD
SCR_ResourceComponentClass UPDATE_DISTANCE_TRESHOLD
OnVisibilityChanged
void OnVisibilityChanged()
Definition: SCR_ResourceComponent.c:1469
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
UnflagForProcessing
void UnflagForProcessing()
Definition: SCR_ResourceComponent.c:959
SetGridContainersBounds
void SetGridContainersBounds(int mins, int maxs)
Definition: SCR_ResourceComponent.c:932
m_aDisabledResourceTypes
protected ref array< EResourceType > m_aDisabledResourceTypes
Definition: SCR_ResourceComponent.c:73
SCR_ResourceComponentClass
Definition: SCR_ResourceComponent.c:16
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_Resources_OnResourceEnabledChanged
func SCR_Resources_OnResourceEnabledChanged
Definition: SCR_ResourceComponent.c:11
GetNextEncapsulatorCandidate
protected bool GetNextEncapsulatorCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceEncapsulator encapsulator, EResourceType resourceType)
Definition: SCR_ResourceComponent.c:409
m_iGridContainersBoundsMaxs
protected int m_iGridContainersBoundsMaxs
Definition: SCR_ResourceComponent.c:53
UPDATE_DISTANCE_TRESHOLD_SQUARE
const float UPDATE_DISTANCE_TRESHOLD_SQUARE
Definition: SCR_ResourceComponent.c:46
OnAddedToParentEx
protected void OnAddedToParentEx(IEntity child, IEntity parent)
Definition: SCR_ResourceComponent.c:1498
OnVehiclePhysicsActive
void OnVehiclePhysicsActive(IEntity owner, bool activeState)
Definition: SCR_ResourceComponent.c:1551
GetContainers
array< SCR_ResourceContainer > GetContainers()
Definition: SCR_ResourceComponent.c:555
ReplicateEx
void ReplicateEx()
Definition: SCR_ResourceComponent.c:1413
SetIsVisible
void SetIsVisible(bool state)
Definition: SCR_ResourceComponent.c:906
GetNextConsumerCandidate
protected bool GetNextConsumerCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceConsumer consumer, EResourceGeneratorID identifier, EResourceType resourceType)
Definition: SCR_ResourceComponent.c:640
m_iGridContainersBoundsMins
protected int m_iGridContainersBoundsMins
Definition: SCR_ResourceComponent.c:52
Initialize
void Initialize(notnull IEntity owner)
Definition: SCR_ResourceComponent.c:1030
m_OnResourceTypeEnabledChanged
protected ref ScriptInvokerBase< SCR_Resources_OnResourceEnabledChanged > m_OnResourceTypeEnabledChanged
Definition: SCR_ResourceComponent.c:82
EResourceType
EResourceType
Definition: SCR_ResourceContainer.c:1
IsOwnerActive
bool IsOwnerActive()
Definition: SCR_ResourceComponent.c:877
OnPostInit
override event protected void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_ResourceComponent.c:1001
OnChildAdded
override event protected void OnChildAdded(IEntity parent, IEntity child)
Definition: SCR_ResourceComponent.c:1275
GetLastPosition
vector GetLastPosition()
Definition: SCR_ResourceComponent.c:834
m_bIsNetDirty
protected bool m_bIsNetDirty
Definition: SCR_ResourceComponent.c:49
m_bEnableDebugVisualization
protected bool m_bEnableDebugVisualization
Setting for enabling the debugging visualization of the container and/or consumer.
Definition: SCR_ResourceComponent.c:104
OnResourceTypeEnabledChanged
protected void OnResourceTypeEnabledChanged()
Definition: SCR_ResourceComponent.c:203
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
GetOnResourceTypeEnabledChanged
ScriptInvokerBase< SCR_Resources_OnResourceEnabledChanged > GetOnResourceTypeEnabledChanged()
Definition: SCR_ResourceComponent.c:211
SCR_PhysicsHelper
Definition: SCR_PhysicsHelper.c:6
m_eDebugVisualizationFlags
protected EResourceDebugVisualizationFlags m_eDebugVisualizationFlags
Flags for enabling the debugging visualization.
Definition: SCR_ResourceComponent.c:108
EOnInit
override event protected void EOnInit(IEntity owner)
Initialise this component with data from FactionsManager.
Definition: SCR_ResourceComponent.c:1287
InventoryItemComponent
Definition: InventoryItemComponent.c:12
m_LastPosition
protected vector m_LastPosition
Definition: SCR_ResourceComponent.c:125
SCR_ResourceSystem
Definition: SCR_ResourceSystem.c:1
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
CanResourceTypeEnabledBeChanged
bool CanResourceTypeEnabledBeChanged(EResourceType resourceType=EResourceType.SUPPLIES)
Definition: SCR_ResourceComponent.c:158
UpdateLastPosition
void UpdateLastPosition()
Updates the serial number for the current processing call of the resource grid onto this component.
Definition: SCR_ResourceComponent.c:940
IsDebugVisualizationEnabled
bool IsDebugVisualizationEnabled()
Definition: SCR_ResourceComponent.c:863
m_aGenerators
protected ref array< ref SCR_ResourceGenerator > m_aGenerators
Refer to SCR_ResourceGenerator for documentation.
Definition: SCR_ResourceComponent.c:69
m_bIsVisible
protected bool m_bIsVisible
Definition: SCR_ResourceComponent.c:115
GetNextContainerCandidate
protected bool GetNextContainerCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceContainer container, EResourceType resourceType)
Definition: SCR_ResourceComponent.c:523
SCR_ResourceContainer
Definition: SCR_ResourceContainer.c:34
OnRemovedFromParent
override event protected void OnRemovedFromParent(IEntity child, IEntity parent)
Definition: SCR_ResourceComponent.c:1532
m_DebugColor
protected ref Color m_DebugColor
Setting for the base color for the debugging visualization of the container and/or consumer.
Definition: SCR_ResourceComponent.c:112
m_bHasParent
protected bool m_bHasParent
Definition: SCR_ResourceComponent.c:126
FlagForProcessing
void FlagForProcessing()
Definition: SCR_ResourceComponent.c:947
SetResourceTypeEnabled
void SetResourceTypeEnabled(bool enable, EResourceType resourceType=EResourceType.SUPPLIES)
Definition: SCR_ResourceComponent.c:167
IsResourceTypeEnabled
bool IsResourceTypeEnabled(EResourceType resourceType=EResourceType.SUPPLIES)
Definition: SCR_ResourceComponent.c:138
m_bIsAddedToParentBuffered
protected bool m_bIsAddedToParentBuffered
Definition: SCR_ResourceComponent.c:133
m_aEncapsulators
protected ref array< ref SCR_ResourceEncapsulator > m_aEncapsulators
Refer to SCR_ResourceEncapsulator for documentation.
Definition: SCR_ResourceComponent.c:61
IsVisible
bool IsVisible()
Definition: SCR_ResourceComponent.c:870
GetNextGeneratorCandidate
protected bool GetNextGeneratorCandidate(inout int position, inout int higherLimitPosition, inout SCR_ResourceGenerator generator, EResourceGeneratorID identifier, EResourceType resourceType)
Definition: SCR_ResourceComponent.c:763
DeleteGenerators
void DeleteGenerators()
Definition: SCR_ResourceComponent.c:981
GetGridContainersBounds
void GetGridContainersBounds(out int mins, out int maxs)
Definition: SCR_ResourceComponent.c:300
SetGridContainersBoundsMaxs
void SetGridContainersBoundsMaxs(int maxs)
Definition: SCR_ResourceComponent.c:924
EResourceDebugVisualizationFlags
EResourceDebugVisualizationFlags
Definition: SCR_ResourceComponent.c:1
GetChildren
void GetChildren(out array< SCR_ScenarioFrameworkLayerBase > children)
Definition: SCR_ScenarioFrameworkLayerBase.c:359
m_TEMP_OnInteractorReplicated
protected ref ScriptInvoker m_TEMP_OnInteractorReplicated
HOTFIX: Until replication issues are resolved.
Definition: SCR_ResourceComponent.c:80
GetGridContainersBoundsMaxs
int GetGridContainersBoundsMaxs()
Definition: SCR_ResourceComponent.c:292
GetEncapsulator
SCR_ResourceEncapsulator GetEncapsulator(EResourceType resourceType)
Definition: SCR_ResourceComponent.c:349
GetReplicationComponent
RplComponent GetReplicationComponent()
Definition: SCR_ResourceComponent.c:334
TEMP_GetOnInteractorReplicated
ScriptInvoker TEMP_GetOnInteractorReplicated()
HOTFIX: Until replication issues are resolved.
Definition: SCR_ResourceComponent.c:86
m_iGridUpdateId
protected int m_iGridUpdateId
Definition: SCR_ResourceComponent.c:50
GetGridContainersWorldBoundingBox
void GetGridContainersWorldBoundingBox(out vector mins, out vector maxs)
Definition: SCR_ResourceComponent.c:318
m_FactionAffiliationComponent
protected FactionAffiliationComponent m_FactionAffiliationComponent
Definition: SCR_ResourceComponent.c:123
m_aDisallowChangingEnableResource
protected ref array< EResourceType > m_aDisallowChangingEnableResource
Definition: SCR_ResourceComponent.c:77
SCR_ResourceEncapsulator
Definition: SCR_ResourceEncapsulator.c:1
GetContainer
SCR_ResourceContainer GetContainer(EResourceType resourceType)
Definition: SCR_ResourceComponent.c:463
GetGridContainersBoundsMins
int GetGridContainersBoundsMins()
Definition: SCR_ResourceComponent.c:285
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
CONTAINER
CONTAINER
Definition: SCR_ResourceComponent.c:3
GetDisabledResourceTypes
int GetDisabledResourceTypes(inout notnull array< EResourceType > disabledResourceTypes)
Definition: SCR_ResourceComponent.c:149
HasParent
bool HasParent()
Definition: SCR_ResourceComponent.c:841
m_vGridContainersBoundingVolumeMins
protected vector m_vGridContainersBoundingVolumeMins
Definition: SCR_ResourceComponent.c:54
SCR_ResourceGenerator
Definition: SCR_ResourceGenerator.c:79
EResourceContainerOnEmptyBehavior
EResourceContainerOnEmptyBehavior
Definition: SCR_ResourceContainer.c:26
DeleteQueryInteractors
void DeleteQueryInteractors()
Definition: SCR_ResourceComponent.c:991
ShouldConsumersBeReplicated
protected bool ShouldConsumersBeReplicated()
Definition: SCR_ResourceComponent.c:883
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
EResourceGeneratorID
EResourceGeneratorID
Definition: SCR_ResourceGenerator.c:1