@bf6mods/sdk 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,691 @@
1
- function z(e,t){return e+t}function H(...e){for(let t=0;t<e.length;t++)if(!e[t])return!1;return!0}function L(...e){for(let t=0;t<e.length;t++){let o=e[t];if(!o())return!1}return!0}function V(e){return mod.GetObjId(e)}function F(e){return mod.GetObjId(e)}function s(e){let t=[],o=mod.CountOf(e);for(let n=0;n<o;n++){let l=mod.ValueInArray(e,n);t.push(l)}return t}function R(e,t){let o=s(e),n=mod.EmptyArray(),l=o.length;for(let d=0;d<l;d++){let r=o[d];t(r)&&mod.AppendToArray(n,r)}return n}function j(e,t,o=null){let n=s(e),l=n.length;for(let d=0;d<l;d++){let r=n[d];if(t(r,o))return d}return-1}function q(e,t,o){return e?t():o()}function k(e,t,o=null){let n=s(e),l=n.length;for(let d=0;d<l;d++){let r=n[d];if(!t(r,o))return!1}return!0}function p(e,t,o=null){let n=s(e),l=n.length;for(let d=0;d<l;d++){let r=n[d];if(t(r,o))return!0}return!1}function J(e,t){let o=e.slice();o.sort(t);let n=[];for(let l of o)n.push(l);return n}function K(e,t){if(e==null||t==null)debugger;return mod.Equals(e,t)}async function Q(e,t){let o=10,n=e/o;for(let l=0;l<o&&t();l++)await mod.Wait(n)}var m=class{constructor(){this.lastState=!1}update(t){return t?this.lastState?!1:(this.lastState=!0,!0):(this.lastState=!1,!1)}},g=class{constructor(){this.conditionStates=[]}getConditionState(t){for(;t>=this.conditionStates.length;)this.conditionStates.push(new m);return this.conditionStates[t]}},A=[],a=[],O=[],S=[],M=[],W=new g;function P(e,t,o){for(;e>=t.length;)t.push(new g);return t[e].getConditionState(o)}function X(e,t){let o=V(e);for(;o>=A.length;)A.push(new g);return A[o].getConditionState(t)}function Y(e,t){let o=F(e);for(;o>=a.length;)a.push(new g);return a[o].getConditionState(t)}function Z(e,t){let o=mod.GetObjId(e);return P(o,O,t)}function $(e,t){let o=mod.GetObjId(e);return P(o,S,t)}function ee(e,t){let o=mod.GetObjId(e);return P(o,M,t)}function te(e){return W.getConditionState(e)}function x(e){let t=mod.AllPlayers(),o=mod.CountOf(t),n=[];for(let l=0;l<o;l++){let d=mod.ValueInArray(t,l);mod.GetTeam(d)==e&&n.push(d)}return n}function i(e){return Array.isArray(e)?mod.CreateVector(e[0],e[1],e.length==2?0:e[2]):e}function U(e){return typeof e=="string"?mod.Message(e):e}function C(e){e.hasOwnProperty("name")||(e.name=""),e.hasOwnProperty("position")||(e.position=mod.CreateVector(0,0,0)),e.hasOwnProperty("size")||(e.size=mod.CreateVector(100,100,0)),e.hasOwnProperty("anchor")||(e.anchor=mod.UIAnchor.TopLeft),e.hasOwnProperty("parent")||(e.parent=mod.GetUIRoot()),e.hasOwnProperty("visible")||(e.visible=!0),e.hasOwnProperty("padding")||(e.padding=e.type=="Container"?0:8),e.hasOwnProperty("bgColor")||(e.bgColor=mod.CreateVector(.25,.25,.25)),e.hasOwnProperty("bgAlpha")||(e.bgAlpha=.5),e.hasOwnProperty("bgFill")||(e.bgFill=mod.UIBgFill.Solid)}function I(e,t){let o=mod.FindUIWidgetWithName(e);return mod.SetUIWidgetName(o,t.name),o}var u="----uniquename----";function _(e){C(e);let t=e.teamId??e.playerId;t?mod.AddUIContainer(u,i(e.position),i(e.size),e.anchor,e.parent,e.visible,e.padding,i(e.bgColor),e.bgAlpha,e.bgFill,t):mod.AddUIContainer(u,i(e.position),i(e.size),e.anchor,e.parent,e.visible,e.padding,i(e.bgColor),e.bgAlpha,e.bgFill);let o=I(u,e);return e.children&&e.children.forEach(n=>{n.parent=o,T(n)}),o}function D(e){e.hasOwnProperty("textLabel")||(e.textLabel=""),e.hasOwnProperty("textSize")||(e.textSize=0),e.hasOwnProperty("textColor")||(e.textColor=mod.CreateVector(1,1,1)),e.hasOwnProperty("textAlpha")||(e.textAlpha=1),e.hasOwnProperty("textAnchor")||(e.textAnchor=mod.UIAnchor.CenterLeft)}function v(e){C(e),D(e);let t=e.teamId??e.playerId;return t?mod.AddUIText(u,i(e.position),i(e.size),e.anchor,e.parent,e.visible,e.padding,i(e.bgColor),e.bgAlpha,e.bgFill,U(e.textLabel),e.textSize,i(e.textColor),e.textAlpha,e.textAnchor,t):mod.AddUIText(u,i(e.position),i(e.size),e.anchor,e.parent,e.visible,e.padding,i(e.bgColor),e.bgAlpha,e.bgFill,U(e.textLabel),e.textSize,i(e.textColor),e.textAlpha,e.textAnchor),I(u,e)}function B(e){e.hasOwnProperty("imageType")||(e.imageType=mod.UIImageType.None),e.hasOwnProperty("imageColor")||(e.imageColor=mod.CreateVector(1,1,1)),e.hasOwnProperty("imageAlpha")||(e.imageAlpha=1)}function N(e){C(e),B(e);let t=e.teamId??e.playerId;return t?mod.AddUIImage(u,i(e.position),i(e.size),e.anchor,e.parent,e.visible,e.padding,i(e.bgColor),e.bgAlpha,e.bgFill,e.imageType,i(e.imageColor),e.imageAlpha,t):mod.AddUIImage(u,i(e.position),i(e.size),e.anchor,e.parent,e.visible,e.padding,i(e.bgColor),e.bgAlpha,e.bgFill,e.imageType,i(e.imageColor),e.imageAlpha),I(u,e)}function E(e){e.hasOwnProperty("buttonEnabled")||(e.buttonEnabled=!0),e.hasOwnProperty("buttonColorBase")||(e.buttonColorBase=mod.CreateVector(.7,.7,.7)),e.hasOwnProperty("buttonAlphaBase")||(e.buttonAlphaBase=1),e.hasOwnProperty("buttonColorDisabled")||(e.buttonColorDisabled=mod.CreateVector(.2,.2,.2)),e.hasOwnProperty("buttonAlphaDisabled")||(e.buttonAlphaDisabled=.5),e.hasOwnProperty("buttonColorPressed")||(e.buttonColorPressed=mod.CreateVector(.25,.25,.25)),e.hasOwnProperty("buttonAlphaPressed")||(e.buttonAlphaPressed=1),e.hasOwnProperty("buttonColorHover")||(e.buttonColorHover=mod.CreateVector(1,1,1)),e.hasOwnProperty("buttonAlphaHover")||(e.buttonAlphaHover=1),e.hasOwnProperty("buttonColorFocused")||(e.buttonColorFocused=mod.CreateVector(1,1,1)),e.hasOwnProperty("buttonAlphaFocused")||(e.buttonAlphaFocused=1)}function G(e){C(e),E(e);let t=e.teamId??e.playerId;return t?mod.AddUIButton(u,i(e.position),i(e.size),e.anchor,e.parent,e.visible,e.padding,i(e.bgColor),e.bgAlpha,e.bgFill,e.buttonEnabled,i(e.buttonColorBase),e.buttonAlphaBase,i(e.buttonColorDisabled),e.buttonAlphaDisabled,i(e.buttonColorPressed),e.buttonAlphaPressed,i(e.buttonColorHover),e.buttonAlphaHover,i(e.buttonColorFocused),e.buttonAlphaFocused,t):mod.AddUIButton(u,i(e.position),i(e.size),e.anchor,e.parent,e.visible,e.padding,i(e.bgColor),e.bgAlpha,e.bgFill,e.buttonEnabled,i(e.buttonColorBase),e.buttonAlphaBase,i(e.buttonColorDisabled),e.buttonAlphaDisabled,i(e.buttonColorPressed),e.buttonAlphaPressed,i(e.buttonColorHover),e.buttonAlphaHover,i(e.buttonColorFocused),e.buttonAlphaFocused),I(u,e)}function T(e){if(e!=null){if(e.type=="Container")return _(e);if(e.type=="Text")return v(e);if(e.type=="Image")return N(e);if(e.type=="Button")return G(e)}}function oe(...e){let t;for(let o=0;o<e.length;o++)t=T(e[o]);return t}function ne(e,t,o,n){let l=async(c,f,b,h)=>{mod.AddUIText(c,mod.CreateVector(50,250+h*45,0),mod.CreateVector(250,60,0),mod.UIAnchor.TopRight,mod.GetUIRoot(),!0,8,mod.CreateVector(1,1,1),1,mod.UIBgFill.Blur,f,30,mod.CreateVector(1,1,1),1,mod.UIAnchor.Center,b),o>0&&(await mod.Wait(o),mod.DeleteUIWidget(mod.FindUIWidgetWithName(c)))},d=async(c,f,b,h)=>{mod.AddUIText(c,mod.CreateVector(85,270+h*43,0),mod.CreateVector(125,40,0),mod.UIAnchor.TopRight,mod.GetUIRoot(),!0,8,mod.CreateVector(1,1,1),1,mod.UIBgFill.Blur,f,20,mod.CreateVector(1,1,1),1,mod.UIAnchor.Center,b),o>0&&(await mod.Wait(o),mod.DeleteUIWidget(mod.FindUIWidgetWithName(c)))},r=t<1?l:d;if(n)if(mod.IsType(n,mod.Types.Player)){let c=t+String(n);r(c,e,n,t)}else mod.IsType(n,mod.Types.Team)&&x(n).forEach(f=>{let b=t+String(f);r(b,e,f,t)});else{let c=mod.AllPlayers(),f=mod.CountOf(c);for(let b=0;b<f;b++){let h=mod.ValueInArray(c,b),w=t+String(h);r(w,e,h,t)}}}function ie(e,t){let o=async(n,l)=>{let d="GameModeMessage";l?mod.AddUIText(d,mod.CreateVector(0,0,0),mod.CreateVector(2500,80,0),mod.UIAnchor.TopCenter,mod.GetUIRoot(),!0,8,mod.CreateVector(1,1,1),1,mod.UIBgFill.Blur,n,30,mod.CreateVector(1,1,1),1,mod.UIAnchor.Center,l):mod.AddUIText(d,mod.CreateVector(0,0,0),mod.CreateVector(2500,80,0),mod.UIAnchor.TopCenter,mod.GetUIRoot(),!0,8,mod.CreateVector(1,1,1),1,mod.UIBgFill.Blur,n,30,mod.CreateVector(1,1,1),1,mod.UIAnchor.Center),await mod.Wait(6),mod.DeleteUIWidget(mod.FindUIWidgetWithName(d))};t?o(e,t):o(e)}function le(e,t){t?mod.DisplayHighlightedWorldLogMessage(e,t):mod.DisplayHighlightedWorldLogMessage(e)}function de(e,t){t?mod.DisplayNotificationMessage(e,t):mod.DisplayNotificationMessage(e)}function re(e){try{y(mod.CustomNotificationSlots.HeaderText,e)}catch{}try{y(mod.CustomNotificationSlots.MessageText1,e)}catch{}try{y(mod.CustomNotificationSlots.MessageText2,e)}catch{}try{y(mod.CustomNotificationSlots.MessageText3,e)}catch{}try{y(mod.CustomNotificationSlots.MessageText4,e)}catch{}}function y(e,t){try{if(t){if(mod.IsType(t,mod.Types.Player))mod.DeleteUIWidget(mod.FindUIWidgetWithName(e+String(t)));else if(mod.IsType(t,mod.Types.Team)){let o=x(t);for(let n=0;n<o.length;n++){let l=o[n];mod.DeleteUIWidget(mod.FindUIWidgetWithName(e+String(l)))}}}else{let o=mod.AllPlayers(),n=mod.CountOf(o);for(let l=0;l<n;l++){let d=mod.ValueInArray(o,l);mod.DeleteUIWidget(mod.FindUIWidgetWithName(e+String(d)))}}}catch{console.error("Could not clear custom message for specified target(s)")}}export{H as And,L as AndFn,re as ClearAllCustomNotificationMessages,y as ClearCustomNotificationMessage,z as Concat,m as ConditionState,s as ConvertArray,ne as DisplayCustomNotificationMessage,K as Equals,R as FilteredArray,q as IfThenElse,j as IndexOfFirstTrue,k as IsTrueForAll,p as IsTrueForAny,oe as ParseUI,ie as ShowEventGameModeMessage,le as ShowHighlightedGameModeMessage,de as ShowNotificationMessage,J as SortedArray,Q as WaitUntil,Z as getCapturePointCondition,te as getGlobalCondition,$ as getMCOMCondition,X as getPlayerCondition,V as getPlayerId,x as getPlayersInTeam,Y as getTeamCondition,F as getTeamId,ee as getVehicleCondition};
1
+ // src/config/index.ts
2
+ var ManDownExperienceType = /* @__PURE__ */ ((ManDownExperienceType2) => {
3
+ ManDownExperienceType2[ManDownExperienceType2["Crawl"] = 0] = "Crawl";
4
+ ManDownExperienceType2[ManDownExperienceType2["Downed"] = 1] = "Downed";
5
+ ManDownExperienceType2[ManDownExperienceType2["InstantDeath"] = 2] = "InstantDeath";
6
+ return ManDownExperienceType2;
7
+ })(ManDownExperienceType || {});
8
+ var AiSpawnType = /* @__PURE__ */ ((AiSpawnType2) => {
9
+ AiSpawnType2[AiSpawnType2["NoBots"] = 0] = "NoBots";
10
+ AiSpawnType2[AiSpawnType2["Backfill"] = 2] = "Backfill";
11
+ AiSpawnType2[AiSpawnType2["Static"] = 1] = "Static";
12
+ return AiSpawnType2;
13
+ })(AiSpawnType || {});
14
+ var SquadSpawnType = /* @__PURE__ */ ((SquadSpawnType2) => {
15
+ SquadSpawnType2[SquadSpawnType2["All"] = 0] = "All";
16
+ SquadSpawnType2[SquadSpawnType2["SquadmatesOnLeader_LeaderNone"] = 1] = "SquadmatesOnLeader_LeaderNone";
17
+ SquadSpawnType2[SquadSpawnType2["SquadmatesOnLeader_LeaderAll"] = 2] = "SquadmatesOnLeader_LeaderAll";
18
+ SquadSpawnType2[SquadSpawnType2["Disabled"] = 2] = "Disabled";
19
+ return SquadSpawnType2;
20
+ })(SquadSpawnType || {});
21
+ var ScoreboardType = /* @__PURE__ */ ((ScoreboardType2) => {
22
+ ScoreboardType2[ScoreboardType2["NotSet"] = 0] = "NotSet";
23
+ ScoreboardType2[ScoreboardType2["DefaultFAA"] = 1] = "DefaultFAA";
24
+ ScoreboardType2[ScoreboardType2["Off"] = 2] = "Off";
25
+ ScoreboardType2[ScoreboardType2["CustomTwoTeams"] = 3] = "CustomTwoTeams";
26
+ ScoreboardType2[ScoreboardType2["CustomFFA"] = 4] = "CustomFFA";
27
+ return ScoreboardType2;
28
+ })(ScoreboardType || {});
29
+ var PingBehavior = /* @__PURE__ */ ((PingBehavior2) => {
30
+ PingBehavior2[PingBehavior2["PingTargets"] = 0] = "PingTargets";
31
+ PingBehavior2[PingBehavior2["Disabled"] = 1] = "Disabled";
32
+ return PingBehavior2;
33
+ })(PingBehavior || {});
34
+ var ModBuilderGameMode = /* @__PURE__ */ ((ModBuilderGameMode2) => {
35
+ ModBuilderGameMode2[ModBuilderGameMode2["Custom"] = 2] = "Custom";
36
+ return ModBuilderGameMode2;
37
+ })(ModBuilderGameMode || {});
38
+ var FactionID = /* @__PURE__ */ ((FactionID2) => {
39
+ FactionID2[FactionID2["Pax"] = -1865993703] = "Pax";
40
+ FactionID2[FactionID2["MapDefault"] = 0] = "MapDefault";
41
+ FactionID2[FactionID2["NATO"] = 607944106] = "NATO";
42
+ return FactionID2;
43
+ })(FactionID || {});
44
+ var AttachmentType = /* @__PURE__ */ ((AttachmentType2) => {
45
+ AttachmentType2[AttachmentType2["SpatialData"] = 1] = "SpatialData";
46
+ AttachmentType2[AttachmentType2["TypeScript"] = 2] = "TypeScript";
47
+ AttachmentType2[AttachmentType2["Strings"] = 4] = "Strings";
48
+ return AttachmentType2;
49
+ })(AttachmentType || {});
50
+
51
+ // src/modlib/index.ts
52
+ function Concat(s1, s2) {
53
+ return s1 + s2;
54
+ }
55
+ function And(...rest) {
56
+ for (let i = 0; i < rest.length; i++) {
57
+ const cond = rest[i];
58
+ if (!cond) return false;
59
+ }
60
+ return true;
61
+ }
62
+ function AndFn(...rest) {
63
+ for (let i = 0; i < rest.length; i++) {
64
+ const condFn = rest[i];
65
+ if (!condFn()) return false;
66
+ }
67
+ return true;
68
+ }
69
+ function getPlayerId(player) {
70
+ return mod.GetObjId(player);
71
+ }
72
+ function getTeamId(team) {
73
+ return mod.GetObjId(team);
74
+ }
75
+ function ConvertArray(array) {
76
+ let v = [];
77
+ let n = mod.CountOf(array);
78
+ for (let i = 0; i < n; i++) {
79
+ let currentElement = mod.ValueInArray(array, i);
80
+ v.push(currentElement);
81
+ }
82
+ return v;
83
+ }
84
+ function FilteredArray(array, cond) {
85
+ const arr = ConvertArray(array);
86
+ let v = mod.EmptyArray();
87
+ let n = arr.length;
88
+ for (let i = 0; i < n; i++) {
89
+ let currentElement = arr[i];
90
+ if (cond(currentElement)) mod.AppendToArray(v, currentElement);
91
+ }
92
+ return v;
93
+ }
94
+ function IndexOfFirstTrue(array, cond, arg = null) {
95
+ const arr = ConvertArray(array);
96
+ let n = arr.length;
97
+ for (let i = 0; i < n; i++) {
98
+ let currentArrayElement = arr[i];
99
+ if (cond(currentArrayElement, arg)) return i;
100
+ }
101
+ return -1;
102
+ }
103
+ function IfThenElse(condition, ifTrue, ifFalse) {
104
+ if (condition) return ifTrue();
105
+ else return ifFalse();
106
+ }
107
+ function IsTrueForAll(array, condition, arg = null) {
108
+ const arr = ConvertArray(array);
109
+ let n = arr.length;
110
+ for (let i = 0; i < n; i++) {
111
+ let currentArrayElement = arr[i];
112
+ if (!condition(currentArrayElement, arg)) return false;
113
+ }
114
+ return true;
115
+ }
116
+ function IsTrueForAny(array, condition, arg = null) {
117
+ const arr = ConvertArray(array);
118
+ let n = arr.length;
119
+ for (let i = 0; i < n; i++) {
120
+ let currentArrayElement = arr[i];
121
+ if (condition(currentArrayElement, arg)) return true;
122
+ }
123
+ return false;
124
+ }
125
+ function SortedArray(array, compare) {
126
+ let v1 = array.slice();
127
+ v1.sort(compare);
128
+ let v2 = [];
129
+ for (let e of v1) v2.push(e);
130
+ return v2;
131
+ }
132
+ function Equals(a, b) {
133
+ if (a == null || b == null) debugger;
134
+ return mod.Equals(a, b);
135
+ }
136
+ async function WaitUntil(delay, cond) {
137
+ let deltaCount = 10;
138
+ let deltaWait = delay / deltaCount;
139
+ for (let t = 0; t < deltaCount; t++) {
140
+ if (!cond()) break;
141
+ await mod.Wait(deltaWait);
142
+ }
143
+ }
144
+ var ConditionState = class {
145
+ constructor() {
146
+ this.lastState = false;
147
+ }
148
+ update(newState) {
149
+ if (!newState) {
150
+ this.lastState = false;
151
+ return false;
152
+ }
153
+ if (this.lastState) return false;
154
+ this.lastState = true;
155
+ return true;
156
+ }
157
+ };
158
+ var Conditions = class {
159
+ constructor() {
160
+ this.conditionStates = [];
161
+ }
162
+ getConditionState(n) {
163
+ while (n >= this.conditionStates.length) {
164
+ this.conditionStates.push(new ConditionState());
165
+ }
166
+ return this.conditionStates[n];
167
+ }
168
+ };
169
+ var playerConditions = [];
170
+ var teamConditions = [];
171
+ var capturePointConditions = [];
172
+ var mcomConditions = [];
173
+ var vehicleConditions = [];
174
+ var globalConditions = new Conditions();
175
+ function getObjectCondition(id, objectConditions, n) {
176
+ while (id >= objectConditions.length) {
177
+ objectConditions.push(new Conditions());
178
+ }
179
+ let conditions = objectConditions[id];
180
+ return conditions.getConditionState(n);
181
+ }
182
+ function getPlayerCondition(obj, n) {
183
+ let id = getPlayerId(obj);
184
+ while (id >= playerConditions.length) {
185
+ playerConditions.push(new Conditions());
186
+ }
187
+ let conditions = playerConditions[id];
188
+ return conditions.getConditionState(n);
189
+ }
190
+ function getTeamCondition(team, n) {
191
+ let id = getTeamId(team);
192
+ while (id >= teamConditions.length) {
193
+ teamConditions.push(new Conditions());
194
+ }
195
+ let conditions = teamConditions[id];
196
+ return conditions.getConditionState(n);
197
+ }
198
+ function getCapturePointCondition(obj, n) {
199
+ let id = mod.GetObjId(obj);
200
+ return getObjectCondition(id, capturePointConditions, n);
201
+ }
202
+ function getMCOMCondition(obj, n) {
203
+ let id = mod.GetObjId(obj);
204
+ return getObjectCondition(id, mcomConditions, n);
205
+ }
206
+ function getVehicleCondition(obj, n) {
207
+ let id = mod.GetObjId(obj);
208
+ return getObjectCondition(id, vehicleConditions, n);
209
+ }
210
+ function getGlobalCondition(n) {
211
+ return globalConditions.getConditionState(n);
212
+ }
213
+ function getPlayersInTeam(team) {
214
+ const allPlayers = mod.AllPlayers();
215
+ const n = mod.CountOf(allPlayers);
216
+ let teamMembers = [];
217
+ for (let i = 0; i < n; i++) {
218
+ let player = mod.ValueInArray(allPlayers, i);
219
+ if (mod.GetTeam(player) == team) {
220
+ teamMembers.push(player);
221
+ }
222
+ }
223
+ return teamMembers;
224
+ }
225
+ function __asModVector(param) {
226
+ if (Array.isArray(param)) return mod.CreateVector(param[0], param[1], param.length == 2 ? 0 : param[2]);
227
+ else return param;
228
+ }
229
+ function __asModMessage(param) {
230
+ if (typeof param === "string") return mod.Message(param);
231
+ return param;
232
+ }
233
+ function __fillInDefaultArgs(params) {
234
+ if (!params.hasOwnProperty("name")) params.name = "";
235
+ if (!params.hasOwnProperty("position")) params.position = mod.CreateVector(0, 0, 0);
236
+ if (!params.hasOwnProperty("size")) params.size = mod.CreateVector(100, 100, 0);
237
+ if (!params.hasOwnProperty("anchor")) params.anchor = mod.UIAnchor.TopLeft;
238
+ if (!params.hasOwnProperty("parent")) params.parent = mod.GetUIRoot();
239
+ if (!params.hasOwnProperty("visible")) params.visible = true;
240
+ if (!params.hasOwnProperty("padding")) params.padding = params.type == "Container" ? 0 : 8;
241
+ if (!params.hasOwnProperty("bgColor")) params.bgColor = mod.CreateVector(0.25, 0.25, 0.25);
242
+ if (!params.hasOwnProperty("bgAlpha")) params.bgAlpha = 0.5;
243
+ if (!params.hasOwnProperty("bgFill")) params.bgFill = mod.UIBgFill.Solid;
244
+ }
245
+ function __setNameAndGetWidget(uniqueName, params) {
246
+ let widget = mod.FindUIWidgetWithName(uniqueName);
247
+ mod.SetUIWidgetName(widget, params.name);
248
+ return widget;
249
+ }
250
+ var __cUniqueName = "----uniquename----";
251
+ function __addUIContainer(params) {
252
+ __fillInDefaultArgs(params);
253
+ let restrict = params.teamId ?? params.playerId;
254
+ if (restrict) {
255
+ mod.AddUIContainer(
256
+ __cUniqueName,
257
+ __asModVector(params.position),
258
+ __asModVector(params.size),
259
+ params.anchor,
260
+ params.parent,
261
+ params.visible,
262
+ params.padding,
263
+ __asModVector(params.bgColor),
264
+ params.bgAlpha,
265
+ params.bgFill,
266
+ restrict
267
+ );
268
+ } else {
269
+ mod.AddUIContainer(
270
+ __cUniqueName,
271
+ __asModVector(params.position),
272
+ __asModVector(params.size),
273
+ params.anchor,
274
+ params.parent,
275
+ params.visible,
276
+ params.padding,
277
+ __asModVector(params.bgColor),
278
+ params.bgAlpha,
279
+ params.bgFill
280
+ );
281
+ }
282
+ let widget = __setNameAndGetWidget(__cUniqueName, params);
283
+ if (params.children) {
284
+ params.children.forEach((childParams) => {
285
+ childParams.parent = widget;
286
+ __addUIWidget(childParams);
287
+ });
288
+ }
289
+ return widget;
290
+ }
291
+ function __fillInDefaultTextArgs(params) {
292
+ if (!params.hasOwnProperty("textLabel")) params.textLabel = "";
293
+ if (!params.hasOwnProperty("textSize")) params.textSize = 0;
294
+ if (!params.hasOwnProperty("textColor")) params.textColor = mod.CreateVector(1, 1, 1);
295
+ if (!params.hasOwnProperty("textAlpha")) params.textAlpha = 1;
296
+ if (!params.hasOwnProperty("textAnchor")) params.textAnchor = mod.UIAnchor.CenterLeft;
297
+ }
298
+ function __addUIText(params) {
299
+ __fillInDefaultArgs(params);
300
+ __fillInDefaultTextArgs(params);
301
+ let restrict = params.teamId ?? params.playerId;
302
+ if (restrict) {
303
+ mod.AddUIText(
304
+ __cUniqueName,
305
+ __asModVector(params.position),
306
+ __asModVector(params.size),
307
+ params.anchor,
308
+ params.parent,
309
+ params.visible,
310
+ params.padding,
311
+ __asModVector(params.bgColor),
312
+ params.bgAlpha,
313
+ params.bgFill,
314
+ __asModMessage(params.textLabel),
315
+ params.textSize,
316
+ __asModVector(params.textColor),
317
+ params.textAlpha,
318
+ params.textAnchor,
319
+ restrict
320
+ );
321
+ } else {
322
+ mod.AddUIText(
323
+ __cUniqueName,
324
+ __asModVector(params.position),
325
+ __asModVector(params.size),
326
+ params.anchor,
327
+ params.parent,
328
+ params.visible,
329
+ params.padding,
330
+ __asModVector(params.bgColor),
331
+ params.bgAlpha,
332
+ params.bgFill,
333
+ __asModMessage(params.textLabel),
334
+ params.textSize,
335
+ __asModVector(params.textColor),
336
+ params.textAlpha,
337
+ params.textAnchor
338
+ );
339
+ }
340
+ return __setNameAndGetWidget(__cUniqueName, params);
341
+ }
342
+ function __fillInDefaultImageArgs(params) {
343
+ if (!params.hasOwnProperty("imageType")) params.imageType = mod.UIImageType.None;
344
+ if (!params.hasOwnProperty("imageColor")) params.imageColor = mod.CreateVector(1, 1, 1);
345
+ if (!params.hasOwnProperty("imageAlpha")) params.imageAlpha = 1;
346
+ }
347
+ function __addUIImage(params) {
348
+ __fillInDefaultArgs(params);
349
+ __fillInDefaultImageArgs(params);
350
+ let restrict = params.teamId ?? params.playerId;
351
+ if (restrict) {
352
+ mod.AddUIImage(
353
+ __cUniqueName,
354
+ __asModVector(params.position),
355
+ __asModVector(params.size),
356
+ params.anchor,
357
+ params.parent,
358
+ params.visible,
359
+ params.padding,
360
+ __asModVector(params.bgColor),
361
+ params.bgAlpha,
362
+ params.bgFill,
363
+ params.imageType,
364
+ __asModVector(params.imageColor),
365
+ params.imageAlpha,
366
+ restrict
367
+ );
368
+ } else {
369
+ mod.AddUIImage(
370
+ __cUniqueName,
371
+ __asModVector(params.position),
372
+ __asModVector(params.size),
373
+ params.anchor,
374
+ params.parent,
375
+ params.visible,
376
+ params.padding,
377
+ __asModVector(params.bgColor),
378
+ params.bgAlpha,
379
+ params.bgFill,
380
+ params.imageType,
381
+ __asModVector(params.imageColor),
382
+ params.imageAlpha
383
+ );
384
+ }
385
+ return __setNameAndGetWidget(__cUniqueName, params);
386
+ }
387
+ function __fillInDefaultButtonArgs(params) {
388
+ if (!params.hasOwnProperty("buttonEnabled")) params.buttonEnabled = true;
389
+ if (!params.hasOwnProperty("buttonColorBase")) params.buttonColorBase = mod.CreateVector(0.7, 0.7, 0.7);
390
+ if (!params.hasOwnProperty("buttonAlphaBase")) params.buttonAlphaBase = 1;
391
+ if (!params.hasOwnProperty("buttonColorDisabled")) params.buttonColorDisabled = mod.CreateVector(0.2, 0.2, 0.2);
392
+ if (!params.hasOwnProperty("buttonAlphaDisabled")) params.buttonAlphaDisabled = 0.5;
393
+ if (!params.hasOwnProperty("buttonColorPressed")) params.buttonColorPressed = mod.CreateVector(0.25, 0.25, 0.25);
394
+ if (!params.hasOwnProperty("buttonAlphaPressed")) params.buttonAlphaPressed = 1;
395
+ if (!params.hasOwnProperty("buttonColorHover")) params.buttonColorHover = mod.CreateVector(1, 1, 1);
396
+ if (!params.hasOwnProperty("buttonAlphaHover")) params.buttonAlphaHover = 1;
397
+ if (!params.hasOwnProperty("buttonColorFocused")) params.buttonColorFocused = mod.CreateVector(1, 1, 1);
398
+ if (!params.hasOwnProperty("buttonAlphaFocused")) params.buttonAlphaFocused = 1;
399
+ }
400
+ function __addUIButton(params) {
401
+ __fillInDefaultArgs(params);
402
+ __fillInDefaultButtonArgs(params);
403
+ let restrict = params.teamId ?? params.playerId;
404
+ if (restrict) {
405
+ mod.AddUIButton(
406
+ __cUniqueName,
407
+ __asModVector(params.position),
408
+ __asModVector(params.size),
409
+ params.anchor,
410
+ params.parent,
411
+ params.visible,
412
+ params.padding,
413
+ __asModVector(params.bgColor),
414
+ params.bgAlpha,
415
+ params.bgFill,
416
+ params.buttonEnabled,
417
+ __asModVector(params.buttonColorBase),
418
+ params.buttonAlphaBase,
419
+ __asModVector(params.buttonColorDisabled),
420
+ params.buttonAlphaDisabled,
421
+ __asModVector(params.buttonColorPressed),
422
+ params.buttonAlphaPressed,
423
+ __asModVector(params.buttonColorHover),
424
+ params.buttonAlphaHover,
425
+ __asModVector(params.buttonColorFocused),
426
+ params.buttonAlphaFocused,
427
+ restrict
428
+ );
429
+ } else {
430
+ mod.AddUIButton(
431
+ __cUniqueName,
432
+ __asModVector(params.position),
433
+ __asModVector(params.size),
434
+ params.anchor,
435
+ params.parent,
436
+ params.visible,
437
+ params.padding,
438
+ __asModVector(params.bgColor),
439
+ params.bgAlpha,
440
+ params.bgFill,
441
+ params.buttonEnabled,
442
+ __asModVector(params.buttonColorBase),
443
+ params.buttonAlphaBase,
444
+ __asModVector(params.buttonColorDisabled),
445
+ params.buttonAlphaDisabled,
446
+ __asModVector(params.buttonColorPressed),
447
+ params.buttonAlphaPressed,
448
+ __asModVector(params.buttonColorHover),
449
+ params.buttonAlphaHover,
450
+ __asModVector(params.buttonColorFocused),
451
+ params.buttonAlphaFocused
452
+ );
453
+ }
454
+ return __setNameAndGetWidget(__cUniqueName, params);
455
+ }
456
+ function __addUIWidget(params) {
457
+ if (params == null) return void 0;
458
+ if (params.type == "Container") return __addUIContainer(params);
459
+ else if (params.type == "Text") return __addUIText(params);
460
+ else if (params.type == "Image") return __addUIImage(params);
461
+ else if (params.type == "Button") return __addUIButton(params);
462
+ return void 0;
463
+ }
464
+ function ParseUI(...params) {
465
+ let widget;
466
+ for (let a = 0; a < params.length; a++) {
467
+ widget = __addUIWidget(params[a]);
468
+ }
469
+ return widget;
470
+ }
471
+ function DisplayCustomNotificationMessage(msg, custom, duration, target) {
472
+ const CreateHeader = async (widgetId, msg2, targetPlayer, slot) => {
473
+ mod.AddUIText(
474
+ widgetId,
475
+ mod.CreateVector(50, 250 + slot * (40 + 5), 0),
476
+ mod.CreateVector(250, 60, 0),
477
+ mod.UIAnchor.TopRight,
478
+ mod.GetUIRoot(),
479
+ true,
480
+ 8,
481
+ mod.CreateVector(1, 1, 1),
482
+ 1,
483
+ mod.UIBgFill.Blur,
484
+ msg2,
485
+ 30,
486
+ mod.CreateVector(1, 1, 1),
487
+ 1,
488
+ mod.UIAnchor.Center,
489
+ targetPlayer
490
+ );
491
+ if (duration > 0) {
492
+ await mod.Wait(duration);
493
+ mod.DeleteUIWidget(mod.FindUIWidgetWithName(widgetId));
494
+ }
495
+ };
496
+ const CreateSubText = async (widgetId, msg2, targetPlayer, slot) => {
497
+ mod.AddUIText(
498
+ widgetId,
499
+ mod.CreateVector(85, 270 + slot * (40 + 3), 0),
500
+ mod.CreateVector(125, 40, 0),
501
+ mod.UIAnchor.TopRight,
502
+ mod.GetUIRoot(),
503
+ true,
504
+ 8,
505
+ mod.CreateVector(1, 1, 1),
506
+ 1,
507
+ mod.UIBgFill.Blur,
508
+ msg2,
509
+ 20,
510
+ mod.CreateVector(1, 1, 1),
511
+ 1,
512
+ mod.UIAnchor.Center,
513
+ targetPlayer
514
+ );
515
+ if (duration > 0) {
516
+ await mod.Wait(duration);
517
+ mod.DeleteUIWidget(mod.FindUIWidgetWithName(widgetId));
518
+ }
519
+ };
520
+ const createNotificationFunction = custom < 1 ? CreateHeader : CreateSubText;
521
+ if (target) {
522
+ if (mod.IsType(target, mod.Types.Player)) {
523
+ const widgetId = custom + String(target);
524
+ createNotificationFunction(widgetId, msg, target, custom);
525
+ } else if (mod.IsType(target, mod.Types.Team)) {
526
+ const teamMates = getPlayersInTeam(target);
527
+ teamMates.forEach((player) => {
528
+ const widgetId = custom + String(player);
529
+ createNotificationFunction(widgetId, msg, player, custom);
530
+ });
531
+ }
532
+ } else {
533
+ const allPlayers = mod.AllPlayers();
534
+ const n = mod.CountOf(allPlayers);
535
+ for (let i = 0; i < n; i++) {
536
+ let player = mod.ValueInArray(allPlayers, i);
537
+ const widgetId = custom + String(player);
538
+ createNotificationFunction(widgetId, msg, player, custom);
539
+ }
540
+ }
541
+ }
542
+ function ShowEventGameModeMessage(event, target) {
543
+ const MakeShiftDisplayGameModeMessage = async (message, target2) => {
544
+ const widgetId = "GameModeMessage";
545
+ if (target2) {
546
+ mod.AddUIText(
547
+ widgetId,
548
+ mod.CreateVector(0, 0, 0),
549
+ mod.CreateVector(2500, 80, 0),
550
+ mod.UIAnchor.TopCenter,
551
+ mod.GetUIRoot(),
552
+ true,
553
+ 8,
554
+ mod.CreateVector(1, 1, 1),
555
+ 1,
556
+ mod.UIBgFill.Blur,
557
+ message,
558
+ 30,
559
+ mod.CreateVector(1, 1, 1),
560
+ 1,
561
+ mod.UIAnchor.Center,
562
+ target2
563
+ );
564
+ } else {
565
+ mod.AddUIText(
566
+ widgetId,
567
+ mod.CreateVector(0, 0, 0),
568
+ mod.CreateVector(2500, 80, 0),
569
+ mod.UIAnchor.TopCenter,
570
+ mod.GetUIRoot(),
571
+ true,
572
+ 8,
573
+ mod.CreateVector(1, 1, 1),
574
+ 1,
575
+ mod.UIBgFill.Blur,
576
+ message,
577
+ 30,
578
+ mod.CreateVector(1, 1, 1),
579
+ 1,
580
+ mod.UIAnchor.Center
581
+ );
582
+ }
583
+ await mod.Wait(6);
584
+ mod.DeleteUIWidget(mod.FindUIWidgetWithName(widgetId));
585
+ };
586
+ if (target) {
587
+ MakeShiftDisplayGameModeMessage(event, target);
588
+ } else {
589
+ MakeShiftDisplayGameModeMessage(event);
590
+ }
591
+ }
592
+ function ShowHighlightedGameModeMessage(event, target) {
593
+ if (target) {
594
+ mod.DisplayHighlightedWorldLogMessage(event, target);
595
+ } else {
596
+ mod.DisplayHighlightedWorldLogMessage(event);
597
+ }
598
+ }
599
+ function ShowNotificationMessage(msg, target) {
600
+ if (target) {
601
+ mod.DisplayNotificationMessage(msg, target);
602
+ } else {
603
+ mod.DisplayNotificationMessage(msg);
604
+ }
605
+ }
606
+ function ClearAllCustomNotificationMessages(target) {
607
+ try {
608
+ ClearCustomNotificationMessage(mod.CustomNotificationSlots.HeaderText, target);
609
+ } catch {
610
+ }
611
+ try {
612
+ ClearCustomNotificationMessage(mod.CustomNotificationSlots.MessageText1, target);
613
+ } catch {
614
+ }
615
+ try {
616
+ ClearCustomNotificationMessage(mod.CustomNotificationSlots.MessageText2, target);
617
+ } catch {
618
+ }
619
+ try {
620
+ ClearCustomNotificationMessage(mod.CustomNotificationSlots.MessageText3, target);
621
+ } catch {
622
+ }
623
+ try {
624
+ ClearCustomNotificationMessage(mod.CustomNotificationSlots.MessageText4, target);
625
+ } catch {
626
+ }
627
+ }
628
+ function ClearCustomNotificationMessage(custom, target) {
629
+ try {
630
+ if (target) {
631
+ if (mod.IsType(target, mod.Types.Player)) {
632
+ mod.DeleteUIWidget(mod.FindUIWidgetWithName(custom + String(target)));
633
+ } else if (mod.IsType(target, mod.Types.Team)) {
634
+ const teamMembers = getPlayersInTeam(target);
635
+ for (let i = 0; i < teamMembers.length; i++) {
636
+ let player = teamMembers[i];
637
+ mod.DeleteUIWidget(mod.FindUIWidgetWithName(custom + String(player)));
638
+ }
639
+ }
640
+ } else {
641
+ const allPlayers = mod.AllPlayers();
642
+ const n = mod.CountOf(allPlayers);
643
+ for (let i = 0; i < n; i++) {
644
+ let player = mod.ValueInArray(allPlayers, i);
645
+ mod.DeleteUIWidget(mod.FindUIWidgetWithName(custom + String(player)));
646
+ }
647
+ }
648
+ } catch {
649
+ console.error("Could not clear custom message for specified target(s)");
650
+ }
651
+ }
652
+ export {
653
+ AiSpawnType,
654
+ And,
655
+ AndFn,
656
+ AttachmentType,
657
+ ClearAllCustomNotificationMessages,
658
+ ClearCustomNotificationMessage,
659
+ Concat,
660
+ ConditionState,
661
+ ConvertArray,
662
+ DisplayCustomNotificationMessage,
663
+ Equals,
664
+ FactionID,
665
+ FilteredArray,
666
+ IfThenElse,
667
+ IndexOfFirstTrue,
668
+ IsTrueForAll,
669
+ IsTrueForAny,
670
+ ManDownExperienceType,
671
+ ModBuilderGameMode,
672
+ ParseUI,
673
+ PingBehavior,
674
+ ScoreboardType,
675
+ ShowEventGameModeMessage,
676
+ ShowHighlightedGameModeMessage,
677
+ ShowNotificationMessage,
678
+ SortedArray,
679
+ SquadSpawnType,
680
+ WaitUntil,
681
+ getCapturePointCondition,
682
+ getGlobalCondition,
683
+ getMCOMCondition,
684
+ getPlayerCondition,
685
+ getPlayerId,
686
+ getPlayersInTeam,
687
+ getTeamCondition,
688
+ getTeamId,
689
+ getVehicleCondition
690
+ };
2
691
  //# sourceMappingURL=index.js.map