‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
scriptbundle_shared.csc
Go to the documentation of this file.
1 #insert scripts\shared\shared.gsh;
2 
3 #using scripts\shared\util_shared;
4 
5 #namespace scriptbundle;
6 
8 {
9  var ‪_s; // struct that holds gdt data for object
10  var ‪_o_bundle; // reference to parent bundle object
11  var ‪_e_array; // entities associated with this bundle object
13 
15  {
16  }
17 
19  {
20  }
21 
22  function ‪init( s_objdef, o_bundle, e_ent, localclientnum )
23  {
24  ‪_s = s_objdef;
25  ‪_o_bundle = o_bundle;
26 
27  if ( isdefined( e_ent ) )
28  {
29  Assert( !isdefined( localclientnum ) || ( e_ent.localclientnum == localclientnum ), "Local client number mismatch." );
30 
31  ‪_n_clientnum = e_ent.localclientnum;
32  ‪_e_array[ ‪_n_clientnum ] = e_ent;
33  }
34  else
35  {
36  ‪_e_array = [];
37 
38  if ( isdefined( localclientnum ) )
39  {
40  ‪_n_clientnum = localclientnum;
41  }
42  }
43  }
44 
45  function ‪log( str_msg )
46  {
47  /# PrintLn( [[ ‪_o_bundle ]] -> ‪get_type() + " " + [[ ‪_o_bundle ]] -> ‪get_name() + ": (" + ‪STR_DEFAULT( ‪_s.name, "no name" ) + ") " + str_msg ); #/
48  }
49 
50  function ‪error( condition, str_msg )
51  {
52  if ( condition )
53  {
54  if ( [[‪_o_bundle]]->‪is_testing() )
55  {
57  }
58  else
59  {
60  AssertMsg( [[ ‪_o_bundle ]] -> ‪get_type() + " " + [[ ‪_o_bundle ]] -> ‪get_name() + ": (" + ‪STR_DEFAULT( ‪_s.name, "no name" ) + ") " + str_msg );
61  }
62 
63  thread [[‪_o_bundle]]->on_error();
64  return true;
65  }
66 
67  return false;
68  }
69 
70  function ‪get_ent( localClientNum )
71  {
72  return ‪_e_array[localClientNum];
73  }
74 }
75 
76 class cScriptBundleBase
77 {
78  var ‪_s; // struct that holds gdt data for bundle
79  var ‪_str_name; // name of bundle
81 
83 
84  function ‪on_error( e ) { } // IMPLEMENT IN DERIVED CLASS
85 
87  {
88  ‪_a_objects = [];
89  ‪_testing = false;
90  }
91 
93  {
94  }
95 
96  function ‪init( str_name, s, b_testing )
97  {
98  ‪_s = s;
99  ‪_str_name = str_name;
100  ‪_testing = b_testing;
101  }
102 
103  function ‪get_type()
104  {
105  return ‪_s.type;
106  }
107 
108  function ‪get_name()
109  {
110  return ‪_str_name;
111  }
112 
113  function ‪get_vm()
114  {
115  return ‪_s.vmtype;
116  }
117 
118  function ‪get_objects()
119  {
120  return ‪_s.objects;
121  }
122 
123  function ‪is_testing()
124  {
125  return ‪_testing;
126  }
127 
128  function ‪add_object( o_object )
129  {
130  ‪ARRAY_ADD( ‪_a_objects, o_object );
131  }
132 
133  function ‪remove_object( o_object )
134  {
135  ArrayRemoveValue( ‪_a_objects, o_object );
136  }
137 
138  function ‪log( str_msg )
139  {
140  /# PrintLn( ‪_s.type + " " + ‪_str_name + ": " + str_msg ); #/
141  }
142 
143  function ‪error( condition, str_msg )
144  {
145  if ( condition )
146  {
147  if ( ‪_testing )
148  {
149 // scriptbundle::error_on_screen( str_msg );
150  }
151  else
152  {
153  AssertMsg( ‪_s.type + " " + ‪_str_name + ": " + str_msg );
154  }
155 
156  thread [[self]]->on_error();
157  return true;
158  }
159 
160  return false;
161  }
162 }
163 
164 function ‪error_on_screen( str_msg )
165 {
166  if ( str_msg != "" )
167  {
168  if ( !isdefined( level.scene_error_hud ) )
169  {
170  level.scene_error_hud = CreateLUIMenu( 0, "HudElementText" );
171  SetLuiMenuData( 0, level.scene_error_hud, "alignment", ‪LUI_HUDELEM_ALIGNMENT_LEFT );
172  SetLuiMenuData( 0, level.scene_error_hud, "x", 0 );
173  SetLuiMenuData( 0, level.scene_error_hud, "y", 10 );
174  SetLuiMenuData( 0, level.scene_error_hud, "width", 1920 );
175  OpenLUIMenu( 0, level.scene_error_hud );
176  }
177 
178  SetLuiMenuData( 0, level.scene_error_hud, "text", str_msg );
179  self thread ‪_destroy_error_on_screen();
180  }
181 }
182 
184 {
185  level notify( "_destroy_error_on_screen" );
186  level endon( "_destroy_error_on_screen" );
187 
188  self ‪util::waittill_notify_or_timeout( "stopped", 5 );
189 
190  CloseLuiMenu( 0, level.scene_error_hud );
191  level.scene_error_hud = undefined;
192 }
‪destructor
‪destructor()
Definition: scriptbundle_shared.csc:92
‪get_type
‪function get_type()
Definition: scriptbundle_shared.csc:103
‪cScriptBundleObjectBase
Definition: scriptbundle_shared.csc:7
‪init
‪function init(str_name, s, b_testing)
Definition: scriptbundle_shared.csc:96
‪_a_objects
‪var _a_objects
Definition: scriptbundle_shared.csc:80
‪remove_object
‪function remove_object(o_object)
Definition: scriptbundle_shared.csc:133
‪_destroy_error_on_screen
‪function _destroy_error_on_screen()
Definition: scriptbundle_shared.csc:183
‪cScriptBundleObjectBase::_e_array
‪var _e_array
Definition: scriptbundle_shared.csc:11
‪error
‪function error(condition, str_msg)
Definition: scriptbundle_shared.csc:143
‪cScriptBundleObjectBase::_s
‪var _s
Definition: scriptbundle_shared.csc:9
‪is_testing
‪function is_testing()
Definition: scriptbundle_shared.csc:123
‪add_object
‪function add_object(o_object)
Definition: scriptbundle_shared.csc:128
‪_testing
‪var _testing
Definition: scriptbundle_shared.csc:82
‪cScriptBundleObjectBase::constructor
‪constructor()
Definition: scriptbundle_shared.csc:14
‪get_vm
‪function get_vm()
Definition: scriptbundle_shared.csc:113
‪_str_name
‪var _str_name
Definition: scriptbundle_shared.csc:79
‪log
‪function log(str_msg)
Definition: scriptbundle_shared.csc:138
‪cScriptBundleObjectBase::_o_bundle
‪var _o_bundle
Definition: scriptbundle_shared.csc:10
‪cScriptBundleObjectBase::log
‪function log(str_msg)
Definition: scriptbundle_shared.csc:45
‪waittill_notify_or_timeout
‪function waittill_notify_or_timeout(msg, timer)
Definition: util_shared.csc:473
‪on_error
‪function on_error(e)
Definition: scriptbundle_shared.csc:84
‪ARRAY_ADD
‪#define ARRAY_ADD(__array, __item)
Definition: shared.gsh:304
‪constructor
‪constructor()
Definition: scriptbundle_shared.csc:86
‪cScriptBundleObjectBase::error
‪function error(condition, str_msg)
Definition: scriptbundle_shared.csc:50
‪cScriptBundleObjectBase::init
‪function init(s_objdef, o_bundle, e_ent, localclientnum)
Definition: scriptbundle_shared.csc:22
‪get_name
‪function get_name()
Definition: scriptbundle_shared.csc:108
‪cScriptBundleObjectBase::destructor
‪destructor()
Definition: scriptbundle_shared.csc:18
‪_s
‪class cScriptBundleObjectBase _s
‪error_on_screen
‪function error_on_screen(str_msg)
Definition: scriptbundle_shared.csc:164
‪cScriptBundleObjectBase::get_ent
‪function get_ent(localClientNum)
Definition: scriptbundle_shared.csc:70
‪cScriptBundleObjectBase::_n_clientnum
‪var _n_clientnum
Definition: scriptbundle_shared.csc:12
‪get_objects
‪function get_objects()
Definition: scriptbundle_shared.csc:118
‪LUI_HUDELEM_ALIGNMENT_LEFT
‪#define LUI_HUDELEM_ALIGNMENT_LEFT
Definition: shared.gsh:151
‪STR_DEFAULT
‪#define STR_DEFAULT(__var, __def)
Definition: shared.gsh:298