18 ref ScriptInvoker m_OnActivated =
new ScriptInvoker;
19 ref ScriptInvoker m_OnCompleted =
new ScriptInvoker;
20 ref ScriptInvoker m_OnCanceled =
new ScriptInvoker;
21 ref ScriptInvoker m_OnResumed =
new ScriptInvoker;
22 ref ScriptInvoker m_OnPaused =
new ScriptInvoker;
23 ref ScriptInvoker m_OnFailed =
new ScriptInvoker;
24 ref ScriptInvoker m_OnChanged =
new ScriptInvoker;
27 protected const int STATE_INACTIVE = 0;
28 protected const int STATE_ACTIVE = 1;
29 protected const int STATE_COMPLETED = 2;
30 protected const int STATE_FAILED = 3;
31 protected const int STATE_CANCELED = 4;
32 protected const int STATE_PAUSED = 5;
36 protected int m_State;
38 protected bool m_bAttached;
39 protected ref Managed m_UserData;
42 protected string m_sAddonName;
43 protected string m_sAddonId;
57 m_sAddonName = wrapper.GetName();
58 m_sAddonId = wrapper.GetId();
74 bool IsInactive() {
return m_State == STATE_INACTIVE; }
75 bool IsActive() {
return m_State == STATE_ACTIVE; }
76 bool IsCompleted() {
return m_State == STATE_COMPLETED; }
77 bool IsCanceled() {
return m_State == STATE_CANCELED; }
78 bool IsPaused() {
return m_State == STATE_PAUSED; }
79 bool IsFailed() {
return m_State == STATE_FAILED; }
85 bool IsAttached() {
return m_bAttached; }
101 return m_Wrapper.GetName();
111 return m_Wrapper.GetId();
126 #ifdef WORKSHOP_DEBUG
127 _print(
"Activate()");
130 if (!m_Wrapper || !m_bAttached)
135 #ifdef WORKSHOP_DEBUG
136 _print(
"OnActivate()");
138 bool success = OnActivate();
142 m_OnActivated.Invoke(
this);
144 m_Wrapper.Internal_OnChanged();
154 return this.Resume();
156 else if (
m_State == STATE_ACTIVE)
169 if (!m_Wrapper || !m_bAttached)
172 #ifdef WORKSHOP_DEBUG
178 #ifdef WORKSHOP_DEBUG
179 _print(
"OnCancel()");
182 bool success = OnCancel();
186 m_OnCanceled.Invoke(
this);
188 m_Wrapper.Internal_OnChanged();
196 else if (
m_State == STATE_CANCELED)
209 if (!m_Wrapper || !m_bAttached)
212 #ifdef WORKSHOP_DEBUG
218 #ifdef WORKSHOP_DEBUG
222 bool success = OnPause();
226 m_OnPaused.Invoke(
this);
228 m_Wrapper.Internal_OnChanged();
236 else if (
m_State == STATE_PAUSED)
249 if (!m_Wrapper || !m_bAttached)
252 #ifdef WORKSHOP_DEBUG
258 #ifdef WORKSHOP_DEBUG
259 _print(
"OnResume()");
262 bool success = OnResume();
266 m_OnResumed.Invoke(
this);
268 m_Wrapper.Internal_OnChanged();
276 else if (
m_State == STATE_INACTIVE)
280 else if (
m_State == STATE_ACTIVE)
292 if (!m_Wrapper || !m_bAttached)
295 #ifdef WORKSHOP_DEBUG
296 _print(
"Reactivate()");
301 #ifdef WORKSHOP_DEBUG
302 _print(
"OnReactivate()");
305 bool success = OnReactivate();
309 m_OnActivated.Invoke(
this);
311 m_Wrapper.Internal_OnChanged();
315 else if (
m_State == STATE_ACTIVE)
329 protected void Fail(
int reason = -1)
331 if (!m_Wrapper || !m_bAttached)
334 #ifdef WORKSHOP_DEBUG
342 m_OnFailed.Invoke(
this, reason);
344 m_Wrapper.Internal_OnChanged();
350 protected void Complete()
352 if (!m_Wrapper || !m_bAttached)
355 #ifdef WORKSHOP_DEBUG
356 _print(
"Complete()");
359 if (
m_State != STATE_COMPLETED)
363 m_OnCompleted.Invoke(
this);
365 m_Wrapper.Internal_OnChanged();
371 protected void InvokeOnChanged()
380 protected bool OnActivate() {
return false; }
381 protected bool OnCancel() {
return false; }
382 protected bool OnPause() {
return false; }
383 protected bool OnResume() {
return false; }
384 protected bool OnReactivate() {
return false; }
385 protected void OnFail(
int reason = -1);
386 protected void OnComplete();
391 void Internal_Update(
float timeSlice);
394 void Internal_Detach()
400 void _print(
string str, LogLevel logLevel = LogLevel.DEBUG)
402 Print(
string.Format(
"[SCR_AddonManager] %1 %2",
this, str), logLevel);
410 ref array<ref SCR_WorkshopItemAction> m_aActions =
new array<ref SCR_WorkshopItemAction>;
414 array<ref SCR_WorkshopItemAction> GetActions()
416 array<ref SCR_WorkshopItemAction> actions =
new array<ref SCR_WorkshopItemAction>;
437 protected void UnregisterActions(array<SCR_WorkshopItemAction> actions)
439 foreach (
auto i : actions)
444 protected bool AllCompleted()
456 protected bool AnyFailed()
466 protected void CancelAll()
473 protected void PauseAll()
480 protected void ResumeAll()
487 protected void ActivateAll()