Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AISendMessageDebugUI.c
Go to the documentation of this file.
1class SCR_AISendMessageDebugUIClass : GenericEntityClass
2{
3
4};
5
9
10class SCR_AISendMessageDebugUI : GenericEntity
11{
12 static SCR_AISendMessageDebugUI s_Instance;
13
14 //-------------------------------------------------------------------------------------------
15 static void Init()
16 {
17 if (!s_Instance)
18 s_Instance = SCR_AISendMessageDebugUI.Cast(GetGame().SpawnEntity(SCR_AISendMessageDebugUI));
19 }
20
21
22 //-------------------------------------------------------------------------------------------
23 void SCR_AISendMessageDebugUI(IEntitySource src, IEntity parent)
24 {
25 SetFlags(EntityFlags.ACTIVE, true);
27 }
28
29
30 //-------------------------------------------------------------------------------------------
31 protected override void EOnFrame(IEntity owner, float timeSlice)
32 {
33 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_AI_SEND_MESSAGE))
34 s_Instance.Draw();
35 }
36
37
38 //-------------------------------------------------------------------------------------------
39 protected void Draw()
40 {
41 SCR_AIWorld aiWorld = SCR_AIWorld.Cast(GetGame().GetAIWorld());
42 if (!aiWorld)
43 return;
44
45 // Init list with string names of info messages
46 /*
47 TStringArray InfoMsgNames = {};
48 TIntArray infoMsgEnumValues = {};
49 typename msgTypeInfoTypename = EMessageType_Info;
50 for (int i = 0; i < msgTypeInfoTypename.GetVariableCount(); i++)
51 {
52 int _enumValue;
53 msgTypeInfoTypename.GetVariableValue(null, i, _enumValue);
54
55 // Check if this message is supposed to be used in this Debug UI
56 SCR_AIMessageBase msg = aiWorld.GetInfoMessageOfType(_enumValue);
57
58 if (!msg)
59 continue;
60
61 if (!msg.DebugUi_IsVisible())
62 continue;
63
64 infoMsgEnumValues.Insert(_enumValue);
65
66 string _s = typename.EnumToString(EMessageType_Info, _enumValue);
67 InfoMsgNames.Insert(_s);
68 }
69 */
70
71 DbgUI.Begin("Send Info Message");
72
73
74 // Text: Selected AI
76 DbgUI.Text(string.Format("Selected Entity: %1", ent.ToString()));
77
78 if (ent)
79 {
80 AIControlComponent controlComp = AIControlComponent.Cast(ent.FindComponent(AIControlComponent));
81 AIAgent senderAgent = controlComp.GetAIAgent();
82
83 const int buttonWidth = 500;
84 if (DbgUI.Button("INFO: NO AMMO -> GROUP", buttonWidth))
85 SendNoAmmoToGroup(ent, senderAgent);
86 }
87 else
88 {
89 DbgUI.Text("You must select an AI Entity with Game Master first!");
90 }
91
92 DbgUI.End();
93 }
94
95
96 //-------------------------------------------------------------------------------------------
98 {
99 SCR_AIWorld aiWorld = SCR_AIWorld.Cast(GetGame().GetAIWorld());
100 AIControlComponent controlComp = AIControlComponent.Cast(senderEnt.FindComponent(AIControlComponent));
101 AIAgent senderAgent = controlComp.GetAIAgent();
102 AICommunicationComponent mailbox = senderAgent.GetCommunicationComponent();
103
104 SCR_AIMessageBase msg; // Disabled for now, it's not useful
105
106 return msg;
107 }
108
109
110 //-------------------------------------------------------------------------------------------
111 protected void BroadcastMessage(AIAgent senderAgent, SCR_AIMessageBase msg, AIAgent receiver)
112 {
113 AICommunicationComponent mailbox = senderAgent.GetCommunicationComponent();
114
115 mailbox.RequestBroadcast(msg, receiver);
116 }
117
118
119 //-------------------------------------------------------------------------------------------
121 {
122 // Get first AI entity selected in Game Master
124 set<SCR_EditableEntityComponent> selectedEntities = new set<SCR_EditableEntityComponent>();
125 filter.GetEntities(selectedEntities);
126
127 if (selectedEntities.Count() != 1)
128 return null;
129
130 SCR_EditableCharacterComponent editCharacterComp = SCR_EditableCharacterComponent.Cast(selectedEntities[0]);
131
132 if (!editCharacterComp)
133 return null;
134
135 return editCharacterComp.GetAgent().GetControlledEntity();
136 }
137
138
139
140
141 //-------------------------------------------------------------------------------------------
142 protected void SendNoAmmoToGroup(IEntity senderEnt, AIAgent senderAgent)
143 {
145
146 msg.m_entityToSupply = senderEnt;
147
148 // Get current mag well
149 auto weaponManager = BaseWeaponManagerComponent.Cast(senderEnt.FindComponent(BaseWeaponManagerComponent));
150 BaseWeaponComponent weapon = weaponManager.GetCurrent();
151 msg.m_MagazineWell = SCR_AIGetMagazineWell.GetWeaponMainMagazineWell(weapon);
152 Print(string.Format("SendNoAmmoToGroup: %1, %2", senderEnt.ToString(), msg.m_MagazineWell.ToString()), LogLevel.DEBUG);
153
154 AIAgent receiver = senderAgent.GetParentGroup();
155 BroadcastMessage(senderAgent, msg, receiver);
156 }
157};
override void Init()
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ArmaReforgerScripted GetGame()
Definition game.c:1398
EMessageType_Info
IEntity SpawnEntity(ResourceName entityResourceName, notnull IEntity slotOwner)
Definition DbgUI.c:66
Diagnostic and developer menu system.
Definition DiagMenu.c:18
void IEntity(IEntitySource src, IEntity parent)
protected script Constructor
proto external EntityEvent SetEventMask(EntityEvent e)
proto external Managed FindComponent(typename typeName)
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
static GetWeaponMainMagazineWell(BaseWeaponComponent weapon)
SCR_AIMessageBase CreateInfoMessage(EMessageType_Info msgType, IEntity senderEnt)
override void EOnFrame(IEntity owner, float timeSlice)
void BroadcastMessage(AIAgent senderAgent, SCR_AIMessageBase msg, AIAgent receiver)
void SendNoAmmoToGroup(IEntity senderEnt, AIAgent senderAgent)
static SCR_BaseEditableEntityFilter GetInstance(EEditableEntityState state, bool showError=false)
int GetEntities(out set< SCR_EditableEntityComponent > entities, bool includeChildren=false, bool evaluate=true)
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
EEditableEntityState
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EntityFlags
Various entity flags.
Definition EntityFlags.c:14