-
Notifications
You must be signed in to change notification settings - Fork 1
base_bar
Class Name: COP_BaseBar
Inherits: Node
Inherited By: normal_bar
Base class for all the bar objects.
base_bar is the parent/base class for all the bar objects in the tool/plugin CodeOptPro. The script is designed in a way that every new bar type will need to extend from base_bar. That way it will be easier to keep the bars organized and having common parent. This will also help in making sure that new/current bars can be just dragged and dropped into other scripts and it will work no matter what type of a bar is used, SOLID principles. The bar for example can be used as player health.
Type | Name | Default Value |
---|---|---|
int | _value_max | 1 |
int | _value_cur | 0 |
Return Type | Name |
---|---|
void | set_max( int value ) |
void | set_current( int value ) |
float | get_normal() |
void | add( int value ) |
int | get_value_max() |
int | get_value_current() |
bool | if_full() |
bool | is_depleted() |
void | restore() |
void | subtract( int value ) |
int _value_max = 1
The maximum limit for the bar which is the maximum value. This value can NOT be less than 0.
int _value_cur = 0
The current value for the bar. This value can NOT be less than 0 or greater than _value_max.
void set_max (int value)
This method sets the _value_max property which is the maximum limit of the bar. The maximum limit can NOT be less than 1. If a value of less than 1 is provided then the maximum limit will be set to 1.
It is recommended to call this method once when the scene is ready. This will make sure to avoid any wrong results.
Note: Also make sure that this method is called before [set_current()][#void-set_current-int-value] method. Otherwise setup might give wrong results.
void set_current (int value)
This method sets the _value_cur property which is the current value of the bar. The current value can NOT be less than 0 or greater than _value_max. If a value of less than 0 is provided then the current value will be set to 0. If a value of greater than _value_max is provided then the current value will be set to _value_max.
It is recommended to call this method once when the scene is ready. This will make sure to avoid any wrong results.
Note: Also make sure that this method called after set_max method. Otherwise setup might give wrong results.
float get_normal ()
This method gets the normal value of the bar which is in the range of 0.0 to 1.0. This method is a powerful feature of the bar as you can use the normal value of the bar to sync with other features.
void add (int value)
This method adds to the _value_cur or the current value of the bar. The added amount will NOT go over _value_max or the max value. If value given makes the current value greater than max value then the current value will be set to max value.
Note: If the parameter value given is less than and equal to 0 then the calculation will be ignored and nothing will happen. Only positive values greater than 0 will be allowed for calculation.
int get_value_max ()
This method returns the _value_max value which is the maximum value.
int get_value_current()
This method returns the _value_cur which is the current value.
bool is_full ()
This method checks if the bar is full which is if _value_cur equals to _value_max.
bool is_depleted ()
This method checks if the bar is empty which is if _value_cur equals to zero.
This method makes the bar full again by making _value_cur equal to _value_max.
void subtract (int value)
This method subtracts the _value_cur with the given value.
- 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