1[
ComponentEditorProps(
category:
"GameScripted/Editor", description:
"Main conflict editor component to handle building mode placing", icon:
"WBData/ComponentEditorProps/componentEditor.png")]
19 [
Attribute(
"{C7EE4C198B641E21}Sounds/Editor/BaseBuilding/Editor_BaseBuilding.acp", UIWidgets.ResourceNamePicker,
"Sound project file to be used for building",
"acp")]
20 protected ResourceName m_sSoundFile;
22 [
Attribute(
"", UIWidgets.ResourcePickerThumbnail,
"WP that is spawned as default for placed AI.",
"et")]
43 if (!factionAffiliationComp)
46 Faction faction = factionAffiliationComp.GetAffiliatedFaction();
48 return factionAffiliationComp.GetDefaultAffiliatedFaction();
57 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
58 if (!providerComponent)
61 base = SCR_MilitaryBaseComponent.Cast(
m_Provider.FindComponent(SCR_MilitaryBaseComponent));
75 SCR_CampaignBuildingPlacingObstructionEditorComponent obstructionComponent = SCR_CampaignBuildingPlacingObstructionEditorComponent.Cast(
FindEditorComponent(SCR_CampaignBuildingPlacingObstructionEditorComponent,
true,
true));
76 if (!obstructionComponent)
79 obstructionComponent.OnPreviewCreated(previewEnt);
102 BaseGameMode gameMode =
GetGame().GetGameMode();
104 SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
117 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
118 if (!providerComponent)
122 array<ref SCR_EntityBudgetValue> budgetCosts = {};
124 SCR_EditableEntityCoreBudgetSetting budgetSettings;
126 m_BudgetManager.GetBudgetCostsDontDiscardCampaignBudget(entitySource, budgetCosts);
128 return providerComponent.IsThereEnoughBudgetToSpawn(budgetCosts);
137 int cooldownTime, aiBudgetValue;
138 int count = entities.Count();
139 SCR_EditorLinkComponent linkComponent;
141 SCR_CampaignBuildingCompositionComponent compositionComponent;
144 for (
int i = 0; i < count; i++)
146 IEntity entityOwner = entities[i].GetOwnerScripted();
150 linkComponent = SCR_EditorLinkComponent.Cast(entityOwner.
FindComponent(SCR_EditorLinkComponent));
152 SCR_EditorLinkComponent.IgnoreSpawning(
false);
155 if (editableGroupComponent)
160 aiGroup = editableGroupComponent.GetAIGroupComponent();
166 params.TransformMode = ETransformMode.WORLD;
167 params.Transform[3] = aiGroup.GetOrigin();
170 aiGroup.AddWaypointAt(defendWP, 0);
174 compositionComponent = SCR_CampaignBuildingCompositionComponent.Cast(entityOwner.
FindComponent(SCR_CampaignBuildingCompositionComponent));
175 if (compositionComponent)
206 array<ref SCR_EntityBudgetValue> outBudgets = {};
207 entity.GetEntityChildrenBudgetCost(outBudgets);
209 if (outBudgets.IsEmpty())
210 entity.GetEntityBudgetCost(outBudgets);
214 if (outBudget.GetBudgetType() == budget)
215 return outBudget.GetBudgetValue();
233 int id = managerEnt.GetPlayerID();
235 compositionComponent.SetBuilderId(
id);
236 compositionComponent.SetProviderEntity(provider);
239 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(provider.
FindComponent(SCR_CampaignBuildingProviderComponent));
240 if (!providerComponent)
243 SCR_MilitaryBaseComponent
base = providerComponent.GetMilitaryBaseComponent();
248 compositionComponent.SetClearProviderEvent(ent);
260 array<AIAgent> outAgents = {};
263 SCR_CampaignBuildingProviderComponent providerComponent;
265 aiGroup.GetAgents(outAgents);
267 foreach (AIAgent agent: outAgents)
269 ent = agent.GetControlledEntity();
271 if (editableEntityComponent)
274 providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
275 if (!providerComponent)
278 providerComponent.SetOnEntityKilled(agent.GetControlledEntity());
301 Math3D.MatrixIdentity4(transform);
304 if (soundEvent && pos)
313 SCR_EditorLinkComponent.IgnoreSpawning(
true);
316 SCR_ServicePointComponent.SpawnAsOffline(
true);
318 super.CreateEntityServer(
params, prefabID, playerID, entityIndex, isQueue, recipientIds, canBePlayer, holderId);
325 BaseGameMode gameMode =
GetGame().GetGameMode();
329 SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
330 if (!buildingManagerComponent)
343 SCR_CampaignBuildingPlacingObstructionEditorComponent obstructionComponent = SCR_CampaignBuildingPlacingObstructionEditorComponent.Cast(
FindEditorComponent(SCR_CampaignBuildingPlacingObstructionEditorComponent,
true,
true));
344 if (!obstructionComponent)
350 if (obstructionComponent.IsPreviewOutOfRange(m_InstantPlacingParam, outNotification))
356 SCR_CampaignBuildingPlacingHQBaseEditorComponent hqBaseEditorComponent = SCR_CampaignBuildingPlacingHQBaseEditorComponent.Cast(
FindEditorComponent(SCR_CampaignBuildingPlacingHQBaseEditorComponent,
true,
true));
357 if (hqBaseEditorComponent && hqBaseEditorComponent.IsNearAnyHQ(outNotification))
363 return super.CanCreateEntity(outNotification, previewStateToShow,
params, prefabID) && obstructionComponent.CanCreate(outNotification, previewStateToShow);
369 if (!super.CanPlaceEntityServer(editableEntitySource, blockingBudget, updatePreview, showNotification, prefabID, playerID,
params))
377 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
378 if (providerComponent && providerComponent.IsBudgetToEvaluate(
EEditableEntityBudget.COOLDOWN) && providerComponent.GetCooldownValue(playerID) > 0)
391 array<EEditableEntityLabel> entityLabels = {};
405 FactionAffiliationComponent fac = FactionAffiliationComponent.Cast(
m_Provider.FindComponent(FactionAffiliationComponent));
412 while (parent && fac == null)
414 fac = FactionAffiliationComponent.Cast(parent.
FindComponent(FactionAffiliationComponent));
423 if (!providerFaction)
427 providerFaction =
SCR_Faction.Cast(fac.GetDefaultAffiliatedFaction());
428 if (!providerFaction)
435 SCR_CampaignBuildingProviderComponent providerComp = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
439 array<EEditableEntityLabel> providerLabels = providerComp.GetAvailableTraits();
440 if (providerLabels.Contains(
EEditableEntityLabel.SERVICE_HQ) && !SCR_CampaignBuildingProviderComponent.CanBeUsedToEstablishBase(
m_Provider, m_Manager.GetPlayerID()))
446 if (!entityLabels.Contains(providerLabel))
449 matchingLabel =
true;
460 array<EEditableEntityLabel> validBlackListLabels = {};
464 if (entityLabels.Contains(blacklistedLabel))
474 super.EOnEditorActivate();
489 super.EOnEditorOpen();
497 super.EOnEditorClose();
504 super.EOnEditorOpenServer();
509 private void SetInitialEvent()
519 private void InitVariables()
539 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
540 if (!providerComponent)
553 int playerId = managerEnt.GetPlayerID();
555 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
556 if (!providerComponent)
559 providerComponent.SetPlayerCooldown(playerId, cooldownTime);
565 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
566 if (!providerComponent)
569 providerComponent.AddAIValue(value);
ArmaReforgerScripted GetGame()
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_CampaignBuildingEditorComponent m_CampaignBuildingComponent
ResourceName GetOutlineToSpawn(notnull SCR_EditableEntityComponent entity)
Search for the outline that is assigned to this composition to be spawned.
int GetEntityBudgetValue(notnull SCR_EditableEntityComponent entity, EEditableEntityBudget budget)
Get value of given budget for given entity.
ref map< EEditableEntityBudget, int > m_accumulatedCampaignBudgetChanges
void SetAIBudget(int value)
bool GetProviderBase(out SCR_MilitaryBaseComponent base)
Return the base which belongs to a provider (if any).
void GetAIBudgetClient(int prefabID, SCR_EditableEntityComponent entity)
void SetAiFlag(SCR_EditableEntityComponent component)
bool AreLabelsMatching(notnull array< EEditableEntityLabel > entityLabels)
Faction GetProviderAffiliatedFaction()
void SetCooldownTimer(int cooldownTime)
void OnPreviewCreated(SCR_EditablePreviewEntity previewEnt)
Method called when the preview of prefab to build is created.
ResourceName m_sDefaultAIWP
void InitGroup(SCR_AIGroup aiGroup)
Init spawned AI group (set events and flags).
void OnPlaceEntityServer(int prefabID, SCR_EditableEntityComponent entity)
void GetCooldownTimeClient(int prefabID, SCR_EditableEntityComponent entity)
The placement is driven by a cooldown set on server. However for a client needs (to show him a remain...
bool UseCooldown()
Check if the cooldown is set with this provider.
ECantBuildNotificationType
@ BLOCKED
User has this asset blocked so it should not be possible to interact with it until unblocked.
void PlaySoundEvent(vector pos, string soundEvent)
ECantBuildNotificationType m_eBlockingReason
void SetInitialCanBeCreatedState(notnull SCR_EditablePreviewEntity previewEnt)
Set the initial state of the preview can / can't be created (based on the place where player place th...
void SetProviderAndBuilder(notnull SCR_CampaignBuildingCompositionComponent compositionComponent)
Set the provider and builder entity to composition. Provider is the entity to which a composition bel...
SCR_EditablePreviewEntity m_PreviewEnt
ScriptedGameTriggerEntity m_AreaTrigger
SCR_PreviewEntityEditorComponent m_PreviewManager
void SCR_EditableGroupComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
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 IEntity GetParent()
Object holding reference to resource. In destructor release the resource.
Replication item identifier.
ScriptInvoker GetOnInit()
void EOnEditorOpen()
When the editor is opened.
void EOnEditorDeactivateServer()
EntityComponentPrefabData GetEditorComponentData()
void EOnEditorOpenServer()
When the editor is opened (called on server).
void EOnEditorClose()
When the editor is closed.
SCR_BaseEditorComponent FindEditorComponent(typename type, bool showError=false, bool modeFirst=false)
SCR_EditorManagerEntity GetManager()
void EOnEditorActivateServer()
ResourceName GetCompositionOutline(notnull SCR_EditableEntityComponent entity)
Search all SCR_CampaignBuildingCompositionLayoutManager entry and try to find a matching composition....
bool ContainPrefab(ResourceName res)
ref array< ResourceName > m_aClippingCheckIgnoredPrefabs
int GetValidBlackListedLabels(out notnull array< EEditableEntityLabel > validBlackListLabels)
void SetEntityFlag(EEditableEntityFlag flag, bool toSet)
int GetEntityLabels(out notnull array< EEditableEntityLabel > entityLabels)
static SCR_EditableEntityUIInfo ExtractEditableUIInfoFromPrefab(ResourceName prefab)
Network packet of variables for entity placing and transformation.
EEditableEntityLabel GetFactionLabel()
ResourceName GetPrefab(int index)
void SCR_PlacingEditorComponentClass(IEntityComponentSource componentSource, IEntitySource parentSource, IEntitySource prefabSource)
bool IsThereEnoughBudgetToSpawn(IEntityComponentSource entitySource)
void CreateEntityServer(SCR_EditorPreviewParams params, RplId prefabID, int playerID, int entityIndex, bool isQueue, array< RplId > recipientIds, bool canBePlayer, RplId holderId)
ScriptInvoker GetOnPlaceEntityServer()
bool CanCreateEntity(out ENotification outNotification=-1, inout SCR_EPreviewState previewStateToShow=SCR_EPreviewState.PLACEABLE, SCR_EditorPreviewParams params=null, int prefabID=-1)
override void EOnEditorActivate()
ScriptInvoker GetOnPlaceEntity()
bool CanPlaceEntityServer(IEntityComponentSource editableEntitySource, out EEditableEntityBudget blockingBudget, bool updatePreview, bool showNotification, int prefabID=-1, int playerID=-1, SCR_EditorPreviewParams params=null)
void OnEntityCreatedServer(array< SCR_EditableEntityComponent > entities)
void OnBeforeEntityCreatedServer(ResourceName prefab)
ScriptInvoker GetOnPreviewCreate()
proto external GenericEntity GetOwner()
Get owner entity.
EEditableEntityFlag
Unique flags of the entity.
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.