#include "OperatingSystemPortableDeviceActor.h"
AOperatingSystemPortableDeviceActor is a class that represents a portable device in an operating system simulation. It inherits from AOperatingSystemDeviceActor and adds functionality specific to portable devices, such as battery management.
The class provides properties and functions to manage the battery of the device, including charging, battery level monitoring, and battery health state.
- See also
- AOperatingSystemDeviceActor
◆ AOperatingSystemPortableDeviceActor()
AOperatingSystemPortableDeviceActor::AOperatingSystemPortableDeviceActor |
( |
| ) |
|
◆ BeginChargingBattery()
void AOperatingSystemPortableDeviceActor::BeginChargingBattery |
( |
FGenericError & | OutError | ) |
|
Begins the charging process for the battery of the portable device. If there are any errors during the charging process, the errors will be stored in the provided FGenericError parameter.
- Parameters
-
OutError | (output) - The variable to store any errors that occur during the charging process. |
- See also
- FGenericError
◆ GetChargingSpeed()
FORCEINLINE float AOperatingSystemPortableDeviceActor::GetChargingSpeed |
( |
FGenericError & | OutError | ) |
const |
|
inline |
Retrieves the charging speed of the portable device.
The charging speed is calculated based on the time required to fully recharge the current battery. If the battery is not valid, the function returns 0.0.
- Parameters
-
OutError | (output) - The variable to store any errors that occur during the process. |
- Returns
- The charging speed of the portable device in seconds per unit.
- See also
- FGenericError
-
FOperatingSystemBattery
◆ GetOperatingSystemBatteryChargeEventName()
static FName AOperatingSystemPortableDeviceActor::GetOperatingSystemBatteryChargeEventName |
( |
| ) |
|
|
inlinestatic |
Returns the name of the battery charge event.
- Returns
- The name of the battery charge event.
◆ GetOperatingSystemBatteryLevelChangeEventName()
static FName AOperatingSystemPortableDeviceActor::GetOperatingSystemBatteryLevelChangeEventName |
( |
| ) |
|
|
inlinestatic |
Returns the name of the battery level change event.
- Returns
- The name of the battery level change event.
◆ GetOperatingSystemBatteryLowEventName()
static FName AOperatingSystemPortableDeviceActor::GetOperatingSystemBatteryLowEventName |
( |
| ) |
|
|
inlinestatic |
Returns the name of the battery low event.
- Returns
- The name of the battery low event.
◆ IsCharging()
bool AOperatingSystemPortableDeviceActor::IsCharging |
( |
| ) |
const |
Checks whether the portable device is currently charging its battery.
- Returns
- true if the device is charging, false otherwise.
◆ IsPortableDeviceImpl()
virtual bool AOperatingSystemPortableDeviceActor::IsPortableDeviceImpl |
( |
| ) |
const |
|
inlinefinaloverrideprotectedvirtual |
This function always return true for this class. This method cannot be overridden by derived class since it is marked as final.
- Returns
- true
Reimplemented from AOperatingSystemDeviceActor.
◆ K2_OnBatteryLevelChanged()
void AOperatingSystemPortableDeviceActor::K2_OnBatteryLevelChanged |
( |
const bool | bIsCharging | ) |
|
|
protected |
Notifies when the battery level of the portable device changes.
The function K2_OnBatteryLevelChanged
is a blueprint event that is triggered when the battery level of the portable device changes.
- Parameters
-
bIsCharging | The current charging state of the battery. If true , the battery is being charged; otherwise, the battery is not being charged. |
- See also
- AOperatingSystemPortableDeviceActor
◆ OnLoadGame()
Callback function called when a game is loaded on a portable device.
This function is called when a game is loaded on a portable device. It updates the battery information based on the save data provided.
- Parameters
-
LoadData | The save data containing the battery information. |
- See also
- FOperatingSystemDeviceSaveLoad
Reimplemented from AOperatingSystemDeviceActor.
◆ OnNewDeviceCreated()
void AOperatingSystemPortableDeviceActor::OnNewDeviceCreated |
( |
FGenericError & | OutError | ) |
|
|
overrideprotectedvirtual |
Called when a new device is created.
This method is called when a new device is created in the portable device actor. It checks if the device has a battery and if it is charging. If the device does not have a battery , an error is returned. If the device is not charging and the battery level is less than 1, an error is returned. If the conditions are met, the method sets a timer to consume the battery power periodically. Finally, the method logs the battery charge level and the health state of the battery.
- Parameters
-
OutError | The output parameter for errors, if any occur during the method execution. If any error occurs, it will be set in this parameter. |
Reimplemented from AOperatingSystemDeviceActor.
◆ OnSaveGame()
Called when the game is being saved for a portable device.
This method handles the saving of game data for a portable device. It is called when the game is being saved. The method saves the necessary device information such as the battery status and level.
- Parameters
-
SaveData | The save/load data object that contains the information to be saved.
- bSaveLoad_IsPortableDevice: A boolean indicating if the device is portable.
- bSaveLoad_HasBattery: A boolean indicating if the device has a battery.
- SaveLoad_PortableBatteryLevel: The current battery level of the device (between 0 and 100).
- SaveLoad_PortableBattery: The current battery status of the device.
|
- See also
- FOperatingSystemDeviceSaveLoad
-
AOperatingSystemPortableDeviceActor
Reimplemented from AOperatingSystemDeviceActor.
◆ OnValidate()
void AOperatingSystemPortableDeviceActor::OnValidate |
( |
FGenericError & | OutError | ) |
|
|
overrideprotectedvirtual |
Validates the portable device and returns any errors encountered.
The OnValidate
method is used to validate the portable device and check for any errors. If any errors are encountered during the validation process, they will be returned in the OutError
parameter.
This method performs the following validations:
- Calls the
Validate
method on the CurrentBattery
object to check if the battery is valid. If any errors are encountered during the validation of the battery, they will be added to OutError
.
- Checks if the
LowBatteryWarningLevel
is within the valid range of 2 to 99. If the warning level is outside this range, it will add an error to the OutError
parameter.
- Parameters
-
OutError | The output parameter that will contain any validation errors encountered during the validation. |
Reimplemented from AOperatingSystemDeviceActor.
◆ SetBattery()
Sets the battery of the portable device. If there are any errors during the battery setting process, the errors will be stored in the provided FGenericError parameter.
- Parameters
-
NewBattery | (input) - The new battery to be set. |
OutError | (output) - The variable to store any errors that occur during the battery setting process. |
- See also
- FOperatingSystemBattery
-
FGenericError
◆ StopChargingBattery()
void AOperatingSystemPortableDeviceActor::StopChargingBattery |
( |
| ) |
|
Stops charging the battery of the portable device.
This method stops the charging of the battery and performs the necessary actions when the charging process is stopped. The method clears the timer for battery charging, broadcasts the battery charge event, and checks if the battery level is below the low battery warning level. If the battery level is below the warning level, the method broadcasts the battery low event.
- See also
- GetOperatingSystemBatteryChargeEventName
-
GetOperatingSystemBatteryLowEventName
-
LowBatteryWarningLevel
◆ BatteryConsumeDelay
float AOperatingSystemPortableDeviceActor::BatteryConsumeDelay |
|
protected |
Seconds taken to consume 1 battery level if not charging.
◆ BatteryLevel
int32 AOperatingSystemPortableDeviceActor::BatteryLevel |
|
protected |
◆ BatterySaveStateFlags
int32 AOperatingSystemPortableDeviceActor::BatterySaveStateFlags |
|
protected |
Select your required battery states to save.
◆ bHasBattery
bool AOperatingSystemPortableDeviceActor::bHasBattery |
|
protected |
Does this device come with a battery. To turn on this device, you need a battery. Use SetBattery function to toggle at runtime.
◆ bLowBatteryNotified
uint8 AOperatingSystemPortableDeviceActor::bLowBatteryNotified |
|
protected |
Determines if user has already been notified of low battery.
◆ CurrentBattery
◆ LowBatteryWarningLevel
uint8 AOperatingSystemPortableDeviceActor::LowBatteryWarningLevel |
|
protected |
If battery level is <= to this, then device emits a warning signal.
The documentation for this class was generated from the following files: