Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BuildingTaskCreator.c
Go to the documentation of this file.
3{
4 [Attribute("10 0 -10", desc:"Task offset")]
6
7 SCR_CampaignBuildingManagerComponent m_BuildingManager;
8
9 protected static const string CAMPAIGN_BUILDING_TASK_ID = "%1_BuildingCampaignMilitaryBaseTask_%2";
10
11 //------------------------------------------------------------------------------------------------
12 protected void OnEntitySpawnedByProvider(int prefabID, SCR_EditableEntityComponent editableEntity, int playerId, SCR_CampaignBuildingProviderComponent provider)
13 {
14 SCR_CampaignBuildingCompositionComponent buildingCompositionComponent = SCR_CampaignBuildingCompositionComponent.Cast(editableEntity.GetOwner().FindComponent(SCR_CampaignBuildingCompositionComponent));
15 if (!buildingCompositionComponent)
16 return;
17
18 IEntity player = GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId);
19 if (!player)
20 return;
21
23 if (!faction)
24 return;
25
26 SCR_GroupTaskManagerComponent groupTaskManager = SCR_GroupTaskManagerComponent.GetInstance();
27 if (!groupTaskManager || !groupTaskManager.CanCreateNewTaskWithResourceName(m_sTaskPrefab, faction))
28 return;
29
30 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
31 if (!taskSystem)
32 return;
33
34 SCR_CampaignMilitaryBaseComponent base = provider.GetCampaignMilitaryBaseComponent();
35 if (!base)
36 return;
37
38 string taskID = string.Format(CAMPAIGN_BUILDING_TASK_ID, faction.GetFactionKey(), base.GetCallsign());
39
40 if (SCR_TaskSystem.GetTaskFromTaskID(taskID, false))
41 return;
42
43 SCR_BuildingCampaignMilitaryBaseTaskEntity task = SCR_BuildingCampaignMilitaryBaseTaskEntity.Cast(taskSystem.CreateTask(
45 taskID,
46 "",
47 "",
48 base.GetOwner().GetOrigin() + m_vPositionOffset
49 ));
50
51 if (!task)
52 {
53 Print("Task was not created", LogLevel.ERROR);
54 return;
55 }
56
57 task.SetMilitaryBaseCallSign(base.GetCallsign());
58 taskSystem.SetTaskOwnership(task, SCR_ETaskOwnership.EXECUTOR);
59 taskSystem.SetTaskVisibility(task, SCR_ETaskVisibility.GROUP);
60 taskSystem.AddTaskFaction(task, faction.GetFactionKey());
61
62 groupTaskManager.SetGroupTask(task, 0);
63
64 SCR_TaskUIInfo taskUIInfo = task.GetTaskUIInfo();
65 if (!taskUIInfo)
66 return;
67
68 task.SetTaskName(taskUIInfo.GetName(), {base.GetFormattedBaseNameWithCallsign(faction)});
69 }
70
71 //------------------------------------------------------------------------------------------------
72 override void Init(SCR_TaskCreatorComponent taskCreatorComponent)
73 {
74 super.Init(taskCreatorComponent);
75
76 BaseGameMode gameMode = taskCreatorComponent.GetGameMode();
77 if (!gameMode)
78 return;
79
80 m_BuildingManager = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
82 return;
83
84 m_BuildingManager.GetOnEntitySpawnedByProvider().Insert(OnEntitySpawnedByProvider);
85 }
86
87 //------------------------------------------------------------------------------------------------
88 override void Deinit()
89 {
91 return;
92
93 m_BuildingManager.GetOnEntitySpawnedByProvider().Remove(OnEntitySpawnedByProvider);
94 }
95}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_GroupTaskManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_ETaskVisibility
Definition SCR_Task.c:24
SCR_CampaignBuildingManagerComponent m_BuildingManager
override void Init(SCR_TaskCreatorComponent taskCreatorComponent)
void OnEntitySpawnedByProvider(int prefabID, SCR_EditableEntityComponent editableEntity, int playerId, SCR_CampaignBuildingProviderComponent provider)
static const string CAMPAIGN_BUILDING_TASK_ID
static Faction GetEntityFaction(notnull IEntity entity)
ResourceName m_sTaskPrefab
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute