1 [
ComponentEditorProps(
category:
"GameScripted/Editor", description:
"Main conflict editor component to handle building mode placing", icon:
"WBData/ComponentEditorProps/componentEditor.png")]
5 protected ref array<ResourceName> m_aClippingCheckIgnoredPrefabs;
7 bool ContainPrefab(ResourceName res)
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")]
36 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
37 if (!providerComponent)
40 base = SCR_MilitaryBaseComponent.Cast(
m_Provider.FindComponent(SCR_MilitaryBaseComponent));
54 SCR_CampaignBuildingPlacingObstructionEditorComponent obstructionComponent = SCR_CampaignBuildingPlacingObstructionEditorComponent.Cast(FindEditorComponent(SCR_CampaignBuildingPlacingObstructionEditorComponent,
true,
true));
55 if (!obstructionComponent)
58 obstructionComponent.OnPreviewCreated(previewEnt);
81 BaseGameMode gameMode =
GetGame().GetGameMode();
83 SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
96 int cooldownTime, aiBudgetValue;
97 int count = entities.Count();
98 SCR_EditorLinkComponent linkComponent;
100 SCR_CampaignBuildingCompositionComponent compositionComponent;
103 for (
int i = 0; i < count; i++)
105 IEntity entityOwner = entities[i].GetOwnerScripted();
109 linkComponent = SCR_EditorLinkComponent.Cast(entityOwner.FindComponent(SCR_EditorLinkComponent));
111 SCR_EditorLinkComponent.IgnoreSpawning(
false);
114 if (editableGroupComponent)
119 aiGroup = editableGroupComponent.GetAIGroupComponent();
124 EntitySpawnParams
params = EntitySpawnParams();
125 params.TransformMode = ETransformMode.WORLD;
126 params.Transform[3] = aiGroup.GetOrigin();
129 aiGroup.AddWaypointAt(defendWP, 0);
133 compositionComponent = SCR_CampaignBuildingCompositionComponent.Cast(entityOwner.FindComponent(SCR_CampaignBuildingCompositionComponent));
134 if (compositionComponent)
165 array<ref SCR_EntityBudgetValue> outBudgets = {};
166 entity.GetEntityChildrenBudgetCost(outBudgets);
168 if (outBudgets.IsEmpty())
169 entity.GetEntityBudgetCost(outBudgets);
173 if (outBudget.GetBudgetType() == budget)
174 return outBudget.GetBudgetValue();
192 int id = managerEnt.GetPlayerID();
194 compositionComponent.SetBuilderId(
id);
195 compositionComponent.SetProviderEntity(provider);
198 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(provider.FindComponent(SCR_CampaignBuildingProviderComponent));
199 if (!providerComponent)
202 SCR_MilitaryBaseComponent base = providerComponent.GetMilitaryBaseComponent();
207 compositionComponent.SetClearProviderEvent(ent);
219 array<AIAgent> outAgents = {};
222 SCR_CampaignBuildingProviderComponent providerComponent;
224 aiGroup.GetAgents(outAgents);
226 foreach (AIAgent agent: outAgents)
228 ent = agent.GetControlledEntity();
230 if (editableEntityComponent)
233 providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
234 if (!providerComponent)
237 providerComponent.SetOnEntityKilled(agent.GetControlledEntity());
250 vector
position = entity.GetOwner().GetOrigin();
256 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
260 Math3D.MatrixIdentity4(transform);
263 if (soundEvent && pos)
264 AudioSystem.PlayEvent(soundEvent,
SCR_SoundEvent.SOUND_BUILD, transform,
new array<string>,
new array<float>);
268 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
272 SCR_EditorLinkComponent.IgnoreSpawning(
true);
275 SCR_ServicePointComponent.SpawnAsOffline(
true);
277 super.CreateEntityServer(
params, prefabID, playerID, entityIndex, isQueue, recipientIds, canBePlayer);
294 BaseGameMode gameMode =
GetGame().GetGameMode();
298 SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
299 if (!buildingManagerComponent)
306 return outlineManager.GetCompositionOutline(entity);
312 SCR_CampaignBuildingPlacingObstructionEditorComponent obstructionComponent = SCR_CampaignBuildingPlacingObstructionEditorComponent.Cast(FindEditorComponent(SCR_CampaignBuildingPlacingObstructionEditorComponent,
true,
true));
313 if (!obstructionComponent)
319 if (obstructionComponent.IsPreviewOutOfRange(outNotification))
325 return obstructionComponent.CanCreate(outNotification, previewStateToShow);
331 super.EOnEditorActivate();
346 super.EOnEditorOpen();
354 super.EOnEditorClose();
361 super.EOnEditorOpenServer();
378 m_CampaignBuildingComponent = SCR_CampaignBuildingEditorComponent.Cast(FindEditorComponent(SCR_CampaignBuildingEditorComponent,
true,
true));
396 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
397 if (!providerComponent)
410 int playerId = managerEnt.GetPlayerID();
412 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
413 if (!providerComponent)
416 providerComponent.SetPlayerCooldown(playerId, cooldownTime);
422 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_Provider.FindComponent(SCR_CampaignBuildingProviderComponent));
423 if (!providerComponent)
426 providerComponent.AddAIValue(value);