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)
22 return !budgetValues.IsEmpty();
33 [
RplProp(onRplName:
"OnLeaderIdChanged")]
47 static ResourceName AI_WAYPOINT_CYCLE =
"{35BD6541CBB8AC08}Prefabs/AI/Waypoints/AIWaypoint_Cycle.et";
52 super.OnDelete(owner);
55 const int missingAgents =
m_Group.GetSpawnQueueSize();
58 if(
m_Group.GetSpawnQueueSize() == 0)
71 aiBudget.UnreserveBudget(missingAgents);
81 array<AIWaypoint> waypoints = {};
86 m_Group.GetWaypoints(waypoints);
107 for (
int i = 0, count = waypoints.Count(); i < count; i++)
109 m_Group.AddWaypoint(waypoints[i]);
116 array<AIWaypoint> waypoints = {};
117 m_Group.GetWaypoints(waypoints);
118 for (
int i = 0, count = waypoints.Count(); i < count; i++)
159 if (!budgetComponent)
164 aiBudget.UnreserveBudget(1);
215 waypoint.SetParentEntity(
this);
227 if (waypoint && waypoint.GetParentEntity() ==
this)
239 m_Group.GetWaypoints(outWaypoints);
241 return outWaypoints.Count();
248 array<SCR_EditableWaypointComponent> waypoints =
new array<SCR_EditableWaypointComponent>;
250 bool hasNonEditable, hasNull;
251 AIWaypoint aiWaypoint;
252 AIWaypoint currentAiWaypoint =
m_Group.GetCurrentWaypoint();
253 array<AIWaypoint> aiWaypoints = {};
256 aiWaypoint = aiWaypoints[i];
260 waypoints.Insert(waypoint);
261 if (aiWaypoint == currentAiWaypoint)
262 currentWaypoint = waypoint;
266 hasNonEditable =
true;
277 Log(
"Group contains null waypoints!",
true,
LogLevel.WARNING);
279 else if (!waypoints.IsEmpty() && hasNonEditable)
281 Log(
"Group has a mix of editable and non-editable waypoints. Please use only one of those!",
true,
LogLevel.WARNING);
285 for (
int i = 0, count = waypoints.Count(); i < count; i++)
287 waypoint = waypoints[i];
288 waypoint.SetWaypointIndex(i + 1, waypoint == currentWaypoint, prevWaypoint);
289 prevWaypoint = waypoint;
320 SCR_EditableCharacterComponent editableCharacter = SCR_EditableCharacterComponent.Cast(entity);
321 if (editableCharacter)
322 editableCharacter.OnFactionChanged();
366 faction =
m_Group.GetFaction();
391 return m_Group.GetPlayerAndAgentCount();
423 array<AIWaypoint> aiWaypoints =
new array<AIWaypoint>;
434 m_Group.RemoveWaypoint(aiWaypoints[i]);
452 array<AIAgent> agentsInGroup = {};
453 SCR_EditableCharacterComponent editableCharacter;
454 m_Group.GetAgents(agentsInGroup);
456 foreach (AIAgent agent : agentsInGroup)
458 IEntity controlledEntity = agent.GetControlledEntity();
460 if (!controlledEntity)
463 editableCharacter = SCR_EditableCharacterComponent.Cast(controlledEntity.
FindComponent(SCR_EditableCharacterComponent));
465 array<ref SCR_EntityBudgetValue> characterBudget = {};
466 editableCharacter.GetEntityBudgetCost(characterBudget);
479 array<ref SCR_EntityBudgetValue> groupBudgetCosts = {};
491 IEntitySource entitySourceC = baseResourceC.ToEntitySource();
495 for (
int i = 0, count = entitySourceC.GetComponentCount(); i < count; i++)
497 componentSourceC = entitySourceC.GetComponent(i);
500 array<ref SCR_EntityBudgetValue> gropBudgetCosts = {};
509 override bool CanDuplicate(out notnull set<SCR_EditableEntityComponent> outRecipients)
543 set<SCR_EditableEntityComponent> children =
new set<SCR_EditableEntityComponent>();
548 if (child.CanDestroy())
558 set<SCR_EditableEntityComponent> children =
new set<SCR_EditableEntityComponent>();
563 if (!child.IsDestroyed())
575 if (!
m_Group || !rpl || rpl.IsProxy())
578 bool isGroupEmpty =
m_Group.GetAgentsCount() == 0;
586 if (!super.RplSave(writer))
597 if (!super.RplLoad(reader))
600 int areWaypointsCycled;
601 reader.ReadBool(areWaypointsCycled);
613 set<SCR_EditableEntityComponent> children =
new set<SCR_EditableEntityComponent>();
616 bool isDestroyed =
true;
620 isDestroyed &= child.Destroy(editorPlayerID);
640 if (forceVehicleCompartments.IsEmpty())
664 set<SCR_EditableEntityComponent> children =
new set<SCR_EditableEntityComponent>;
666 if (children.IsEmpty() && !parentEntityPrev)
681 child.SetParentEntity(parentEntity);
693 super.OnParentEntityChanged(parentEntity, parentEntityPrev, changedByUser);
702 super.OnCreatedServer(placedEditorComponent);
708 int numberOfMembersToSpawn =
m_Group.GetNumberOfMembersToSpawn();
709 if (numberOfMembersToSpawn < 1)
716 if (!budgetComponent)
721 aiBudget.ReserveBudget(numberOfMembersToSpawn);
758 SCR_EditableCharacterComponent childCharacter = SCR_EditableCharacterComponent.Cast(child);
762 AIAgent childAgent = childCharacter.GetAgent();
772 if (groupFaction && groupFaction != childCharacter.GetFaction())
774 FactionAffiliationComponent charactedFactionComponent = FactionAffiliationComponent.Cast(childCharacter.GetOwner().FindComponent(FactionAffiliationComponent));
775 if (charactedFactionComponent)
776 charactedFactionComponent.SetAffiliatedFaction(groupFaction);
783 m_Group.RemoveAgent(childAgent);
790 AIWaypoint waypoint = AIWaypoint.Cast(child.GetOwner());
794 array<AIWaypoint> waypoints = {};
801 if (!waypoints.Contains(waypoint))
803 waypoints.Insert(waypoint);
806 for (
int i = 0, count = waypoints.Count(); i < count; i++)
816 m_Group.GetWaypoints(waypoints);
817 if (!waypoints.Contains(waypoint))
826 int waypointID = waypoints.Find(waypoint);
827 if (waypointID != -1)
829 waypoints.Remove(waypointID);
835 m_Group.RemoveWaypoint(waypoint);
850 super.OnPostInit(owner);
870 SCR_GroupIdentityComponent groupIdentity = SCR_GroupIdentityComponent.Cast(owner.
FindComponent(SCR_GroupIdentityComponent));
890 Print(
"SCR_EditableGroupComponent must be on SCR_AIGroup!",
LogLevel.ERROR);
894 Print(
"SCR_EditableGroupComponent entity type must be set to GROUP!",
LogLevel.ERROR);
ArmaReforgerScripted GetGame()
SCR_AIGroupSettingsComponentClass m_Group
void OnAgentRemoved(AIGroup group, AIAgent agent)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
void OnFactionChanged(Faction faction)
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
override void OnParentEntityChanged(SCR_EditableEntityComponent parentEntity, SCR_EditableEntityComponent parentEntityPrev, bool changedByUser)
void GetPrefabBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
SCR_AIGroup GetAIGroupComponent()
void RemoveAllWaypointsFromGroup()
void EnableCycledWaypointsBroadcast(bool enable)
void OnIdentityChange(SCR_MilitarySymbol symbol, LocalizedString name)
ref SCR_EditableGroupUIInfo m_GroupInfo
ref array< ECompartmentType > m_aForceSpawnVehicleCompartments
SCR_EditableEntityComponent m_Leader
void OnAfterAllMembersSpawned()
void OnWaypointRemoved(AIWaypoint wp)
void AddWaypoints(array< AIWaypoint > waypoints)
AIWaypointCycle m_CycleWaypoint
bool m_bAreWaypointsCycled
SCR_PlacingEditorComponent m_PlacedEditorComponent
void SetLeader(SCR_EditableEntityComponent leader)
void OnAllMembersSpawned(SCR_AIGroup group)
void GetRuntimeBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
void SCR_EditableGroupComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void EnableCycledWaypoints(bool enable)
bool AreCycledWaypointsEnabled()
void ClearWaypoints()
Remove all waypoints from the group.
ref ScriptInvoker Event_OnUIRefresh
int GetGroupWaypoints(array< AIWaypoint > outWaypoints)
void SCR_EditableWaypointComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
override SCR_UIInfo GetInfo()
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
proto external Managed FindComponent(typename typeName)
proto external EntityPrefabData GetPrefabData()
Object holding reference to resource. In destructor release the resource.
Replication item identifier.
SCR_EditableEntityCoreBudgetSetting GetBudgetSetting(EEditableEntityBudget budgetType)
void GetChildren(out notnull set< SCR_EditableEntityComponent > entities, bool onlyDirect=false, bool skipIgnored=false)
SCR_EditableEntityComponent GetChild(int index)
void SetVisible(bool show)
RplComponent GetRplComponent()
void ForceVehicleCompartments(notnull array< ECompartmentType > forceVehicleCompartments)
void SetInfoInstance(SCR_UIInfo info)
void OnParentEntityChanged(SCR_EditableEntityComponent parentEntity, SCR_EditableEntityComponent parentEntityPrev, bool changedByUser)
SCR_EditableEntityComponent GetAIEntity()
ScriptInvoker GetOnUIRefresh()
static SCR_EditableEntityComponent GetEditableEntity(IEntity owner)
bool GetPos(out vector pos)
EEditableEntityType GetEntityType(IEntity owner=null)
SCR_EditableEntityComponent SetParentEntity(SCR_EditableEntityComponent parentEntity, bool changedByUser=false)
override bool RplLoad(ScriptBitReader reader)
bool Destroy(int editorPlayerID=0)
void OnChildEntityChanged(SCR_EditableEntityComponent child, bool isAdded)
bool CanDuplicate(out notnull set< SCR_EditableEntityComponent > outRecipients)
override bool RplSave(ScriptBitWriter writer)
void OnCreatedServer(notnull SCR_PlacingEditorComponent placedEditorComponent)
bool GetEntityBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets, IEntity owner=null)
SCR_EditableEntityComponent GetParentEntity()
SCR_EditableEntityComponent GetAIGroup()
bool GetGroupBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
proto external GenericEntity GetOwner()
Get owner entity.
void OnAgentAdded(AIAgent agent)
void OnWaypointAdded(AIWaypoint wp)
void OnCurrentWaypointChanged(AIWaypoint _currentWp, AIWaypoint _prevWp)
void OnWaypointCompleted(AIWaypoint wp)
void OnLeaderChanged(AIAgent currentLeader, AIAgent prevLeader)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.