-
Notifications
You must be signed in to change notification settings - Fork 1
Tutorial Variable Creator
I have also added a feature that allows to share/use data in a performant way by extending the Resource script. For now there are 3 categories of data share and each have their own different data types.
In this category different type of data types are shared, example bool, float, int, string etc. You only need to create one fixed var and share it with multiple objects, example - If five objects needs an int value of 1 then create a fixed var of type int that has the value 1 and share that. In that way only one int value of 1 is created instead of five which saves some memory. Like the name suggests the values are fixed and can/should NOT be updated. Otherwise it defeats the purpose of its function. Only call the get_value() function to get the value and do NOT change the property _value through script.
- COP_FixedBoolVar - This FixedVar type shares bool data types. When creating the COP_FixedBoolVar set the value either true or false by clicking the tick box. To get the value simply call the method get_value(). To use COP_FixedBoolVar simply change the type of a var to COP_FixedBoolVar.
- COP_FixedFloatVar - This FixedVar type shares float data types. When creating the COP_FixedFloatVar set the value to any float type value. To get the value simply call the method get_value(). To use COP_FixedFloatVar simply change the type of a var to COP_FixedFloatVar.
- COP_FixedIntVar - This FixedVar type shares int data types. When creating the COP_FixedIntVar set the value to any int type value. To get the value simply call the method get_value(). To use COP_FixedIntVar simply change the type of a var to COP_FixedIntVar.
- COP_FixedStringVar - This FixedVar type shares String data types. When creating the COP_FixedStringVar set the value to any String type value. To get the value simply call the method get_value(). To use COP_FixedStringVar simply change the type of a var to COP_FixedStringVar.
- COP_FixedVector2Var - This FixedVar type shares Vector2 data types. When creating the COP_FixedVector2Var set the value to any Vector2 type value. To get the value simply call the method get_value(). To use COP_FixedVector2Var simply change the type of a var to COP_FixedVector2Var.
- COP_FixedVector3Var - This FixedVar type shares Vector3 data types. When creating the COP_FixedVector3Var set the value to any Vector3 type value. To get the value simply call the method get_value(). To use COP_FixedVector3Var simply change the type of a var to COP_FixedVector3Var.
- fixed_var_template - For creating a new COP_FixedVar type you can simply use the script templates that are already present in the addon. Go to the folder addons -> kamran_wali -> code_opt_pro and then copy the folder script_templates. Paste the copy folder to the root folder res://. Now you can use the script templates to create a new COP_FixedVar. Just create a new script and make sure to Inherit from Resource. Then in the Template section select Resource: Fixed Var Template. Give the script any name you want and finally create it. Now in the script make sure to give it a class name if you want to which has been commented out. For the _value, change it to any type you want. Finally for the get_value() method make sure to give it a return type as well which may help with performance a bit.
This category shares different type of managers instead of data types. Managers are scripts that have a bit of complex logic to it and these manager resources helps to share the references to those managers in a decoupled way. In this case unfortunately Variable Creator will only create managers that are created in CodeOptPro but if you want to create your own custom manager then you can use the manager_helper_template which is under the Resources while creating a script. The manager that is going to be referenced MUST be the only one that calls the method void set_manager(manager) and provides self as reference. Other scripts using this manager helper resource reference MUST only call the method get_manager() and then use the manager's methods from there. You can check out the script cop_update_manager_global_helper to see how the manager resource script is coded.
- COP_PoolHelper - This manager's reference type stores and uses any script that is a child of base_pool. For now the scripts pool_global and pool_local can be stored and used by this reference helper script.
- COP_UpdateManagerGlobalHelper - This manager's reference type stores and uses any script that is a child of base_update_manager. For now the scripts physics_process_manager_local, physics_process_manager_global, process_manager_local and process_manager_global can be stored and used by this reference helper script.
- manager_helper_template - For creating a new COP_Helper type you can simply use the script templates that are already present in the addon. Go to the folder addons -> kamran_wali -> code_opt_pro and then copy the folder script_templates. Paste the copy folder to the root folder res://. Now you can use the script templates to create a new COP_Helper. Just create a new script and make sure to Inherit from Resource. Then in the Template section select Resource: Manager Helper Template. Give the script any name you want and finally create it. Now in the script make sure to give it a class name if you want to which has been commented out. For the _manager, change it to any script type you want. For the get_manager() method make sure to give it a return type as well which may help with performance a bit. Finally for the set_manager(manager) method make sure the parameter has a type as well which may also help with performance.
This category shares different type of observers like bool, float, int and String. The variables in this category uses the observer pattern to send signals to the observer. Basically when the value in the observer changes then it will emit that change to the observers. The emit is done using Godot's Signals. The observers are similar to the Vars but the only difference being that the observers can emit signals. Read the Vars to understand how the values are stored.
- COP_ObserverAction - This observer type has no data type. It only has a signal with no parameters. To emit the signal simply call action(). For removing all the callables from the observer simply call the method disconnect_all().
- COP_ObserverBool - This observer type shares and emits the bool data type. To add an observer simply connect to the signal value_changed(bool value). To set the value simply call set_value(bool). To set the value and emit it simply call set_value_emit(bool). To get the value just call bool get_value(). To get the value and emit it then just call bool get_value_emit(). For removing all the callables from the observer simply call the method disconnect_all().
- COP_ObserverFloat - This observer type shares and emits the float data type. To add an observer simply connect to the signal value_changed(float value). To set the value simply call void set_value(value). To set the value and emit it simply call void set_value_emit(value). To get the value just call float get_value(). To get the value and emit it then just call float get_value_emit(). For removing all the callables from the observer simply call the method disconnect_all().
- COP_ObserverInt - This observer type shares and emits the int data type. To add an observer simply connect to the signal value_changed(int value). To set the value simply call void set_value(value). To set the value and emit it simply call void set_value_emit(value). To get the value just call int get_value(). To get the value and emit it then just call int get_value_emit(). For removing all the callables from the observer simply call the method void disconnect_all().
- COP_ObserverString - This observer type shares and emits the String data type. To add an observer simply connect to the signal value_changed(String value). To set the value simply call void set_value(value). To set the value and emit it simply call void set_value_emit(value). To get the value just call get_value(). To get the value and emit it then just call get_value_emit(). For removing all the callables from the observer simply call the method void disconnect_all().
- COP_ObserverVector2 - This observer type shares and emits the Vector2 data type. To add an observer simply connect to the signal value_changed(Vector2 value). To set the value simply call void set_value(value). To set the value and emit it simply call void set_value_emit(value). To get the value just call get_value(). To get the value and emit it then just call get_value_emit(). For removing all the callables from the observer simply call the method void disconnect_all().
- Tutorial Bar
- Tutorial Debug
- Tutorial Instantiate Object
- Tutorial Pool
- Tutorial Timer
- Tutorial Update Manager
- Tutorial Variable Creator
- Bars
- Debugs
- Maths
- Pools
- Resources
- Fixed Vars
- Managers
- Observers
- Vars
- Script Templates
- Timers
- Updates