-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add documentation to class of time module
- Loading branch information
Showing
4 changed files
with
148 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Clock Class | ||
|
||
The `Clock` class is part of the `Alis.Core.Aspect.Time` namespace. It is used to manage and measure time in an application. | ||
|
||
## Properties | ||
|
||
- `Elapsed`: Gets the total elapsed time measured by the current instance. | ||
- `ElapsedMilliseconds`: Gets the total elapsed time measured by the current instance, in milliseconds. | ||
- `ElapsedTicks`: Gets the total elapsed time measured by the current instance, in timer ticks. | ||
- `ElapsedSeconds`: Gets the total elapsed time measured by the current instance, in seconds. | ||
|
||
## Methods | ||
|
||
- `Start()`: Starts, or resumes, measuring elapsed time for an interval. | ||
- `Stop()`: Stops measuring elapsed time for an interval. | ||
- `Reset()`: Stops time interval measurement and resets the elapsed time to zero. | ||
|
||
## Usage | ||
|
||
Here is an example of how to use the `Clock` class: | ||
|
||
```csharp | ||
Clock clock = new Clock(); | ||
clock.Start(); | ||
// Do some work | ||
clock.Stop(); | ||
Console.WriteLine($"Elapsed time: {clock.ElapsedMilliseconds} ms"); | ||
``` | ||
|
||
In this example, a new `Clock` object is created and started. After some work is done, the clock is stopped and the elapsed time is printed to the console. | ||
|
||
### Notes | ||
|
||
The Clock class is useful for measuring elapsed time during the execution of your program. It can be used to time the execution of code blocks, measure performance, or create time-dependent functionality. The Elapsed property provides the most accurate time measurement, while the ElapsedMilliseconds and ElapsedSeconds properties provide more human-readable time measurements. The ElapsedTicks property provides a low-level time measurement in timer ticks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
# Time Configuration | ||
# TimeConfiguration Class | ||
|
||
The `TimeConfiguration` class is part of the `Alis.Core.Aspect.Time` namespace. It is used to manage time-related configurations in an application. | ||
|
||
## Properties | ||
|
||
- `FixedTimeStep`: A framerate-independent interval that dictates when physics calculations and FixedUpdate() events are performed. | ||
- `MaximumAllowedTimeStep`: A framerate-independent interval that caps the worst case scenario when frame-rate is low. Physics calculations and FixedUpdate() events will not be performed for longer time than specified. | ||
- `TimeScale`: The speed at which time progresses. Change this value to simulate bullet-time effects. A value of 1 means real-time. A value of .5 means half speed; a value of 2 is double speed. | ||
|
||
## Constructor | ||
|
||
The `TimeConfiguration` class has a constructor that accepts three parameters, each corresponding to one of the properties mentioned above. The parameters have default values, so they can be omitted when instantiating the `TimeConfiguration` class. | ||
|
||
```csharp | ||
public TimeConfiguration(float fixedTimeStep = 0.016f, float maximumAllowedTimeStep = 0.10f, float timeScale = 1.00f) | ||
``` | ||
|
||
## Usage | ||
|
||
Here is an example of how to use the `TimeConfiguration` class: | ||
|
||
```csharp | ||
TimeConfiguration timeConfig = new TimeConfiguration(0.02f, 0.15f, 1.0f); | ||
``` | ||
|
||
In this example, a new `TimeConfiguration` object is created with a `FixedTimeStep` of 0.02, a `MaximumAllowedTimeStep` of 0.15, and a `TimeScale` of 1.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,55 @@ | ||
# Time Manager | ||
# TimeManager Class | ||
|
||
The `TimeManager` class is part of the `Alis.Core.Aspect.Time` namespace. It provides an interface to get time information and manage time in an application. | ||
|
||
## Properties | ||
|
||
- `Configuration`: Gets or sets the value of the configuration. It is represented as a `TimeConfiguration` object. | ||
- `Clock`: Gets the value of the clock. It is represented as a `Clock` object. | ||
- `DeltaTime`: The interval in seconds from the last frame to the current one. | ||
- `FixedDeltaTime`: The interval in seconds at which physics and other fixed frame rate updates. | ||
- `FixedTime`: The time since the last FixedUpdate started. This is the time in seconds since the start of the game. | ||
- `FixedTimeAsDouble`: The double precision time since the last FixedUpdate started. This is the time in seconds since the start of the game. | ||
- `FixedUnscaledDeltaTime`: The timeScale-independent interval in seconds from the last Runtime.FixedUpdate() phase to the current one. | ||
- `FixedUnscaledTime`: The timeScale-independent time at the beginning of the last Runtime.FixedUpdate() phase. This is the time in seconds since the start of the game. | ||
- `FixedUnscaledTimeAsDouble`: The double precision timeScale-independent time at the beginning of the last FixedUpdate. This is the time in seconds since the start of the game. | ||
- `FrameCount`: The total number of frames since the start of the game. | ||
- `InFixedTimeStep`: Returns true if called inside a fixed time step callback (like Runtime FixedUpdate), otherwise returns false. | ||
- `MaximumDeltaTime`: The maximum value of TimeManager.DeltaTime in any given frame. This is a time in seconds that limits the increase of TimeManager.time between two frames. | ||
- `RealtimeSinceStartup`: The real time in seconds since the game started. | ||
- `RealtimeSinceStartupAsDouble`: The real time in seconds since the game started. Double precision version of realtimeSinceStartup. | ||
- `SmoothDeltaTime`: A smoothed out TimeManager.DeltaTime. | ||
- `Time`: The time at the beginning of this frame. | ||
- `TimeAsDouble`: The double precision time at the beginning of this frame. This is the time in seconds since the start of the game. | ||
- `TimeScale`: The scale at which time passes. | ||
- `UnscaledDeltaTime`: The timeScale-independent interval in seconds from the last frame to the current one. | ||
- `UnscaledTime`: The timeScale-independent time for this frame. This is the time in seconds since the start of the game. | ||
- `UnscaledTimeAsDouble`: The double precision timeScale-independent time for this frame. This is the time in seconds since the start of the game. | ||
|
||
## Constructor | ||
|
||
The `TimeManager` class has a constructor that initializes a new instance of the `TimeManager` class and starts the clock. | ||
|
||
```csharp | ||
public TimeManager() | ||
{ | ||
Clock = new Clock(); | ||
Clock.Start(); | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
Here is an example of how to use the `TimeManager` class: | ||
|
||
```csharp | ||
TimeManager timeManager = new TimeManager(); | ||
// Do some work | ||
Console.WriteLine($"Elapsed time: {timeManager.Clock.ElapsedMilliseconds} ms"); | ||
``` | ||
|
||
In this example, a new `TimeManager` object is created and started. After some work is done, the elapsed time is printed to the console. | ||
|
||
### Notes | ||
|
||
The TimeManager class is a crucial part of any game or application that requires time management. It provides a comprehensive set of properties and methods to manage time in your application. The TimeManager class uses the Clock and TimeConfiguration classes to provide a high level of abstraction for managing time. The TimeManager class is designed to be easy to use and understand, making it a great choice for developers of all skill levels. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# TimeStep Class | ||
|
||
The `TimeStep` class is part of the `Alis.Core.Aspect.Time` namespace. It is used to manage and measure time steps in an application. | ||
|
||
## Properties | ||
|
||
- `DeltaTime`: Time step (Delta time). | ||
- `DeltaTimeRatio`: dt * inv_dt0. | ||
- `InvertedDeltaTime`: Inverse time step (0 if dt == 0). | ||
- `InvertedDeltaTimeZero`: The inverted delta time. | ||
- `PositionIterations`: The position iterations. | ||
- `VelocityIterations`: The velocity iterations. | ||
- `WarmStarting`: The warm starting. | ||
|
||
## Methods | ||
|
||
- `Reset()`: Resets this instance. It does not return any value. | ||
|
||
## Usage | ||
|
||
Here is an example of how to use the `TimeStep` class: | ||
|
||
```csharp | ||
TimeStep timeStep = new TimeStep(); | ||
// Do some work | ||
timeStep.Reset(); | ||
``` | ||
|
||
In this example, a new `TimeStep` object is created. After some work is done, the `Reset` method is called to reset the instance. | ||
|
||
## Notes | ||
|
||
The `TimeStep` class is useful for managing and measuring time steps in your application. It provides a set of properties to get and set time step information, and a method to reset the instance. The `TimeStep` class is designed to be easy to use and understand, making it a great choice for developers of all skill levels. |