13 protected static const int UNLIMITED_PROP_BUDGET = -1;
25 array<ref SCR_RankInfo> ranks = factionManager.GetFactionRanks(m_Manager.GetPlayerID()).GetAllRanks();
46 Debug.Error(
"SCR_CampaignBuildingBudgetEditorComponent was unable to find SCR_CampaignBuildingEditorComponent on " +
m_Owner);
86 Debug.Error(
"Recovering of SCR_CampaignBuildingBudgetEditorComponent was unable to find SCR_CampaignBuildingEditorComponent on " +
m_Owner +
" and because of that editor will be closed now!");
107 [
Obsolete(
"SCR_CampaignBuildingBudgetEditorComponent.RefreshResourcesComponent() should be used instead.")]
141 [
Obsolete(
"SCR_CampaignBuildingBudgetEditorComponent.OnBaseResourcesChanged() should be used instead.")]
164 maxBudget = consumer.GetAggregatedMaxResourceValue();
221 AIWorld aiWorld =
GetGame().GetAIWorld();
225 maxBudget = aiWorld.GetLimitOfActiveAIs();
239 if (!providerComponent)
252 return consumer.GetAggregatedMaxResourceValue() - consumer.GetAggregatedResourceValue();
282 return providerComponent.GetCurrentPropValue();
288 return providerComponent.GetCurrentAIValue();
291 AIWorld aiWorld =
GetGame().GetAIWorld();
295 return aiWorld.GetCurrentNumOfActiveAIs();
309 if (!providerComponent)
312 return providerComponent.GetMaxBudgetValue(budget);
323 if (!providerComponent)
329 return providerComponent.HasCooldownSet(m_Manager.GetPlayerID());
339 if (!providerComponent)
342 return providerComponent.GetCooldownValue(m_Manager.GetPlayerID());
350 if (!campaignGameMode)
357 if (!providerComponent)
364 Faction faction = player.GetFaction();
368 IEntity providerEnt = providerComponent.GetOwner();
369 FactionAffiliationComponent factionComp = FactionAffiliationComponent.Cast(providerEnt.
FindComponent(FactionAffiliationComponent));
376 while (parent && factionComp == null)
378 factionComp = FactionAffiliationComponent.Cast(parent.
FindComponent(FactionAffiliationComponent));
386 providerEnt = parent;
391 if (faction != factionComp.GetDefaultAffiliatedFaction())
396 if (faction != factionComp.GetAffiliatedFaction())
400 if (!campaignGameMode.GetBaseManager().CanFactionBuildNewBase(faction))
407 array<SCR_Task> tasks = {};
410 SCR_EstablishBaseTaskEntity establishTask;
411 SCR_EstablishBaseTaskEntity nearestRelevantTask;
414 float distanceToNearestRelevantTask;
418 establishTask = SCR_EstablishBaseTaskEntity.Cast(
task);
423 distance =
vector.DistanceSqXZ(providerComponent.GetOwner().GetOrigin(), establishTask.GetOrigin());
425 if (!nearestRelevantTask ||
distance < distanceToNearestRelevantTask)
427 nearestRelevantTask = establishTask;
428 distanceToNearestRelevantTask =
distance;
432 int threshold = SCR_CampaignFactionCommanderHandlerComponent.Cast(SCR_FactionCommanderHandlerComponent.GetInstance()).GetBaseEstablishingRadius();
434 if (!nearestRelevantTask || distanceToNearestRelevantTask > (threshold * threshold))
446 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerId);
447 if (!playerController)
448 return SCR_ECharacterRank.INVALID;
472 if (consumer.GetAggregatedResourceValue() - budgetChange <= 0)
473 Event_OnBudgetMaxReached.Invoke(entityBudget,
true);
489 if (!providerComponent)
495 array<ref EEditableEntityBudget> budgetsType = {};
496 providerComponent.GetBudgetTypesToEvaluate(budgetsType);
498 SCR_EditableEntityCoreBudgetSetting budget;
500 for (
int i = budgetsType.Count() - 1; i >= 0; i--)
507 m_BudgetSettingsMap.Insert(budgetType, budget);
516 bool canPlace =
true;
519 array<ref SCR_EntityBudgetValue> budgetCosts = {};
530 canPlace = canPlace &&
CanPlace(budgetCosts, blockingBudget);
538 if (showNotification)
554 switch (blockingBudget)
571 rankName.Replace(
"RANK_",
string.Empty);
572 SCR_ECharacterRank requiredRank =
typename.StringToEnum(SCR_ECharacterRank, rankName);
589 if (campaignGameMode && faction && !campaignGameMode.GetBaseManager().CanFactionBuildNewBase(faction))
610 SCR_NotificationsComponent.SendLocal(
ENotification.EDITOR_AILIMIT);
616 SCR_NotificationsComponent.SendLocal(
ENotification.EDITOR_PLACING_BUDGET_MAX);
626 const bool valid = super.GetMaxBudget(
type, budget);
632 int newMaxBudget = budget.GetBudgetValue();
645 newMaxBudget = consumer.GetAggregatedResourceValue();
723 AIWorld aiWorld =
GetGame().GetAIWorld();
727 newMaxBudget = aiWorld.GetLimitOfActiveAIs();
732 budget.SetBudgetValue(newMaxBudget);
743 array<EEditableEntityBudget> blockingBudgets = {};
744 int initialPriorityOrder = -1;
749 if (!
CanPlace(budgetCost, blockingBudget))
753 SCR_EditableEntityCoreBudgetSetting budgetSettings =
GetBudgetSetting(blockingBudget);
759 if (!budgetUIInfo && initialPriorityOrder == -1)
761 blockingBudgetCandidate = blockingBudget;
771 blockingBudgetCandidate = blockingBudget;
778 if (blockingBudgetCandidate == -1)
781 blockingBudget = blockingBudgetCandidate;
796 if (!providerComponent)
799 return providerComponent.IsBudgetToEvaluate(blockingBudget);
818 array<ref SCR_EntityBudgetValue> entityChildrenBudgetCosts = {};
ArmaReforgerScripted GetGame()
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
bool CheckAndRecoverCampaignBuildingComponent()
void OnBaseSuppliesChanged(int supplies)
void OnResourceTypeEnabledChanged(array< EResourceType > disabledResourceTypes)
bool RefreshResourcesComponent()
SCR_ECharacterRank m_eHighestRank
bool HasCooldownTime()
Return current cooldown timer state.
SCR_CampaignBuildingEditorComponent m_CampaignBuildingComponent
void OnBaseResourcesChanged(SCR_ResourceConsumer consumer, int previousValue)
bool RefreshSuppliesComponent()
void OnTargetBaseChanged(IEntity targetEntity)
SCR_CampaignSuppliesComponent m_SuppliesComponent
void CanPlaceOwnerCampaignBuilding(bool canPlace, EEditableEntityBudget blockingBudget)
SCR_ECharacterRank GetUserRank()
int GetProviderMaxValue(EEditableEntityBudget budget)
override int GetCurrentBudgetValue(EEditableEntityBudget type)
bool CanPlaceResultCampaignBuilding(bool canPlace, bool showNotification, EEditableEntityBudget blockingBudget)
SCR_EditableEntityCore m_EntityCore
int GetMaxBudgetValue(EEditableEntityBudget budget)
Return max value of the given budget if this budget is added to be evaluated with this provider and h...
void SCR_CampaignSuppliesComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_CharacterRankComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
void OnResourceTypeEnabledChanged()
SCR_ResourceComponent m_ResourceComponent
void SCR_Task(IEntitySource src, IEntity parent)
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()
void EOnEditorDeactivate()
SCR_BaseEditorComponent FindEditorComponent(typename type, bool showError=false, bool modeFirst=false)
SCR_EditorManagerEntity GetManager()
void EOnEditorActivateServer()
ScriptInvokerBase< SCR_BaseGameMode_OnResourceEnabledChanged > GetOnResourceTypeEnabledChanged()
void UpdatePreviewCost(notnull array< ref SCR_EntityBudgetValue > budgetCosts)
bool GetEntitySourcePreviewBudgetCosts(IEntityComponentSource editableEntitySource, out notnull array< ref SCR_EntityBudgetValue > budgetCosts)
override void EOnEditorActivate()
SCR_EditableEntityCoreBudgetSetting GetBudgetSetting(EEditableEntityBudget budgetType)
bool CanPlace(notnull array< ref SCR_EntityBudgetValue > budgetCosts, out EEditableEntityBudget blockingBudget)
bool GetMaxBudget(EEditableEntityBudget type, out SCR_EntityBudgetValue budget)
void RefreshBudgetSettings()
Get default budget definitions from core, budget values not synced on client, use GetCurrentBudget fo...
void GetEntityTypeBudgetCost(EEditableEntityType entityType, out array< ref SCR_EntityBudgetValue > budgetCosts)
bool CanPlaceEntitySource(IEntityComponentSource editableEntitySource, out EEditableEntityBudget blockingBudget, bool isPlacingPlayer=false, bool updatePreview=true, bool showNotification=true)
bool GetEntityPreviewBudgetCosts(SCR_EditableEntityUIInfo entityUIInfo, out notnull array< ref SCR_EntityBudgetValue > budgetCosts)
bool IsBudgetCapEnabled()
void FilterAvailableBudgets(inout notnull array< ref SCR_EntityBudgetValue > budgetCosts)
void OnEntityCoreBudgetUpdatedOwner(EEditableEntityBudget entityBudget, int budgetValue, int budgetChange, bool sendBudgetMaxEvent, bool budgetMaxReached)
int GetCurrentBudgetValue(EEditableEntityBudget type)
bool GetMaxBudgetValue(EEditableEntityBudget type, out int maxBudget)
void GetEntityAndChildrenBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
Get Entity and its children budgets.
EEditableEntityType GetEntityType()
bool GetEntityBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
void GetEntityChildrenBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
Get only Entity's children budget costs, i.e. cost of entities inside a composition entitiy.
SCR_RankContainer GetRanks()
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
static IEntity GetLocalControlledEntity()
SCR_RankInfo GetRankByID(SCR_ECharacterRank rankIdentifier)
SCR_ECharacterRank GetRankID()
enum EPhysicsLayerPresets Vehicle
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.