2 [
ComponentEditorProps(
category:
"GameScripted/Editor", description:
"Main conflict component for handling building editor mode", icon:
"WBData/ComponentEditorProps/componentEditor.png")]
44 SCR_MilitaryBaseComponent base = providerComponent.GetMilitaryBaseComponent();
69 SCR_CampaignBuildingProviderComponent temporaryProviderComponent;
78 if (getMasterProviderComponent && temporaryProviderComponent && temporaryProviderComponent.UseMasterProvider())
79 return SCR_CampaignBuildingProviderComponent.Cast(
GetMasterProviderEntity().FindComponent(SCR_CampaignBuildingProviderComponent));
81 return temporaryProviderComponent;
86 void SetForcedProvider(SCR_CampaignBuildingProviderComponent forcedProviderComponent =
null)
119 resourceComponent = SCR_ResourceComponent.FindResourceComponent(
GetProviderEntity());
121 if (resourceComponent)
128 resourceComponent = SCR_ResourceComponent.FindResourceComponent(parent);
130 if (resourceComponent)
133 parent = parent.GetParent();
144 if (!providerComponent)
147 return providerComponent.GetShownBudget();
151 [
Obsolete(
"SCR_CampaignBuildingEditorComponent.GetProviderResourceComponent() should be used instead.")]
158 if (suppliesComponent)
165 if (suppliesComponent)
168 parent = parent.GetParent();
190 parent = parent.GetParent();
205 if (!providerComponent)
211 IEntity child =
GetProviderEntity(providerComponent.UseMasterProvider()).GetChildren();
218 child = child.GetSibling();
237 BaseGameMode gameMode =
GetGame().GetGameMode();
239 SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
240 if (!buildingManagerComponent)
244 if (!providerComponent)
251 Resource resource = Resource.Load(buildingManagerComponent.GetClientTriggerResourceName());
252 if (!resource || !resource.IsValid())
255 EntitySpawnParams
params =
new EntitySpawnParams();
256 params.TransformMode = ETransformMode.WORLD;
259 return ScriptedGameTriggerEntity.Cast(
GetGame().SpawnEntityPrefab(resource, provider.GetWorld(),
params));
267 if (!providerComponenet)
276 trigger.SetSphereRadius(providerComponenet.GetBuildingRadius());
278 SCR_CampaignBuildingAreaMeshComponent areaMeshComponent = SCR_CampaignBuildingAreaMeshComponent.Cast(trigger.FindComponent(SCR_CampaignBuildingAreaMeshComponent));
279 if (areaMeshComponent && areaMeshComponent.ShouldEnableFrameUpdateDuringEditor())
281 areaMeshComponent.ActivateEveryFrame();
282 areaMeshComponent.GenerateAreaMesh();
285 trigger.SetFlags(EntityFlags.VISIBLE,
false);
289 if (providerComponenet.ObstrucViewWhenEnemyInRange())
295 if (factionComponent)
298 Faction buildingFaction = factionComponent.GetAffiliatedFaction();
300 if (!buildingFaction)
301 buildingFaction = factionComponent.GetDefaultAffiliatedFaction();
307 array<SCR_EditorContentBrowserSaveStateDataUI> contentBrowserStates = {};
310 for (
int i = 0; i < tabsCount; i++)
312 if (!contentBrowserStates[i])
317 if (i == 0 || !
CanBeShown(contentBrowserStates[i]))
331 return tab.CanBeShown();
339 if (!providerComponent)
342 array<EEditableEntityLabel> labels = providerComponent.GetAvailableTraits();
346 if (tab.ContainsLabel(label))
358 if (!providerComponent)
361 return providerComponent.GetMilitaryBaseComponent();
375 SCR_CampaignBuildingGadgetToolComponent gadgetComponent = SCR_CampaignBuildingGadgetToolComponent.Cast(gadgetManager.GetHeldGadgetComponent());
376 if (!gadgetComponent)
380 gadgetComponent.ToolToHand();
382 gadgetComponent.ToolToInventory();
408 SCR_NotificationsComponent.SendLocal(
ENotification.EDITOR_ENEMY_IN_AREA);
429 trigger.QueryEntitiesInside();
430 array<IEntity> entitiesInside = {};
431 trigger.GetEntitiesInside(entitiesInside);
434 foreach (IEntity entity : entitiesInside)
455 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(ent);
459 CharacterControllerComponent charControl = character.GetCharacterController();
463 int playerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(ent);
466 AIControlComponent ctrComp = charControl.GetAIControlComponent();
467 if (ctrComp && !ctrComp.IsAIActivated())
473 if (!providerComponent || !providerComponent.IsEnemyFaction(character))
486 SCR_EditableCharacterComponent editableCharacter = SCR_EditableCharacterComponent.Cast(ent.FindComponent(SCR_EditableCharacterComponent));
487 if (!editableCharacter)
498 SCR_EditableCharacterComponent editableCharacter = SCR_EditableCharacterComponent.Cast(ent.FindComponent(SCR_EditableCharacterComponent));
499 if (!editableCharacter)
511 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerId);
512 if (!playerController)
521 SCR_MilitaryBaseComponent base;
525 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
GetProviderEntity().FindComponent(SCR_CampaignBuildingProviderComponent));
526 if (!providerComponent)
529 base = providerComponent.GetMilitaryBaseComponent();
547 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
GetProviderEntity().FindComponent(SCR_CampaignBuildingProviderComponent));
548 if (!providerComponent)
551 SCR_MilitaryBaseComponent base = providerComponent.GetMilitaryBaseComponent();
562 if (!editableComponent || editableComponent.GetParentEntity())
565 SCR_CampaignBuildingCompositionComponent comp = SCR_CampaignBuildingCompositionComponent.Cast(ent.FindComponent(SCR_CampaignBuildingCompositionComponent));
570 if (comp.GetProviderEntity() ==
null)
580 if (!editableComponent || editableComponent.GetParentEntity())
583 SCR_CampaignBuildingCompositionComponent comp = SCR_CampaignBuildingCompositionComponent.Cast(ent.FindComponent(SCR_CampaignBuildingCompositionComponent));
588 comp.SetProviderEntityServer(
null);
602 if (factionComponent)
605 Faction buildingFaction = factionComponent.GetAffiliatedFaction();
607 if (!buildingFaction)
608 buildingFaction = factionComponent.GetDefaultAffiliatedFaction();
622 if (getMasterProvider)
626 if (!providerComponent)
629 return providerComponent.GetOwner();
638 if (!providerComponent)
641 return providerComponent.GetMasterProviderEntity();
649 for (
int i = 0; i < count; i++)
651 RplComponent rplComp = RplComponent.Cast(Replication.FindItem(
m_aProvidersRplIds[i]));
655 IEntity provider = rplComp.GetEntity();
659 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(provider.FindComponent(SCR_CampaignBuildingProviderComponent));
660 if (!providerComponent)
673 override protected bool RplSave(ScriptBitWriter writer)
678 writer.WriteInt(count);
679 for (
int i = 0; i < count; i++)
685 RplComponent rplCmp = RplComponent.Cast(provider.FindComponent(RplComponent));
686 entityRplID = rplCmp.Id();
687 writer.WriteRplId(entityRplID);
694 override protected bool RplLoad(ScriptBitReader reader)
699 reader.ReadInt(count);
701 for (
int i = 0; i < count; i++)
703 reader.ReadRplId(entityRplID);
704 if (!entityRplID.IsValid())
707 RplComponent rplComp = RplComponent.Cast(Replication.FindItem(entityRplID));
714 ent = IEntity.Cast(rplComp.GetEntity());
718 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(ent.FindComponent(SCR_CampaignBuildingProviderComponent));