Skip to content

AOperatingSystemPortableDeviceActor

#include <OperatingSystemSimulator/Public/Devices/OperatingSystemPortableDeviceActor.h>
class AOperatingSystemPortableDeviceActor

Defined in OperatingSystemPortableDeviceActor.h:43

Inherits: AOperatingSystemDeviceActor

---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class AOperatingSystemPortableDeviceActor["AOperatingSystemPortableDeviceActor"]
  class AOperatingSystemDeviceActor["AOperatingSystemDeviceActor"]
  AOperatingSystemDeviceActor <|-- AOperatingSystemPortableDeviceActor
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class AOperatingSystemPortableDeviceActor["AOperatingSystemPortableDeviceActor"]
  class FOperatingSystemBattery["FOperatingSystemBattery"]
  AOperatingSystemPortableDeviceActor *-- FOperatingSystemBattery
---
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
  }

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

ReturnNameDescription
AOperatingSystemPortableDeviceActor
voidBeginChargingBatteryBegins 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.
voidStopChargingBatteryStops charging the battery of the portable device.
voidSetBatterySets 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.
boolIsCharging constChecks whether the portable device is currently charging its battery.
floatGetChargingSpeed const inlineRetrieves the charging speed of the portable device.

AOperatingSystemPortableDeviceActor()

Defined in OperatingSystemPortableDeviceActor.h:100

  • CHECK_IN_BP
  • IMPLEMENTED_IN_BP_LAMBDA

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.

  • OutError (output) - The variable to store any errors that occur during the charging process.

See also: FGenericError


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


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.

  • 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


const

bool IsCharging() const

Defined in OperatingSystemPortableDeviceActor.h:169 Checks whether the portable device is currently charging its battery.

true if the device is charging, false otherwise.


const inline

inline float GetChargingSpeed(FGenericError & OutError) const

Defined 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.

  • OutError (output) - The variable to store any errors that occur during the process.

The charging speed of the portable device in seconds per unit.

See also: FGenericError

See also: FOperatingSystemBattery

ReturnNameDescription
FNameGetOperatingSystemBatteryLevelChangeEventName static inlineReturns the name of the battery level change event.
FNameGetOperatingSystemBatteryChargeEventName static inlineReturns the name of the battery charge event.
FNameGetOperatingSystemBatteryLowEventName static inlineReturns 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.

The name of the battery level change event.


static inline

static inline FName GetOperatingSystemBatteryChargeEventName()

Defined in OperatingSystemPortableDeviceActor.h:116 Returns the name of the battery charge event.

The name of the battery charge event.


static inline

static inline FName GetOperatingSystemBatteryLowEventName()

Defined in OperatingSystemPortableDeviceActor.h:124 Returns the name of the battery low event.

The name of the battery low event.

ReturnNameDescription
boolbHasBatteryDoes this device come with a battery. To turn on this device, you need a battery. Use SetBattery function to toggle at runtime.
int32BatteryLevelCurrent battery level.
floatBatteryConsumeDelaySeconds taken to consume 1 battery level if not charging.
FOperatingSystemBatteryCurrentBatteryCurrent battery.
uint8LowBatteryWarningLevelIf battery level is <= to this, then device emits a warning signal.
int32BatterySaveStateFlagsSelect your required battery states to save.
uint8bLowBatteryNotifiedDetermines if user has already been notified of low battery.

bool bHasBattery

Defined 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.


int32 BatteryLevel

Defined in OperatingSystemPortableDeviceActor.h:60 Current battery level.


float BatteryConsumeDelay

Defined in OperatingSystemPortableDeviceActor.h:64 Seconds taken to consume 1 battery level if not charging.


FOperatingSystemBattery CurrentBattery

Defined in OperatingSystemPortableDeviceActor.h:68 Current battery.


uint8 LowBatteryWarningLevel

Defined in OperatingSystemPortableDeviceActor.h:72 If battery level is <= to this, then device emits a warning signal.


int32 BatterySaveStateFlags

Defined in OperatingSystemPortableDeviceActor.h:76 Select your required battery states to save.


uint8 bLowBatteryNotified

Defined in OperatingSystemPortableDeviceActor.h:80 Determines if user has already been notified of low battery.

ReturnNameDescription
voidOnValidate virtual overrideValidates the portable device and returns any errors encountered.
voidOnNewDeviceCreated virtual overrideCalled when a new device is created.
voidOnSaveGame virtual overrideCalled when the game is being saved for a portable device.
voidOnLoadGame virtual overrideCallback function called when a game is loaded on a portable device.
boolIsPortableDeviceImpl virtual const inline override finalThis function always return true for this class. This method cannot be overridden by derived class since it is marked as final.
voidK2_OnBatteryLevelChangedNotifies when the battery level of the portable device changes.

virtual override

virtual void OnValidate(FGenericError & OutError) override

Defined 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 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.

  • OutError The output parameter that will contain any validation errors encountered during the validation.

virtual override

virtual void OnNewDeviceCreated(FGenericError & OutError) override

Defined 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.

  • OutError The output parameter for errors, if any occur during the method execution. If any error occurs, it will be set in this parameter.

virtual override

virtual void OnSaveGame(FOperatingSystemDeviceSaveLoad & SaveData) override

Defined 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.

  • 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

See also: AOperatingSystemPortableDeviceActor


virtual override

virtual void OnLoadGame(const FOperatingSystemDeviceSaveLoad & LoadData) override

Defined 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.

  • LoadData The save data containing the battery information.

See also: FOperatingSystemDeviceSaveLoad


virtual const inline override final

virtual inline bool IsPortableDeviceImpl() const override final

Defined 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.

true


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.

  • 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

ReturnNameDescription
FTimerHandleTimerHandle_BatteryCharging
FTimerHandleTimerHandle_BatteryConsume
TOptional< uint8 >PreChargeBatteryLevelOptional 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.

FTimerHandle TimerHandle_BatteryCharging

Defined in OperatingSystemPortableDeviceActor.h:47


FTimerHandle TimerHandle_BatteryConsume

Defined in OperatingSystemPortableDeviceActor.h:48


TOptional< uint8 > PreChargeBatteryLevel

Defined 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

ReturnNameDescription
voidInternal_ChargeBatteryInternal method to charge the battery of a portable device.
voidInternal_ConsumeBatteryInternal function to handle battery consumption for the portable device actor.
voidInternal_BroadcastSends an internal event broadcast to all subscribers.
boolInternal_IsBatterySaveStateEnabled const inlineCheck if a specific battery save state flag is enabled.

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


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


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.

  • EventName The name of the internal event to broadcast.

See also: GetDeviceMessenger()


const inline

inline bool Internal_IsBatterySaveStateEnabled(const EOperatingSystemBatterySaveStateFlags & TestFlag) const

Defined 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.

  • TestFlag The flag to test. It should be one of the values from the EOperatingSystemBatterySaveStateFlags enumeration.

True if the specified flag is enabled, false otherwise.

See also: EOperatingSystemBatterySaveStateFlags