5 [
Attribute(
desc:
"Compartments Types To fill with characters within vehicle.", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(
ECompartmentType))]
6 protected ref array<ECompartmentType> m_aCompartmentsTypes;
9 protected ref map<SCR_BaseCompartmentManagerComponent, SCR_EditableVehicleComponent> m_VehiclesToOccupyQueue =
new map<SCR_BaseCompartmentManagerComponent, SCR_EditableVehicleComponent>();
11 protected bool m_bHasSendNotEnoughBudgetNotification =
false;
12 protected bool m_bIsSpawningOccupants =
false;
20 if (!uiInfo || (uiInfo && !uiInfo.CanFillWithGivenTypes(m_aCompartmentsTypes)))
23 SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(selectedEntity.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
25 return compartmentManager && compartmentManager.HasDefaultOccupantsDataForTypes(m_aCompartmentsTypes);
33 SCR_EditableVehicleComponent vehicle = SCR_EditableVehicleComponent.Cast(selectedEntity);
34 return vehicle && vehicle.CanOccupyVehicleWithCharacters(m_aCompartmentsTypes, -1,
false,
true,
true,
true,
true);
38 override void Perform(
SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,
int flags,
int param = -1)
40 if (!InitPerform())
return;
43 Perform(entity, cursorWorldPosition);
51 SCR_EditableVehicleComponent vehicle = SCR_EditableVehicleComponent.Cast(selectedEntity);
55 SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(vehicle.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
56 if (!compartmentManager)
60 if (m_VehiclesToOccupyQueue.Contains(compartmentManager))
64 m_VehiclesToOccupyQueue.Insert(compartmentManager, vehicle);
67 if (!m_bIsSpawningOccupants)
69 m_bIsSpawningOccupants =
true;
72 SpawnNextOccupantsInEntity();
77 protected void SpawnNextOccupantsInEntity(SCR_BaseCompartmentManagerComponent compartmentManager =
null, array<IEntity> spawnedCharacters =
null,
bool wasCanceled =
false)
80 if (compartmentManager)
82 compartmentManager.GetOnDoneSpawningDefaultOccupants().Remove(SpawnNextOccupantsInEntity);
83 m_VehiclesToOccupyQueue.Remove(compartmentManager);
87 if (m_VehiclesToOccupyQueue.IsEmpty())
93 SCR_EditableVehicleComponent vehicleToOccupy = m_VehiclesToOccupyQueue.GetElement(0);
98 m_VehiclesToOccupyQueue.RemoveElement(0);
99 SpawnNextOccupantsInEntity(
null,
null,
false);
104 compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(vehicleToOccupy.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
107 if (!compartmentManager)
109 m_VehiclesToOccupyQueue.RemoveElement(0);
110 SpawnNextOccupantsInEntity(
null,
null,
false);
115 if (!vehicleToOccupy.CanOccupyVehicleWithCharacters(m_aCompartmentsTypes, -1,
true, checkEditorBudget:
false, checkForFreeDefaultCompartments:
true))
117 m_VehiclesToOccupyQueue.RemoveElement(0);
118 SpawnNextOccupantsInEntity(
null,
null,
false);
123 if (!vehicleToOccupy.CanOccupyVehicleWithCharacters(m_aCompartmentsTypes, -1,
false,
true,
false,
false,
true))
132 m_VehiclesToOccupyQueue.RemoveElement(0);
133 SpawnNextOccupantsInEntity(
null,
null,
false);
138 compartmentManager.GetOnDoneSpawningDefaultOccupants().Insert(SpawnNextOccupantsInEntity);
139 vehicleToOccupy.OccupyVehicleWithDefaultCharacters(m_aCompartmentsTypes);
142 protected void SetSpawningDone()
144 m_VehiclesToOccupyQueue.Clear();
145 m_bIsSpawningOccupants =
false;
146 m_bHasSendNotEnoughBudgetNotification =
false;