4. SodaSim Base API

4.1. Runtime Editor

SodaSim contains some of the functionality of the Unreal Engine Editor with minor changes. It is copied source code of some Unreal Engine Editor modules, and adapted to work in Game mode and a packaged game. It is located in the SodaSim/Source/RuntimeEditor folder.

The following UnrealEngine modules have been imported (renamed to SodaSim):

  • ClassViewer → RuntimeClassViewer

  • Documentation → RuntimeDocumentation

  • PropertyEditor → RuntimePropertyEditor

  • DetailCustomizations → RuntimeDetailCustomizations

4.2. Runtime Metadata

SodaSim supports working with Metadata Specifiers in a packaged game. Metadata for all classes and structures is saved in UMetadataPrimaryAsset during cooking of an uproject and becomes available in the packaged game. To access metadata of any class, structure, function or method, use the corresponding methods in FRuntimeMetaData.

For example:

FRuntimeMetaData::GetMetaData(Class, TEXT("DisplayName"));
const FString& MinString = FRuntimeMetaData::GetMetaData(Property, TEXT("ClampMin"));
FRuntimeMetaData::HasMetaData(Property, TEXT("Enum")
FRuntimeMetaData::GetBoolMetaData(Function, MD_CallInEditor)

4.3. Additional Metadata Specifires

  • EditInRuntime - specifier for UPROPERTY. Parameters marked in this way will be available in Soda Editor Mode for the selected Actor and Vehicle Component.

  • ReactivateActor - specifier for UPROPERTY. Typically used for components inherited from ISodaVehicleComponent. Means that if this parameter is changed, the ASodaVehicle::ReActivateVehicleComponents() method must be called.

  • ReactivateComponent - specifier for UPROPERTY. Typically used for components inherited from ISodaVehicleComponent. Indicates that if this parameter is changed, this component must be reactivated.

  • CallInRuntime - specifier for UFUNCTION. Adds a button to RuntimePropertyEditor that calls this function. Works similar to the CallInEditor specifier, but in game mode. Only functions of type void MyFunc() availably.

  • RuntimeMetaData - specifier for UCLASS and USTRUCT. For a class or structure marked in this way, its metadata will be saved.

4.4. Base Classes

4.4.1. IEditableObject

IEditableObject - this is the base interface from which all UObjects in SodaSim are inherited.

Purpose:

  • Allows you to “return” the following methods, available only in UE editor mode, to any base class inherited from UObject:

  • Has a version of PostEditChangeProperty() available in Blueprint.

  • Allows you to add metadata for a class to Blueprint by overriding the GenerateMetadata() method.

4.4.2. SodaApp (FSodaApp)

Global unique class (singalton), provides the basic functionality of the SodaSim plugin, independent of the loaded level.

4.4.3. Soda Actor (ISodaActor)

The interface assumes that the base class is inherited from any descendant of AActor.

Purpose:

  • Interact with Actors in the Soda Editor Mode

  • BeginScenario() and EndScenario() methods, which should define the behavior of the Actor at the time the script starts and stops.

  • Defines the “Pinned Actor” logic:

    • UnPinned - means that the Actor’s state (its SaveData) is in one shared record (a file on disk or a record in the database) along with the entire level. Thus, the saved state of an Actor is only available for one save. This behavior is convenient for Actors, which are necessarily associated with a specific level and its state. For example, ANavigationRoute, the user creates a motion trajectory for a specific level, taking into account the geometry of the level and the Actors around it.

    • Pinned - means that the Actor’s state (its SaveData) is located in a separate unique record (file or database) and is available for any level. This means that changes made to an Actor at one level will also appear when this Actor is loaded at other levels. This is a convenient behavior, for example for ASodaVehicle, when creating a vehicle configuration (a set of sensors and components); we may want to use this configuration not only at one level, but also at all others.

  • For ISodaActor, a menu is automatically generated in the UI in Soda Editor Mode, when Actor is selected:

  • ISodaActor becomes available for placement on the stage through the UI if it is registered in one of the USodaLibraryPrimaryAsset.

See Create Blueprint Soda Actor

4.4.4. Actors Librery (USodaLibraryPrimaryAsset)

To make your Soda Actors accessible for addition to a scene in Soda Editor, place them in the USodaLibraryPrimaryAsset library (a subclass of UPrimaryDataAsset). Feel free to utilize an existing library or create a new one.

Organizing Soda Actors into USodaLibraryPrimaryAsset libraries primarily facilitates the seamless transfer of actors between projects. It’s advisable to establish the following actor libraries for optimal organization:

  1. One USodaLibraryPrimaryAsset library for all Soda Actors in the particular plugin - if you don’t need to share a part of it with other plugins;

  2. One USodaLibraryPrimaryAsset library for each subfolder of /Content folder of Unreal Engine project, that allows you to share this content between projects;

  3. One USodaLibraryPrimaryAsset library for all Soda Actors in /Content folder of Unreal Engine project, which won’t be shared between projects.

USodaLibraryPrimaryAsset at the time of cooking checks all C++ classes for the presence of one of the “additional Metada Specifires”. If such are found, then all metadata for this class or structure will be saved.

4.4.5. Game Mode (USodaGameModeComponent)

USodaGameModeComponent implements functionality that should be implemented in Game Mode. For compatibility with Game Mode overridden in possible other projects, all functionality that AGameModeBase implies is placed in a separate component USodaGameModeComponent, which must be added to any class inherited from AGameModeBase

See Setup a New UProject

4.4.6. Level State (ALevelState)

This class is required and unique to any Level. If there is no ALevelState among the default Actors in Level, it will be created automatically before BeginPlay().

This class is primarily responsible for serializing/deserializing the Level with all its Actors, and then saving and loading it.

4.4.7. USodaGameViewportClient

This class is responsible for the user interface.

Must be set in Project Settings as Default Game Viewport Client Class.

4.4.8. ASodaVehicle

See Soda Vehicle API

4.4.9. Actor Factory (ASodaActorFactory)

An auxiliary class for ALevelState, stores a list of all ISodaActor on the stage, controls their creation, destruction, as well as their serialization and deserialization for saving and loading them from disk or database.

4.5. Soda Vehicle API