Skip to content

AOperatingSystemDeviceActor

#include <OperatingSystemSimulator/Public/Devices/OperatingSystemDeviceActor.h>
class AOperatingSystemDeviceActor

Defined in OperatingSystemDeviceActor.h:33

Inherits: AActor Subclassed by: AOperatingSystemPortableDeviceActor

---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class AOperatingSystemDeviceActor["AOperatingSystemDeviceActor"]
  class AActor["AActor"]
  AActor <|-- AOperatingSystemDeviceActor
  class AOperatingSystemPortableDeviceActor["AOperatingSystemPortableDeviceActor"]
  AOperatingSystemDeviceActor <|-- AOperatingSystemPortableDeviceActor
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class AOperatingSystemDeviceActor["AOperatingSystemDeviceActor"]
  class UOperatingSystemBaseDevice["UOperatingSystemBaseDevice"]
  AOperatingSystemDeviceActor *-- UOperatingSystemBaseDevice
  class UOperatingSystemSaveGame["UOperatingSystemSaveGame"]
  AOperatingSystemDeviceActor *-- UOperatingSystemSaveGame
  class UOperatingSystemDeviceMessenger["UOperatingSystemDeviceMessenger"]
  AOperatingSystemDeviceActor *-- UOperatingSystemDeviceMessenger
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class AOperatingSystemDeviceActor {
    +OnDeviceCreated : FOperatingSystemSimpleDelegate
    +OnOperatingSystemStarted : FOperatingSystemSimpleDelegate
    +OnValidate(FGenericError &OutError)
    +CreateDevice(FGenericError &OutError)
    +CurrentDeviceDestroyed()
    +RestartDevice()
    +WidgetChanged(UUserWidget *ChangedWidget)
    +OnShowBlueScreen(const float &OnScreenTime)
    +StopMediaAudio() const
    +GetHardwareByTag(const FGameplayTag &TestTag) const UOperatingSystemBaseHardware() *
    +SetAddWidgetsToScreen(const EOperatingSystemWidgetSet Method)
    +ClearWidgetFromScreen() const
    +RefreshWidget() const
    +IsPortableDevice() const bool
    +BeginDestroyMessenger()
    +FinishDestroyMessenger()
    +BeginOperatingSystemSessionEnd(const bool bRestart)
    +FinishOperatingSystemSessionEnd(const bool bRestart)
    +OnSaveGame(FOperatingSystemDeviceSaveLoad &SaveData)
    +OnLoadGame(const FOperatingSystemDeviceSaveLoad &LoadD
    +MainComponent : TObjectPtr< USceneComponent >
    +MediaSoundComponent : TObjectPtr< UMediaSoundComponent >
    +DeviceTag : FGameplayTag
    +DeviceClass : TSoftClassPtr< UOperatingSystemBaseDevic
    +bCreateDeviceOnBeginPlay : uint8
    +bAddWidgetsToScreen : uint8
    +bExitWhenDeviceIsDestroyed : uint8
    +bCanSaveGame : uint8
    +SaveGameClass : TSoftClassPtr< UOperatingSystemSaveGame(
    +MessengerClass : TSoftClassPtr< UOperatingSystemDeviceMes
    +LoadGameInstance : TObjectPtr< UOperatingSystemSaveGame() >
    +PlayerController : TWeakObjectPtr< APlayerController >
    +OnNewDeviceCreated(FGenericError &OutError)
    +OnBeginOperatingSystemSessionEnd(const bool bIsRestarting)
    +OnFinishOperatingSystemSessionEnd(const bool bWasRestart)
    +IsPortableDeviceImpl() const bool
    +K2_CreateDevice(FGenericError &OutError) bool
    +K2_OnCurrentDeviceDestroyed()
    +K2_OnWidgetChanged(UUserWidget *ChangedWidget)
    +K2_OnBlueScreenShow(const float &OnScreenTime)
    +K2_OnBeginOperatingSystemShutdown()
    +K2_OnFinishOperatingSystemShutdown()
    +K2_OnBeginOperatingSystemRestart()
    +K2_OnFinishOperatingSystemRestart()
    +DeviceMessenger : TObjectPtr< UOperatingSystemDeviceMessen
    +CurrentDevice : TObjectPtr< UOperatingSystemBaseDevice()
    +UniqueID : FGuid
    +Internal_OnValidate(FGenericError &OutError)
    +Internal_CreateDeviceManager()
  }

An operating system device actor that user can place in world.

ReturnNameDescription
FOperatingSystemSimpleDelegateOnDeviceCreatedEvent raised when a new device is created.
FOperatingSystemSimpleDelegateOnOperatingSystemStartedAn event that is raised when Operating System starts in this device.

FOperatingSystemSimpleDelegate OnDeviceCreated

Defined in OperatingSystemDeviceActor.h:127 Event raised when a new device is created.

This event is dispatched when a new device is created and associated with the operating system device actor. Subscribers can listen to this event to perform any necessary actions when a new device is created.

Example usage:

void OnNewDeviceCreated()
{
// Perform actions when a new device is created
}
// Subscribe to the OnDeviceCreated event
MyOperatingSystemDeviceActorInstance->OnDeviceCreated.AddDynamic(this, &AActorClass::OnNewDeviceCreated);

FOperatingSystemSimpleDelegate OnOperatingSystemStarted

Defined in OperatingSystemDeviceActor.h:131 An event that is raised when Operating System starts in this device.

ReturnNameDescription
voidOnValidate virtual inlineThis method is called to validate the object’s state.
voidCreateDeviceCreates a new device.
voidCurrentDeviceDestroyedMethod to handle the destruction of the current device.
voidRestartDeviceRestarts the device.
voidWidgetChangedHandles the event when a widget is changed.
voidOnShowBlueScreenCalled when the blue screen should be shown on the operating system device.
voidStopMediaAudio constStops the media audio playback.
UOperatingSystemBaseHardware *GetHardwareByTag constRetrieves the hardware by the specified tag.
voidSetAddWidgetsToScreenSets the method for adding widgets to the screen.
voidClearWidgetFromScreen constClears the widget from the screen.
voidRefreshWidget constChecks if the current device is valid and then calls the ReApplyWidget() method on the current device.
boolIsPortableDevice const inlineDetermines whether the operating system device actor is a portable device.
voidBeginDestroyMessengerBegins the destruction process for the messenger associated with the operating system device actor.
voidFinishDestroyMessengerA method to finish the destruction of the operating system device actor.
voidBeginOperatingSystemSessionEnd
voidFinishOperatingSystemSessionEnd
voidOnSaveGame virtual inlineSaves the state of the operating system device in the provided save data.
voidOnLoadGame virtual inlineCallback method called when loading a game.

virtual inline

virtual inline void OnValidate(FGenericError & OutError)

Defined in OperatingSystemDeviceActor.h:156 This method is called to validate the object’s state.

This method should be implemented by derived classes to validate the state of the object. If any errors are found during the validation, they should be added to the provided OutError parameter.

  • OutError A reference to a FGenericError object, which is used to store any errors found during validation.

void CreateDevice(FGenericError & OutError)

Defined in OperatingSystemDeviceActor.h:185 Creates a new device.

This method creates a new device based on the specified class and instance. If the ‘CurrentDevice’ member variable is already set, an error will be returned and no device will be created. The ‘DeviceClass’ argument should not be null, otherwise an error will be returned. The ‘DeviceTag’ argument should have a valid tag, otherwise an error will be returned.

If the device creation is successful, the ‘CurrentDevice’ member variable will be set to the created device.

  • OutError A reference to a FGenericError object that will hold any error information if an error occurs during device creation.

void CurrentDeviceDestroyed()

Defined in OperatingSystemDeviceActor.h:197 Method to handle the destruction of the current device.

This method is called when the current device is being destroyed. It performs various cleanup operations and handles any necessary actions. If the current device is valid, it checks if there is a blueprint assigned to the “CurrentDeviceDestroyed” event and calls it if available. It then unbinds the “OnOperatingSystemStartedDelegate” event from the current device, marks it as garbage, and sets the current device to nullptr.

If the “bExitWhenDeviceIsDestroyed” flag is set to true, the method executes additional actions. In the editor mode, it retrieves the player controller and executes the “exit” console command, which will exit the game. Otherwise, it requests the exit of the application.


void RestartDevice()

Defined in OperatingSystemDeviceActor.h:213 Restarts the device.

This method restarts the operating system device. If the device has a blueprint on it that is destroyed, this method triggers the K2_OnCurrentDeviceDestroyed event.

If there is a current device, this method unbinds the OnOperatingSystemStartedDelegate and marks the current device as garbage. It then sets the CurrentDevice pointer to nullptr.

After that, it creates a timer delegate for the CreateDevice function and binds it to this actor. The delegate is then set to be executed after 1 second.


void WidgetChanged(UUserWidget * ChangedWidget)

Defined in OperatingSystemDeviceActor.h:222 Handles the event when a widget is changed.

This method is called when a user widget is changed in the operating system device actor.

  • ChangedWidget The pointer to the user widget that has been changed.

void OnShowBlueScreen(const float & OnScreenTime)

Defined in OperatingSystemDeviceActor.h:233 Called when the blue screen should be shown on the operating system device.

  • OnScreenTime The time in seconds the blue screen should be shown on the screen.

See also: K2_OnBlueScreenShow


const

void StopMediaAudio() const

Defined in OperatingSystemDeviceActor.h:244 Stops the media audio playback.

This method stops the media audio playback by calling the Stop() function of the MediaSoundComponent.

See also: MediaSoundComponent


const

UOperatingSystemBaseHardware * GetHardwareByTag(const FGameplayTag & TestTag) const

Defined in OperatingSystemDeviceActor.h:252 Retrieves the hardware by the specified tag.

  • TestTag The gameplay tag used for filtering hardware.

The instance of UOperatingSystemBaseHardware that matches the specified tag.


void SetAddWidgetsToScreen(const EOperatingSystemWidgetSet Method)

Defined in OperatingSystemDeviceActor.h:261 Sets the method for adding widgets to the screen.

Depending on the specified method, widgets may be added to the screen or not.

  • Method The method for adding widgets to the screen.

const

void ClearWidgetFromScreen() const

Defined in OperatingSystemDeviceActor.h:270 Clears the widget from the screen.

This method clears the currently displayed widget from the screen. It checks if the current device is valid. If valid, it calls the “ClearOnScreenWidget()” method of the current device to clear the widget from the screen.


const

void RefreshWidget() const

Defined in OperatingSystemDeviceActor.h:276 Checks if the current device is valid and then calls the ReApplyWidget() method on the current device.


const inline

inline bool IsPortableDevice() const

Defined in OperatingSystemDeviceActor.h:284 Determines whether the operating system device actor is a portable device.

True if the operating system device actor is a portable device, false otherwise.


void BeginDestroyMessenger()

Defined in OperatingSystemDeviceActor.h:296 Begins the destruction process for the messenger associated with the operating system device actor.

This method is responsible for initiating the destruction process for the messenger. It calls the BeginDestroyMessenger method of the DeviceMessenger associated with the operating system device actor.

See also: DeviceMessenger, AOperatingSystemDeviceActor


void FinishDestroyMessenger()

Defined in OperatingSystemDeviceActor.h:312 A method to finish the destruction of the operating system device actor.

This method marks the device messenger as garbage and sets it to nullptr.

  • The device messenger must be initialized and assigned.
  • The device messenger will be marked as garbage.

  • The device messenger will be set to nullptr.


void BeginOperatingSystemSessionEnd(const bool bRestart)

Defined in OperatingSystemDeviceActor.h:314


void FinishOperatingSystemSessionEnd(const bool bRestart)

Defined in OperatingSystemDeviceActor.h:315


virtual inline

virtual inline void OnSaveGame(FOperatingSystemDeviceSaveLoad & SaveData)

Defined in OperatingSystemDeviceActor.h:324 Saves the state of the operating system device in the provided save data.

  • SaveData The reference to the save data object where the state will be saved.

virtual inline

virtual inline void OnLoadGame(const FOperatingSystemDeviceSaveLoad & LoadData)

Defined in OperatingSystemDeviceActor.h:337 Callback method called when loading a game.

This method is called when a game is being loaded. It is a virtual method that can be overridden by derived classes to provide custom logic for loading a game.

  • LoadData The save/load data for the operating system device.

See also: FOperatingSystemDeviceSaveLoad

ReturnNameDescription
TObjectPtr< USceneComponent >MainComponent
TObjectPtr< UMediaSoundComponent >MediaSoundComponent
FGameplayTagDeviceTagA unique tag to identify this device.
TSoftClassPtr< UOperatingSystemBaseDevice >DeviceClassTarget device class to create.
uint8bCreateDeviceOnBeginPlayIf true, create the device on begin play. If false, you can manually call Create Device whenever you need.
uint8bAddWidgetsToScreenIf true, add widgets directly to viewport screen.
uint8bExitWhenDeviceIsDestroyedSet to exit game when the device is destroyed. Device is destroyed when the OS shuts down.
uint8bCanSaveGameDetermines if this device support save game.
TSoftClassPtr< UOperatingSystemSaveGame >SaveGameClassTarget save game class.
TSoftClassPtr< UOperatingSystemDeviceMessenger >MessengerClassTarget messenger class.
TObjectPtr< UOperatingSystemSaveGame >LoadGameInstance
TWeakObjectPtr< APlayerController >PlayerController

TObjectPtr< USceneComponent > MainComponent

Defined in OperatingSystemDeviceActor.h:40

Section titled “Defined in OperatingSystemDeviceActor.h:40”
TObjectPtr< UMediaSoundComponent > MediaSoundComponent

Defined in OperatingSystemDeviceActor.h:43


FGameplayTag DeviceTag

Defined in OperatingSystemDeviceActor.h:47 A unique tag to identify this device.


TSoftClassPtr< UOperatingSystemBaseDevice > DeviceClass

Defined in OperatingSystemDeviceActor.h:51 Target device class to create.


uint8 bCreateDeviceOnBeginPlay

Defined in OperatingSystemDeviceActor.h:55 If true, create the device on begin play. If false, you can manually call Create Device whenever you need.


uint8 bAddWidgetsToScreen

Defined in OperatingSystemDeviceActor.h:59 If true, add widgets directly to viewport screen.


uint8 bExitWhenDeviceIsDestroyed

Defined in OperatingSystemDeviceActor.h:63 Set to exit game when the device is destroyed. Device is destroyed when the OS shuts down.


uint8 bCanSaveGame

Defined in OperatingSystemDeviceActor.h:67 Determines if this device support save game.


TSoftClassPtr< UOperatingSystemSaveGame > SaveGameClass

Defined in OperatingSystemDeviceActor.h:71 Target save game class.


TSoftClassPtr< UOperatingSystemDeviceMessenger > MessengerClass

Defined in OperatingSystemDeviceActor.h:75 Target messenger class.


TObjectPtr< UOperatingSystemSaveGame > LoadGameInstance

Defined in OperatingSystemDeviceActor.h:78


TWeakObjectPtr< APlayerController > PlayerController

Defined in OperatingSystemDeviceActor.h:81

ReturnNameDescription
voidOnNewDeviceCreated virtual inlineThis method is called when a new device has been created. This method is intended to be overridden in subclasses of OperatingSystemDeviceActor to handle the event of a new device being created. It provides a way for the subclass to perform any necessary actions or processing related to the new device.
voidOnBeginOperatingSystemSessionEnd virtual inlineCalled when the operating system session is about to end.
voidOnFinishOperatingSystemSessionEnd virtual inlineCalled when the operating system session has ended.
boolIsPortableDeviceImpl virtual const inlineDetermines if the device is portable or not. By default, the method returns false.
boolK2_CreateDeviceCreates a device in the operating system.
voidK2_OnCurrentDeviceDestroyedNotifies the actor that the current device has been destroyed.
voidK2_OnWidgetChangedNotifies the actor when the widget has changed.
voidK2_OnBlueScreenShowEvent that is triggered when the blue screen is shown on the operating system device actor.
voidK2_OnBeginOperatingSystemShutdownEvent that is triggered when the operating system begins the shutdown process. This event is called before closing running applications.
voidK2_OnFinishOperatingSystemShutdownEvent that is triggered when the operating system finishes the shutdown process.
voidK2_OnBeginOperatingSystemRestartEvent that is triggered when the operating system begins the restart process.
voidK2_OnFinishOperatingSystemRestartEvent that is triggered when the operating system finishes the restart process.

virtual inline

virtual inline void OnNewDeviceCreated(FGenericError & OutError)

Defined in OperatingSystemDeviceActor.h:368 This method is called when a new device has been created. This method is intended to be overridden in subclasses of OperatingSystemDeviceActor to handle the event of a new device being created. It provides a way for the subclass to perform any necessary actions or processing related to the new device.

  • OutError A reference to a FGenericError object that can be used to return error messages if necessary.

virtual inline

virtual inline void OnBeginOperatingSystemSessionEnd(const bool bIsRestarting)

Defined in OperatingSystemDeviceActor.h:378 Called when the operating system session is about to end.

This method is called when the operating system session is about to end. It provides an opportunity for derived classes to perform any necessary actions before the session ends.

  • bIsRestarting A boolean indicating whether the session is ending due to a restart (true) or a shutdown (false).

virtual inline

virtual inline void OnFinishOperatingSystemSessionEnd(const bool bWasRestart)

Defined in OperatingSystemDeviceActor.h:388 Called when the operating system session has ended.

This method is called when the operating system session has ended. It provides an opportunity for derived classes to perform any necessary actions after the session ends.

  • bWasRestart A boolean indicating whether the session ended due to a restart (true) or a shutdown (false).

virtual const inline

virtual inline bool IsPortableDeviceImpl() const

Defined in OperatingSystemDeviceActor.h:395 Determines if the device is portable or not. By default, the method returns false.

True if the device is portable, false otherwise.


bool K2_CreateDevice(FGenericError & OutError)

Defined in OperatingSystemDeviceActor.h:406 Creates a device in the operating system.

  • OutError A reference to a FGenericError object that will hold any error encountered during device creation.

True if the device creation was successful, false otherwise.


void K2_OnCurrentDeviceDestroyed()

Defined in OperatingSystemDeviceActor.h:416 Notifies the actor that the current device has been destroyed.

This event is blueprint implementable, allowing the user to define their own behavior when the current device is destroyed.


void K2_OnWidgetChanged(UUserWidget * ChangedWidget)

Defined in OperatingSystemDeviceActor.h:428 Notifies the actor when the widget has changed.

This event is called when the user widget associated with the operating system device actor has been changed.

  • ChangedWidget The new user widget that has been assigned to the operating system device actor. This parameter can be nullptr if the widget is being cleared. The ownership of the widget remains with the caller and it’s the caller responsibility to properly manage the widget’s lifetime.

void K2_OnBlueScreenShow(const float & OnScreenTime)

Defined in OperatingSystemDeviceActor.h:440 Event that is triggered when the blue screen is shown on the operating system device actor.

  • OnScreenTime The amount of time the blue screen will be displayed on the screen.

void K2_OnBeginOperatingSystemShutdown()

Defined in OperatingSystemDeviceActor.h:446 Event that is triggered when the operating system begins the shutdown process. This event is called before closing running applications.


void K2_OnFinishOperatingSystemShutdown()

Defined in OperatingSystemDeviceActor.h:450 Event that is triggered when the operating system finishes the shutdown process.


void K2_OnBeginOperatingSystemRestart()

Defined in OperatingSystemDeviceActor.h:454 Event that is triggered when the operating system begins the restart process.


void K2_OnFinishOperatingSystemRestart()

Defined in OperatingSystemDeviceActor.h:458 Event that is triggered when the operating system finishes the restart process.

ReturnNameDescription
TObjectPtr< UOperatingSystemDeviceMessenger >DeviceMessengerMessenger object that communicates with anything within this device.
TObjectPtr< UOperatingSystemBaseDevice >CurrentDeviceDevice that is spawned and currently associated with this actor.
FGuidUniqueIDAn auto generated unique ID associated with this device. Primarily used for save games.

TObjectPtr< UOperatingSystemDeviceMessenger > DeviceMessenger

Defined in OperatingSystemDeviceActor.h:87 Messenger object that communicates with anything within this device.


TObjectPtr< UOperatingSystemBaseDevice > CurrentDevice

Defined in OperatingSystemDeviceActor.h:91 Device that is spawned and currently associated with this actor.


FGuid UniqueID

Defined in OperatingSystemDeviceActor.h:95 An auto generated unique ID associated with this device. Primarily used for save games.

ReturnNameDescription
voidInternal_OnValidateValidates the operating system device actor.
voidInternal_CreateDeviceManagerInternal method to create the device manager for the operating system device actor.

void Internal_OnValidate(FGenericError & OutError)

Defined in OperatingSystemDeviceActor.h:168 Validates the operating system device actor.

This method is called to validate the operating system device actor. It checks if the device tag is valid and if the device class is not null If any validation fails, an error message is assigned to the OutError parameter.

  • OutError [out] The error message assigned if validation fails.

void Internal_CreateDeviceManager()

Defined in OperatingSystemDeviceActor.h:354 Internal method to create the device manager for the operating system device actor.

This method is called internally to create the device manager for the operating system device actor. The device manager is responsible for managing the devices associated with the actor.

See also: DeviceMessenger

See also: UOperatingSystemDeviceMessenger

See also: CreateMessenger

See also: IsValid