Operating System Simulator Plugin  3.5.1
Unreal Engine plugin that simulates an Operating System Environment
Loading...
Searching...
No Matches
AOperatingSystemPortableDeviceActor Class Reference

#include "OperatingSystemPortableDeviceActor.h"

Inheritance diagram for AOperatingSystemPortableDeviceActor:
[legend]
Collaboration diagram for AOperatingSystemPortableDeviceActor:
[legend]

Public Member Functions

 AOperatingSystemPortableDeviceActor ()
 
OPERATINGSYSTEMSIMULATOR_API void BeginChargingBattery (FGenericError &OutError)
 
OPERATINGSYSTEMSIMULATOR_API void StopChargingBattery ()
 
OPERATINGSYSTEMSIMULATOR_API void SetBattery (FOperatingSystemBattery NewBattery, FGenericError &OutError)
 
OPERATINGSYSTEMSIMULATOR_API bool IsCharging () const
 
FORCEINLINE float GetChargingSpeed (FGenericError &OutError) const
 
- Public Member Functions inherited from AOperatingSystemDeviceActor
OPERATINGSYSTEMSIMULATOR_API void CreateDevice (FGenericError &OutError)
 
void CurrentDeviceDestroyed ()
 Method to handle the destruction of the current device.
 
void RestartDevice ()
 
void WidgetChanged (UUserWidget *ChangedWidget)
 Handles the event when a widget is changed.
 
void OnShowBlueScreen (const float &OnScreenTime)
 
void StopMediaAudio () const
 
OPERATINGSYSTEMSIMULATOR_API UOperatingSystemBaseHardwareGetHardwareByTag (const FGameplayTag &TestTag) const
 
void SetAddWidgetsToScreen (const EOperatingSystemWidgetSet Method)
 
void ClearWidgetFromScreen () const
 
void RefreshWidget () const
 
OPERATINGSYSTEMSIMULATOR_API bool IsPortableDevice () const
 Determines whether the operating system device actor is a portable device.
 
void BeginDestroyMessenger ()
 
void FinishDestroyMessenger ()
 A method to finish the destruction of the operating system device actor.
 

Static Public Member Functions

static FName GetOperatingSystemBatteryLevelChangeEventName ()
 
static FName GetOperatingSystemBatteryChargeEventName ()
 
static FName GetOperatingSystemBatteryLowEventName ()
 

Protected Member Functions

virtual OPERATINGSYSTEMSIMULATOR_API void OnValidate (FGenericError &OutError) override
 Validates the portable device and returns any errors encountered.
 
virtual OPERATINGSYSTEMSIMULATOR_API void OnNewDeviceCreated (FGenericError &OutError) override
 Called when a new device is created.
 
virtual OPERATINGSYSTEMSIMULATOR_API void OnSaveGame (FOperatingSystemDeviceSaveLoad &SaveData) override
 Called when the game is being saved for a portable device.
 
virtual OPERATINGSYSTEMSIMULATOR_API void OnLoadGame (const FOperatingSystemDeviceSaveLoad &LoadData) override
 Callback function called when a game is loaded on a portable device.
 
virtual bool IsPortableDeviceImpl () const override final
 
void K2_OnBatteryLevelChanged (const bool bIsCharging)
 Notifies when the battery level of the portable device changes.
 
- Protected Member Functions inherited from AOperatingSystemDeviceActor
bool K2_CreateDevice (FGenericError &OutError)
 
void K2_OnCurrentDeviceDestroyed ()
 
void K2_OnWidgetChanged (UUserWidget *ChangedWidget)
 Notifies the actor when the widget has changed.
 
void K2_OnBlueScreenShow (const float &OnScreenTime)
 

Protected Attributes

bool bHasBattery
 
int32 BatteryLevel
 
float BatteryConsumeDelay
 
FOperatingSystemBattery CurrentBattery
 
uint8 LowBatteryWarningLevel
 
int32 BatterySaveStateFlags
 
uint8 bLowBatteryNotified: 1
 
- Protected Attributes inherited from AOperatingSystemDeviceActor
TObjectPtr< USceneComponent > MainComponent
 
TObjectPtr< UMediaSoundComponent > MediaSoundComponent
 
FGameplayTag DeviceTag
 
TSoftClassPtr< UOperatingSystemBaseDeviceDeviceClass
 
uint8 bCreateDeviceOnBeginPlay: 1
 
uint8 bAddWidgetsToScreen: 1
 
uint8 bExitWhenDeviceIsDestroyed: 1
 
uint8 bCanSaveGame: 1
 
TSoftClassPtr< UOperatingSystemSaveGameSaveGameClass
 
TSoftClassPtr< UOperatingSystemDeviceMessengerMessengerClass
 
TObjectPtr< UOperatingSystemSaveGameLoadGameInstance
 

Additional Inherited Members

- Public Attributes inherited from AOperatingSystemDeviceActor
FOnDeviceCreated OnDeviceCreated
 
FOnOperatingSystemStarted OnOperatingSystemStarted
 

Detailed Description

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

Constructor & Destructor Documentation

◆ AOperatingSystemPortableDeviceActor()

AOperatingSystemPortableDeviceActor::AOperatingSystemPortableDeviceActor ( )

Member Function Documentation

◆ 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
Here is the call graph for this function:

◆ 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
Here is the caller graph for this function:

◆ GetOperatingSystemBatteryChargeEventName()

static FName AOperatingSystemPortableDeviceActor::GetOperatingSystemBatteryChargeEventName ( )
inlinestatic

Returns the name of the battery charge event.

Returns
The name of the battery charge event.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ IsCharging()

bool AOperatingSystemPortableDeviceActor::IsCharging ( ) const

Checks whether the portable device is currently charging its battery.

Returns
true if the device is charging, false otherwise.
Here is the caller graph for this function:

◆ 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
bIsChargingThe current charging state of the battery. If true, the battery is being charged; otherwise, the battery is not being charged.
See also
AOperatingSystemPortableDeviceActor

◆ OnLoadGame()

void AOperatingSystemPortableDeviceActor::OnLoadGame ( const FOperatingSystemDeviceSaveLoad & LoadData)
overrideprotectedvirtual

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
LoadDataThe 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
OutErrorThe 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.

Here is the call graph for this function:

◆ OnSaveGame()

void AOperatingSystemPortableDeviceActor::OnSaveGame ( FOperatingSystemDeviceSaveLoad & SaveData)
overrideprotectedvirtual

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
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
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
OutErrorThe output parameter that will contain any validation errors encountered during the validation.

Reimplemented from AOperatingSystemDeviceActor.

Here is the call graph for this function:

◆ SetBattery()

void AOperatingSystemPortableDeviceActor::SetBattery ( FOperatingSystemBattery NewBattery,
FGenericError & OutError )

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
Here is the call graph for this function:

◆ 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
Here is the call graph for this function:

Member Data Documentation

◆ BatteryConsumeDelay

float AOperatingSystemPortableDeviceActor::BatteryConsumeDelay
protected

Seconds taken to consume 1 battery level if not charging.

◆ BatteryLevel

int32 AOperatingSystemPortableDeviceActor::BatteryLevel
protected

Current battery level.

◆ 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

FOperatingSystemBattery AOperatingSystemPortableDeviceActor::CurrentBattery
protected

Current battery.

◆ 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: