Skip to content

base_timer

Kamran Wali edited this page Dec 2, 2024 · 5 revisions

Class Name: COP_BaseTimer

Inherits: Node

Inherited By: timer_countdown

Base class for all the timer objects.

Description

base_timer is the parent/base class for all the timer objects. This script handles featured related to time that is counting down or up.

The script is designed in a way that every new timer object type will need to extend from base_timer. That way it will be easier to keep the timer objects organized and having common parent. This will also help in making sure that new/current timer objects can be just dragged and dropped into other scripts and it will work no matter what type of a timer objct is used, SOLID principles.

Tutorial

Methods

Return Type Name
void set_time( float time_seconds )
void update_timer( float delta )
void reset_timer()
void stop_timer()
bool is_timer_done()
float get_time_seconds()
float get_current_time_seconds()
float normalized()

Method Descriptions

void set_time ( float time_seconds )

This method sets/overrides the timer's time.

Note: The method needs to be overridden by child scripts as this is a stub method in the base script.


void update_timer ( float delta )

This method updates the timer. For timer countdown or countup logic must be given here. This method MUST be called from other scripts for the countdown to work.

Note: The method needs to be overridden by child scripts as this is a stub method in the base script.


void reset_timer ()

This method resets the timer.

Note: The method needs to be overridden by child scripts as this is a stub method in the base script.


void stop_timer ()

This method stops the timer.

Note: The method needs to be overridden by child scripts as this is a stub method in the base script.


bool is_timer_done ()

This method checks if the timer is done processing.

Note: The method needs to be overridden by child scripts as this method only returns true.


float get_time_seconds ()

This method gets the time second value that was set for the timer.

Note: The method needs to be overridden by child scripts as this is method only returns 0.0.


float get_current_time_seconds ()

This method gets the current time, in seconds, for the timer.

Note: The method needs to be overridden by child scripts as this is method only returns 0.0.


float normalized ()

This method gets the normalized value of the time in timer, range 0.0 - 1.0. This value can be used to synchronize with other features.

Note: The method needs to be overridden by child scripts as this is method only returns 0.0.


Clone this wiki locally