1 [
ComponentEditorProps(
category:
"GameScripted/Editor (Editables)", description:
"", icon:
"WBData/ComponentEditorProps/componentEditor.png")]
5 static override bool GetEntitySourceBudgetCost(IEntityComponentSource editableEntitySource, out notnull array<ref SCR_EntityBudgetValue> budgetValues)
13 static bool GetGroupSourceBudgetCost(IEntityComponentSource editableEntitySource, out notnull array<ref SCR_EntityBudgetValue> budgetValues)
15 if (!editableEntitySource)
19 if (editableEntityUIInfo)
20 return editableEntityUIInfo.GetGroupBudgetCost(budgetValues);
22 return !budgetValues.IsEmpty();
33 [
RplProp(onRplName:
"OnLeaderIdChanged")]
59 editableChild.SetParentEntity(
this);
70 if (editableChild && editableChild.GetParentEntity() ==
this)
71 editableChild.SetParentEntity(
null);
85 m_LeaderId = Replication.FindId(editableLeader);
109 waypoint.SetParentEntity(
this);
119 if (waypoint && waypoint.GetParentEntity() ==
this)
129 SCR_EditableWaypointComponent waypoint, currentWaypoint;
130 array<SCR_EditableWaypointComponent> waypoints =
new array<SCR_EditableWaypointComponent>;
132 bool hasNonEditable, hasNull;
133 AIWaypoint aiWaypoint;
134 AIWaypoint currentAiWaypoint =
m_Group.GetCurrentWaypoint();
135 array<AIWaypoint> aiWaypoints = {};
136 for (
int i = 0, count =
m_Group.GetWaypoints(aiWaypoints); i < count; i++)
138 aiWaypoint = aiWaypoints[i];
142 waypoints.Insert(waypoint);
143 if (aiWaypoint == currentAiWaypoint)
144 currentWaypoint = waypoint;
148 hasNonEditable =
true;
158 Log(
"Group contains null waypoints!",
true, LogLevel.WARNING);
159 else if (!waypoints.IsEmpty() && hasNonEditable)
160 Log(
"Group has a mix of editable and non-editable waypoints. Please use only one of those!",
true, LogLevel.WARNING);
162 SCR_EditableWaypointComponent prevWaypoint;
163 for (
int i = 0, count = waypoints.Count(); i < count; i++)
165 waypoint = waypoints[i];
166 waypoint.SetWaypointIndex(i + 1, waypoint == currentWaypoint, prevWaypoint);
167 prevWaypoint = waypoint;
198 SCR_EditableCharacterComponent editableCharacter = SCR_EditableCharacterComponent.Cast(entity);
199 if (editableCharacter)
200 editableCharacter.OnFactionChanged();
244 faction =
m_Group.GetFaction();
269 return m_Group.GetPlayerAndAgentCount();
300 array<AIWaypoint> aiWaypoints = {};
301 for (
int i = 0, count =
m_Group.GetWaypoints(aiWaypoints); i < count; i++)
303 SCR_EditableWaypointComponent waypoint = SCR_EditableWaypointComponent.Cast(
SCR_EditableEntityComponent.GetEditableEntity(aiWaypoints[i]));
311 m_Group.RemoveWaypoint(aiWaypoints[i]);
317 override bool GetEntityBudgetCost(out notnull array<ref SCR_EntityBudgetValue> outBudgets, IEntity owner =
null)
329 array<AIAgent> agentsInGroup = {};
330 SCR_EditableCharacterComponent editableCharacter;
331 m_Group.GetAgents(agentsInGroup);
333 foreach (AIAgent agent : agentsInGroup)
335 IEntity controlledEntity = agent.GetControlledEntity();
337 if (!controlledEntity)
340 editableCharacter = SCR_EditableCharacterComponent.Cast(controlledEntity.FindComponent(SCR_EditableCharacterComponent));
342 array<ref SCR_EntityBudgetValue> characterBudget = {};
343 editableCharacter.GetEntityBudgetCost(characterBudget);
356 array<ref SCR_EntityBudgetValue> groupBudgetCosts = {};
357 ResourceName resName =
GetOwner().GetPrefabData().GetPrefabName();
358 IEntityComponentSource componentSourceC;
360 Resource prefabResource = Resource.Load(resName);
364 BaseResourceObject baseResourceC = prefabResource.GetResource();
368 IEntitySource entitySourceC = baseResourceC.ToEntitySource();
372 for (
int i = 0, count = entitySourceC.GetComponentCount(); i < count; i++)
374 componentSourceC = entitySourceC.GetComponent(i);
377 array<ref SCR_EntityBudgetValue> gropBudgetCosts = {};
386 override bool CanDuplicate(out notnull set<SCR_EditableEntityComponent> outRecipients)
420 set<SCR_EditableEntityComponent> children =
new set<SCR_EditableEntityComponent>();
425 if (child.CanDestroy())
435 set<SCR_EditableEntityComponent> children =
new set<SCR_EditableEntityComponent>();
440 if (!child.IsDestroyed())
452 if (!
m_Group || !rpl || rpl.IsProxy())
455 bool isGroupEmpty =
m_Group.GetAgentsCount() == 0;
465 set<SCR_EditableEntityComponent> children =
new set<SCR_EditableEntityComponent>();
468 bool isDestroyed =
true;
472 isDestroyed &= child.Destroy();
492 if (forceVehicleCompartments.IsEmpty())
505 if (parentEntity) parentType = parentEntity.GetEntityType();
516 set<SCR_EditableEntityComponent> children =
new set<SCR_EditableEntityComponent>;
518 if (children.IsEmpty() && !parentEntityPrev)
533 child.SetParentEntity(parentEntity);
545 super.OnParentEntityChanged(parentEntity, parentEntityPrev, changedByUser);
554 super.OnCreatedServer(placedEditorComponent);
560 int numberOfMembersToSpawn =
m_Group.GetNumberOfMembersToSpawn();
561 if (numberOfMembersToSpawn < 1)
568 if (!budgetComponent)
573 aiBudget.ReserveBudget(numberOfMembersToSpawn + 1);
588 if (!budgetComponent)
593 aiBudget.UnreserveBudget(
m_Group.GetNumberOfMembersToSpawn() + 1);
601 if (isAdded && Replication.FindId(child) ==
m_LeaderId)
607 switch (child.GetEntityType())
611 SCR_EditableCharacterComponent childCharacter = SCR_EditableCharacterComponent.Cast(child);
615 AIAgent childAgent = childCharacter.GetAgent();
625 if (groupFaction && groupFaction != childCharacter.GetFaction())
627 FactionAffiliationComponent charactedFactionComponent = FactionAffiliationComponent.Cast(childCharacter.GetOwner().FindComponent(FactionAffiliationComponent));
628 if (charactedFactionComponent)
629 charactedFactionComponent.SetAffiliatedFaction(groupFaction);
636 m_Group.RemoveAgent(childAgent);
644 AIWaypoint waypoint = AIWaypoint.Cast(child.GetOwner());
651 array<AIWaypoint> waypoints = {};
652 m_Group.GetWaypoints(waypoints);
653 if (waypoints.Find(waypoint) == -1)
658 m_Group.RemoveWaypoint(waypoint);
669 if (DiagMenu.GetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_DISABLE))
672 super.OnPostInit(owner);
692 SCR_GroupIdentityComponent groupIdentity = SCR_GroupIdentityComponent.Cast(owner.FindComponent(SCR_GroupIdentityComponent));
709 Print(
"SCR_EditableGroupComponent must be on SCR_AIGroup!", LogLevel.ERROR);
713 Print(
"SCR_EditableGroupComponent entity type must be set to GROUP!", LogLevel.ERROR);