AOperatingSystemPortableDeviceActor
#include <OperatingSystemSimulator/Public/Devices/OperatingSystemPortableDeviceActor.h>class AOperatingSystemPortableDeviceActorDefined in OperatingSystemPortableDeviceActor.h:43
Inherits:
AOperatingSystemDeviceActor
Inheritance diagram
Section titled “Inheritance diagram”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class AOperatingSystemPortableDeviceActor["AOperatingSystemPortableDeviceActor"]
class AOperatingSystemDeviceActor["AOperatingSystemDeviceActor"]
AOperatingSystemDeviceActor <|-- AOperatingSystemPortableDeviceActor
Collaboration diagram
Section titled “Collaboration diagram”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class AOperatingSystemPortableDeviceActor["AOperatingSystemPortableDeviceActor"]
class FOperatingSystemBattery["FOperatingSystemBattery"]
AOperatingSystemPortableDeviceActor *-- FOperatingSystemBattery
Class detail
Section titled “Class detail”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class AOperatingSystemPortableDeviceActor {
+AOperatingSystemPortableDeviceActor()
+BeginChargingBattery(FGenericError &OutError)
+StopChargingBattery()
+SetBattery(FOperatingSystemBattery NewBattery, FGeneri
+IsCharging() const bool
+GetChargingSpeed(FGenericError &OutError) const float
+GetOperatingSystemBatteryLevelChangeEventName() FName
+GetOperatingSystemBatteryChargeEventName() FName
+GetOperatingSystemBatteryLowEventName() FName
+bHasBattery : bool
+BatteryLevel : int32
+BatteryConsumeDelay : float
+CurrentBattery : FOperatingSystemBattery()
+LowBatteryWarningLevel : uint8
+BatterySaveStateFlags : int32
+bLowBatteryNotified : uint8
+OnValidate(FGenericError &OutError) override
+OnNewDeviceCreated(FGenericError &OutError) override
+OnSaveGame(FOperatingSystemDeviceSaveLoad &SaveData) o
+OnLoadGame(const FOperatingSystemDeviceSaveLoad &LoadD
+IsPortableDeviceImpl() const override final bool
+K2_OnBatteryLevelChanged(const bool bIsCharging)
+TimerHandle_BatteryCharging : FTimerHandle
+TimerHandle_BatteryConsume : FTimerHandle
+PreChargeBatteryLevel : TOptional< uint8 >
+Internal_ChargeBattery()
+Internal_ConsumeBattery()
+Internal_Broadcast(const FName &EventName)
+Internal_IsBatterySaveStateEnabled(const EOperatingSystemBatterySaveStateFlags bool
}
Caller impact — Internal_Broadcast
Section titled “Caller impact — Internal_Broadcast”Documented call sites inside the plugin (4):
flowchart LR AOperatingSystemPortableDeviceActor__Internal_Broadcast["AOperatingSystemPortableDeviceActor::Internal_Broadcast"] AOperatingSystemPortableDeviceActor__BeginChargingBattery["AOperatingSystemPortableDeviceActor::BeginChargingBattery"] AOperatingSystemPortableDeviceActor__BeginChargingBattery --> AOperatingSystemPortableDeviceActor__Internal_Broadcast AOperatingSystemPortableDeviceActor__Internal_ChargeBattery["AOperatingSystemPortableDeviceActor::Internal_ChargeBattery"] AOperatingSystemPortableDeviceActor__Internal_ChargeBattery --> AOperatingSystemPortableDeviceActor__Internal_Broadcast AOperatingSystemPortableDeviceActor__Internal_ConsumeBattery["AOperatingSystemPortableDeviceActor::Internal_ConsumeBattery"] AOperatingSystemPortableDeviceActor__Internal_ConsumeBattery --> AOperatingSystemPortableDeviceActor__Internal_Broadcast AOperatingSystemPortableDeviceActor__StopChargingBattery["AOperatingSystemPortableDeviceActor::StopChargingBattery"] AOperatingSystemPortableDeviceActor__StopChargingBattery --> AOperatingSystemPortableDeviceActor__Internal_Broadcast
Caller impact — Internal_IsBatterySaveStateEnabled
Section titled “Caller impact — Internal_IsBatterySaveStateEnabled”Documented call sites inside the plugin (4):
flowchart LR AOperatingSystemPortableDeviceActor__Internal_IsBatterySaveStateEnabled["AOperatingSystemPortableDeviceActor::Internal_IsBatterySaveStateEnabled"] AOperatingSystemPortableDeviceActor__Internal_ChargeBattery["AOperatingSystemPortableDeviceActor::Internal_ChargeBattery"] AOperatingSystemPortableDeviceActor__Internal_ChargeBattery --> AOperatingSystemPortableDeviceActor__Internal_IsBatterySaveStateEnabled AOperatingSystemPortableDeviceActor__Internal_ConsumeBattery["AOperatingSystemPortableDeviceActor::Internal_ConsumeBattery"] AOperatingSystemPortableDeviceActor__Internal_ConsumeBattery --> AOperatingSystemPortableDeviceActor__Internal_IsBatterySaveStateEnabled AOperatingSystemPortableDeviceActor__SetBattery["AOperatingSystemPortableDeviceActor::SetBattery"] AOperatingSystemPortableDeviceActor__SetBattery --> AOperatingSystemPortableDeviceActor__Internal_IsBatterySaveStateEnabled AOperatingSystemPortableDeviceActor__StopChargingBattery["AOperatingSystemPortableDeviceActor::StopChargingBattery"] AOperatingSystemPortableDeviceActor__StopChargingBattery --> AOperatingSystemPortableDeviceActor__Internal_IsBatterySaveStateEnabled
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
Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
AOperatingSystemPortableDeviceActor | ||
void | BeginChargingBattery | 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. |
void | StopChargingBattery | Stops charging the battery of the portable device. |
void | 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. |
bool | IsCharging const | Checks whether the portable device is currently charging its battery. |
float | GetChargingSpeed const inline | Retrieves the charging speed of the portable device. |
AOperatingSystemPortableDeviceActor
Section titled “AOperatingSystemPortableDeviceActor”AOperatingSystemPortableDeviceActor()Defined in OperatingSystemPortableDeviceActor.h:100
References
Section titled “References”CHECK_IN_BPIMPLEMENTED_IN_BP_LAMBDA
BeginChargingBattery
Section titled “BeginChargingBattery”void BeginChargingBattery(FGenericError & OutError)Defined in OperatingSystemPortableDeviceActor.h:134 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
Section titled “Parameters”OutError(output) - The variable to store any errors that occur during the charging process.
See also: FGenericError
References
Section titled “References”BatteryLevelbHasBatteryCurrentBatteryErrorExceptionDescriptionGetChargingSpeedGetOperatingSystemBatteryChargeEventNameInternal_BroadcastIsChargingIsValidMAKE_ERROROS_LOGOS_LOG_ERRORTimerHandle_BatteryChargingTimerHandle_BatteryConsumeValidate
StopChargingBattery
Section titled “StopChargingBattery”void StopChargingBattery()Defined in OperatingSystemPortableDeviceActor.h:149 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
See also: GetOperatingSystemBatteryLowEventName
See also: LowBatteryWarningLevel
Referenced by
Section titled “Referenced by”References
Section titled “References”BatteryLevelGetOperatingSystemBatteryChargeEventNameGetOperatingSystemBatteryLowEventNameInternal_BroadcastInternal_IsBatterySaveStateEnabledLowBatteryWarningLevelOS_LOGPreChargeBatteryLevelSaveGameStopChargeTimerHandle_BatteryCharging
SetBattery
Section titled “SetBattery”void SetBattery(FOperatingSystemBattery NewBattery, FGenericError & OutError)Defined in OperatingSystemPortableDeviceActor.h:161 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
Section titled “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
See also: FGenericError
References
Section titled “References”bHasBatteryCurrentBatteryErrorExceptionDescriptionInternal_IsBatterySaveStateEnabledIsValidMAKE_ERRORNewBatteryOS_LOG_ERRORResetSaveGameValidate
IsCharging
Section titled “IsCharging”const
bool IsCharging() constDefined in OperatingSystemPortableDeviceActor.h:169 Checks whether the portable device is currently charging its battery.
Returns
Section titled “Returns”true if the device is charging, false otherwise.
Referenced by
Section titled “Referenced by”References
Section titled “References”GetChargingSpeed
Section titled “GetChargingSpeed”const inline
inline float GetChargingSpeed(FGenericError & OutError) constDefined in OperatingSystemPortableDeviceActor.h:303 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
Section titled “Parameters”OutError(output) - The variable to store any errors that occur during the process.
Returns
Section titled “Returns”The charging speed of the portable device in seconds per unit.
See also: FGenericError
See also: FOperatingSystemBattery
Referenced by
Section titled “Referenced by”Public Static Methods
Section titled “Public Static Methods”| Return | Name | Description |
|---|---|---|
FName | GetOperatingSystemBatteryLevelChangeEventName static inline | Returns the name of the battery level change event. |
FName | GetOperatingSystemBatteryChargeEventName static inline | Returns the name of the battery charge event. |
FName | GetOperatingSystemBatteryLowEventName static inline | Returns the name of the battery low event. |
GetOperatingSystemBatteryLevelChangeEventName
Section titled “GetOperatingSystemBatteryLevelChangeEventName”static inline
static inline FName GetOperatingSystemBatteryLevelChangeEventName()Defined in OperatingSystemPortableDeviceActor.h:108 Returns the name of the battery level change event.
Returns
Section titled “Returns”The name of the battery level change event.
Referenced by
Section titled “Referenced by”GetOperatingSystemBatteryChargeEventName
Section titled “GetOperatingSystemBatteryChargeEventName”static inline
static inline FName GetOperatingSystemBatteryChargeEventName()Defined in OperatingSystemPortableDeviceActor.h:116 Returns the name of the battery charge event.
Returns
Section titled “Returns”The name of the battery charge event.
Referenced by
Section titled “Referenced by”GetOperatingSystemBatteryLowEventName
Section titled “GetOperatingSystemBatteryLowEventName”static inline
static inline FName GetOperatingSystemBatteryLowEventName()Defined in OperatingSystemPortableDeviceActor.h:124 Returns the name of the battery low event.
Returns
Section titled “Returns”The name of the battery low event.
Referenced by
Section titled “Referenced by”Protected Attributes
Section titled “Protected Attributes”| Return | Name | Description |
|---|---|---|
bool | bHasBattery | Does this device come with a battery. To turn on this device, you need a battery. Use SetBattery function to toggle at runtime. |
int32 | BatteryLevel | Current battery level. |
float | BatteryConsumeDelay | Seconds taken to consume 1 battery level if not charging. |
FOperatingSystemBattery | CurrentBattery | Current battery. |
uint8 | LowBatteryWarningLevel | If battery level is <= to this, then device emits a warning signal. |
int32 | BatterySaveStateFlags | Select your required battery states to save. |
uint8 | bLowBatteryNotified | Determines if user has already been notified of low battery. |
bHasBattery
Section titled “bHasBattery”bool bHasBatteryDefined in OperatingSystemPortableDeviceActor.h:56 Does this device come with a battery. To turn on this device, you need a battery. Use SetBattery function to toggle at runtime.
Referenced by
Section titled “Referenced by”BatteryLevel
Section titled “BatteryLevel”int32 BatteryLevelDefined in OperatingSystemPortableDeviceActor.h:60 Current battery level.
Referenced by
Section titled “Referenced by”BeginChargingBatteryInternal_ChargeBatteryInternal_ConsumeBatteryOnLoadGameOnNewDeviceCreatedOnSaveGameStopChargingBattery
BatteryConsumeDelay
Section titled “BatteryConsumeDelay”float BatteryConsumeDelayDefined in OperatingSystemPortableDeviceActor.h:64 Seconds taken to consume 1 battery level if not charging.
Referenced by
Section titled “Referenced by”CurrentBattery
Section titled “CurrentBattery”FOperatingSystemBattery CurrentBatteryDefined in OperatingSystemPortableDeviceActor.h:68 Current battery.
Referenced by
Section titled “Referenced by”LowBatteryWarningLevel
Section titled “LowBatteryWarningLevel”uint8 LowBatteryWarningLevelDefined in OperatingSystemPortableDeviceActor.h:72 If battery level is <= to this, then device emits a warning signal.
Referenced by
Section titled “Referenced by”BatterySaveStateFlags
Section titled “BatterySaveStateFlags”int32 BatterySaveStateFlagsDefined in OperatingSystemPortableDeviceActor.h:76 Select your required battery states to save.
bLowBatteryNotified
Section titled “bLowBatteryNotified”uint8 bLowBatteryNotifiedDefined in OperatingSystemPortableDeviceActor.h:80 Determines if user has already been notified of low battery.
Referenced by
Section titled “Referenced by”Protected Methods
Section titled “Protected Methods”| Return | Name | Description |
|---|---|---|
void | OnValidate virtual override | Validates the portable device and returns any errors encountered. |
void | OnNewDeviceCreated virtual override | Called when a new device is created. |
void | OnSaveGame virtual override | Called when the game is being saved for a portable device. |
void | OnLoadGame virtual override | Callback function called when a game is loaded on a portable device. |
bool | IsPortableDeviceImpl virtual const inline override final | This function always return true for this class. This method cannot be overridden by derived class since it is marked as final. |
void | K2_OnBatteryLevelChanged | Notifies when the battery level of the portable device changes. |
OnValidate
Section titled “OnValidate”virtual override
virtual void OnValidate(FGenericError & OutError) overrideDefined in OperatingSystemPortableDeviceActor.h:184 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
Validatemethod on theCurrentBatteryobject to check if the battery is valid. If any errors are encountered during the validation of the battery, they will be added toOutError. -
Checks if the
LowBatteryWarningLevelis within the valid range of 2 to 99. If the warning level is outside this range, it will add an error to theOutErrorparameter.
Parameters
Section titled “Parameters”OutErrorThe output parameter that will contain any validation errors encountered during the validation.
References
Section titled “References”Reimplements
Section titled “Reimplements”OnNewDeviceCreated
Section titled “OnNewDeviceCreated”virtual override
virtual void OnNewDeviceCreated(FGenericError & OutError) overrideDefined in OperatingSystemPortableDeviceActor.h:195 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
Section titled “Parameters”OutErrorThe output parameter for errors, if any occur during the method execution. If any error occurs, it will be set in this parameter.
References
Section titled “References”BatteryConsumeDelayBatteryLevelbHasBatteryCurrentBatteryGetHealthStateStringIsChargingMAKE_ERROROS_LOGTimerHandle_BatteryConsume
Reimplements
Section titled “Reimplements”OnSaveGame
Section titled “OnSaveGame”virtual override
virtual void OnSaveGame(FOperatingSystemDeviceSaveLoad & SaveData) overrideDefined in OperatingSystemPortableDeviceActor.h:212 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
Section titled “Parameters”-
SaveDataThe 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
See also: AOperatingSystemPortableDeviceActor
References
Section titled “References”BatteryLevelbHasBatterybSaveLoad_HasBatterybSaveLoad_IsPortableDeviceCurrentBatterySaveLoad_PortableBatterySaveLoad_PortableBatteryLevel
Reimplements
Section titled “Reimplements”OnLoadGame
Section titled “OnLoadGame”virtual override
virtual void OnLoadGame(const FOperatingSystemDeviceSaveLoad & LoadData) overrideDefined in OperatingSystemPortableDeviceActor.h:223 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
Section titled “Parameters”LoadDataThe save data containing the battery information.
See also: FOperatingSystemDeviceSaveLoad
References
Section titled “References”BatteryCapacityBatteryLevelbHasBatterybSaveLoad_HasBatterybSaveLoad_IsPortableDeviceChargeRateCurrentBatteryOS_LOGSaveLoad_PortableBatterySaveLoad_PortableBatteryLevel
Reimplements
Section titled “Reimplements”IsPortableDeviceImpl
Section titled “IsPortableDeviceImpl”virtual const inline override final
virtual inline bool IsPortableDeviceImpl() const override finalDefined in OperatingSystemPortableDeviceActor.h:231 This function always return true for this class. This method cannot be overridden by derived class since it is marked as final.
Returns
Section titled “Returns”true
Reimplements
Section titled “Reimplements”K2_OnBatteryLevelChanged
Section titled “K2_OnBatteryLevelChanged”void K2_OnBatteryLevelChanged(const bool bIsCharging)Defined in OperatingSystemPortableDeviceActor.h:242 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
Section titled “Parameters”bIsChargingThe current charging state of the battery. Iftrue, the battery is being charged; otherwise, the battery is not being charged.
See also: AOperatingSystemPortableDeviceActor
Referenced by
Section titled “Referenced by”Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
FTimerHandle | TimerHandle_BatteryCharging | |
FTimerHandle | TimerHandle_BatteryConsume | |
TOptional< uint8 > | PreChargeBatteryLevel | Optional pre-charge battery level that is set before starting the charging process. It is an optional field and may not be set in some cases. |
TimerHandle_BatteryCharging
Section titled “TimerHandle_BatteryCharging”FTimerHandle TimerHandle_BatteryChargingDefined in OperatingSystemPortableDeviceActor.h:47
Referenced by
Section titled “Referenced by”TimerHandle_BatteryConsume
Section titled “TimerHandle_BatteryConsume”FTimerHandle TimerHandle_BatteryConsumeDefined in OperatingSystemPortableDeviceActor.h:48
Referenced by
Section titled “Referenced by”PreChargeBatteryLevel
Section titled “PreChargeBatteryLevel”TOptional< uint8 > PreChargeBatteryLevelDefined in OperatingSystemPortableDeviceActor.h:96 Optional pre-charge battery level that is set before starting the charging process. It is an optional field and may not be set in some cases.
See also: AOperatingSystemPortableDeviceActor
See also: PreChargeBatteryLevel
Referenced by
Section titled “Referenced by”Private Methods
Section titled “Private Methods”| Return | Name | Description |
|---|---|---|
void | Internal_ChargeBattery | Internal method to charge the battery of a portable device. |
void | Internal_ConsumeBattery | Internal function to handle battery consumption for the portable device actor. |
void | Internal_Broadcast | Sends an internal event broadcast to all subscribers. |
bool | Internal_IsBatterySaveStateEnabled const inline | Check if a specific battery save state flag is enabled. |
Internal_ChargeBattery
Section titled “Internal_ChargeBattery”void Internal_ChargeBattery()Defined in OperatingSystemPortableDeviceActor.h:258 Internal method to charge the battery of a portable device.
This method is called to charge the battery of a portable device. It increases the battery level by 1 if the current level is between 0 and 99. If the battery level reaches 100, charging is stopped. It also notifies the actor that the battery level has changed and saves the game if the battery save state is enabled.
See also: AOperatingSystemPortableDeviceActor::K2_OnBatteryLevelChanged
See also: AOperatingSystemPortableDeviceActor::Internal_Broadcast
See also: AOperatingSystemPortableDeviceActor::Internal_IsBatterySaveStateEnabled
See also: UOperatingSystemSaveGame::SaveGame
References
Section titled “References”BatteryChargeBatteryLevelbLowBatteryNotifiedGetOperatingSystemBatteryLevelChangeEventNameInternal_BroadcastInternal_IsBatterySaveStateEnabledK2_OnBatteryLevelChangedPreChargeBatteryLevelSaveGameStopChargingBattery
Internal_ConsumeBattery
Section titled “Internal_ConsumeBattery”void Internal_ConsumeBattery()Defined in OperatingSystemPortableDeviceActor.h:271 Internal function to handle battery consumption for the portable device actor.
The Internal_ConsumeBattery function is responsible for decrementing the battery level and performing various operations based on the battery level. It also checks if the battery save state is enabled for consuming battery and saves the game if necessary. If the battery level reaches 0, it initiates a shutdown.
See also: AOperatingSystemPortableDeviceActor
See also: FOperatingSystemBattery
See also: UOperatingSystemSaveGame
References
Section titled “References”BatteryConsumeBatteryLevelbLowBatteryNotifiedGetOperatingSystemBatteryLevelChangeEventNameGetOperatingSystemBatteryLowEventNameInternal_BroadcastInternal_IsBatterySaveStateEnabledK2_OnBatteryLevelChangedLowBatteryWarningLevelOS_LOGOS_LOG_VERBOSESaveGame
Internal_Broadcast
Section titled “Internal_Broadcast”void Internal_Broadcast(const FName & EventName)Defined in OperatingSystemPortableDeviceActor.h:288 Sends an internal event broadcast to all subscribers.
This method sends an internal event broadcast to all subscribers. The event name is specified as a parameter. The method uses the device messenger to broadcast the event to all subscribed actors. The method does not return a value.
Parameters
Section titled “Parameters”EventNameThe name of the internal event to broadcast.
See also: GetDeviceMessenger()
Referenced by
Section titled “Referenced by”Internal_IsBatterySaveStateEnabled
Section titled “Internal_IsBatterySaveStateEnabled”const inline
inline bool Internal_IsBatterySaveStateEnabled(const EOperatingSystemBatterySaveStateFlags & TestFlag) constDefined in OperatingSystemPortableDeviceActor.h:327 Check if a specific battery save state flag is enabled.
This method checks if a specific battery save state flag is enabled for a portable device.
Parameters
Section titled “Parameters”TestFlagThe flag to test. It should be one of the values from the EOperatingSystemBatterySaveStateFlags enumeration.
Returns
Section titled “Returns”True if the specified flag is enabled, false otherwise.
See also: EOperatingSystemBatterySaveStateFlags