10 [
Attribute(
"", UIWidgets.ResourcePickerThumbnail,
"Prefab of trigger spawned on server to activate a building mode when player enters its range.",
"et")]
11 protected ResourceName m_sFreeRoamBuildingServerTrigger;
13 [
Attribute(
"", UIWidgets.ResourcePickerThumbnail,
"Prefab of trigger spawned only on clients, to visualize the building area and allow player build only within its radius.",
"et")]
16 [
Attribute(
"{58F07022C12D0CF5}Assets/Editor/PlacingPreview/Preview.emat", UIWidgets.ResourcePickerThumbnail,
"Material used when for the preview of the compositions outside of the building mode.",
category:
"Preview",
params:
"emat")]
22 [
Attribute(
"25", UIWidgets.EditBox,
"Refund percentage",
"")]
25 [
Attribute(
"10", UIWidgets.EditBox,
"How many times player has to perform build step to gain a XP reward",
"")]
29 [
Attribute(
"0", UIWidgets.CheckBox,
"If checked, only players of faction that match the owning faction of provider can disassemble composition")]
35 [
Attribute(
"", UIWidgets.ResourceNamePicker,
desc:
"Config with prefabs available to build. The config has to be the same as on Editor Mode - placing editor component..",
params:
"conf")]
43 protected int m_iBuildingCycle
58 IEntity providerEntity;
59 SCR_CampaignBuildingCompositionComponent campaignCompositionComponent = SCR_CampaignBuildingCompositionComponent.Cast(owner.FindComponent(SCR_CampaignBuildingCompositionComponent));
60 if (campaignCompositionComponent)
61 providerEntity = campaignCompositionComponent.GetProviderEntity();
74 component = SCR_ResourceComponent.FindResourceComponent(providerEntity);
90 return m_sFreeRoamBuildingServerTrigger;
124 [
Obsolete(
"SCR_CampaignBuildingManagerComponent.GetResourceComponent() should be used instead.")]
127 SCR_CampaignBuildingCompositionComponent campaignCompositionComponent = SCR_CampaignBuildingCompositionComponent.Cast(ownerEntity.FindComponent(SCR_CampaignBuildingCompositionComponent));
128 if (!campaignCompositionComponent)
131 IEntity providerEntity;
132 providerEntity = campaignCompositionComponent.GetProviderEntity();
145 return suppliesComponent !=
null;
156 m_iBuildingCycle = 0;
158 PlayerController playerController =
GetGame().GetPlayerController();
159 if (!playerController)
162 SCR_CampaignBuildingNetworkComponent networkComponent = SCR_CampaignBuildingNetworkComponent.Cast(playerController.FindComponent(SCR_CampaignBuildingNetworkComponent));
163 if (!networkComponent)
166 networkComponent.AddXPReward(playerController.GetPlayerId());
186 if (entity.GetOwner().IsLoaded())
191 if (campaign && campaign.IsSessionLoadInProgress())
195 array<ref SCR_EntityBudgetValue> budgets = {};
196 entity.GetEntityAndChildrenBudgetCost(budgets);
203 propBudgetValue = budget.GetBudgetValue();
207 IEntity entityOwner = entity.GetOwnerScripted();
208 SCR_ResourceComponent resourceComponent;
214 if (!resourceComponent.IsResourceTypeEnabled())
217 IEntity providerEntity = resourceComponent.GetOwner();
222 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(providerEntity.FindComponent(SCR_CampaignBuildingProviderComponent));
224 if (!providerComponent)
227 if (budgetChange < 0)
231 providerComponent.AddPropValue(-propBudgetValue);
236 generator.RequestGeneration(-budgetChange);
240 providerComponent.AddPropValue(propBudgetValue);
245 consumer.RequestConsumtion(budgetChange);
253 m_RplComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
273 SetEventMask(owner, EntityEvent.INIT);
287 if (!configContainer || !configContainer.IsValid())
324 void GetEditorMode(
int playerID, notnull IEntity provider,
bool userActionActivationOnly =
false,
bool userActionUsed =
false)
332 modeEntity = editorManager.CreateEditorMode(
EEditorMode.BUILDING,
false);
337 SetEditorMode(editorManager, modeEntity, playerID, provider, userActionActivationOnly, userActionUsed);
343 SCR_CampaignBuildingEditorComponent buildingComponent = SCR_CampaignBuildingEditorComponent.Cast(modeEntity.FindComponent(SCR_CampaignBuildingEditorComponent));
344 if (!buildingComponent)
347 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(provider.FindComponent(SCR_CampaignBuildingProviderComponent));
348 if (!providerComponent)
351 providerComponent.AddNewAvailableUser(playerID);
353 providerComponent.AddNewActiveUser(playerID);
355 buildingComponent.AddProviderEntityEditorComponent(providerComponent);
357 if (!editorManager.IsOpened())
358 editorManager.SetCurrentMode(
EEditorMode.BUILDING);
360 if (userActionActivationOnly || userActionUsed)
373 providerComponent.SetCheckProviderMove();
406 SCR_CampaignBuildingEditorComponent buildingComponent = SCR_CampaignBuildingEditorComponent.Cast(modeEntity.FindComponent(SCR_CampaignBuildingEditorComponent));
407 if (!buildingComponent)
410 SCR_CampaignBuildingProviderComponent provider = SCR_CampaignBuildingProviderComponent.Cast(buildingComponent.GetProviderComponent());
414 IEntity player =
GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId);
418 campaign.OnEntityRequested(editableEntity.GetOwner(), player,
SCR_Faction.Cast(
SCR_Faction.GetEntityFaction(editableEntity.GetOwner())), provider);
424 IEntity player =
GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID);
438 IEntity player =
GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID);
452 SCR_DamageManagerComponent hitZoneContainerComponent = SCR_DamageManagerComponent.Cast(provider.FindComponent(SCR_DamageManagerComponent));
453 if (!hitZoneContainerComponent)
464 SCR_DamageManagerComponent hitZoneContainerComponent = SCR_DamageManagerComponent.Cast(provider.FindComponent(SCR_DamageManagerComponent));
465 if (!hitZoneContainerComponent)
476 if (!characterController)
479 int playerID =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(characterController.GetOwner());
485 if (editorManager.IsOpened())
502 IEntity provider = hitZone.GetOwner();
506 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(provider.FindComponent(SCR_CampaignBuildingProviderComponent));
507 if (!providerComponent)
510 array<int> playersIDs = {};
511 providerComponent.GetAvailableUsers(playersIDs);
512 foreach (
int playerId : playersIDs)
514 if (providerComponent.ContainActiveUsers(playerId))
517 providerComponent.RemoveActiveUser(playerId);
520 providerComponent.RemoveAvailableUser(playerId);
531 bool isActiveUser = providerComponent.ContainActiveUsers(playerID);
533 providerComponent.RemoveActiveUser(playerID);
534 providerComponent.RemoveAvailableUser(playerID);
544 void RemoveProvider(
int playerID, SCR_CampaignBuildingProviderComponent providerComponent,
bool isActiveUser)
554 SCR_CampaignBuildingEditorComponent editorComponent = SCR_CampaignBuildingEditorComponent.Cast(modeEntity.FindComponent(SCR_CampaignBuildingEditorComponent));
555 if (!editorComponent)
558 if (isActiveUser && editorManager.IsOpened())
559 editorManager.Close();
561 editorComponent.RemoveProviderEntityEditorComponent(providerComponent);
563 IEntity provider = providerComponent.GetOwner();
567 providerComponent.RemoveCheckProviderMove();
575 if (!editorComponent.GetProviderComponent())
584 editorManager.Toggle();
595 if (!editorModeEntity)
608 return core.GetEditorManager(playerID);