DeskSim v2 0.1
Train simulator prototype created for Lokførerskolen
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ABasicSignal Class Reference

Basic signal class, contains functionality to setup and use signal lights. More...

#include <BasicSignal.h>

Inheritance diagram for ABasicSignal:
IIsSaveableInterface

Public Member Functions

virtual void Tick (float DeltaTime) override
 
void SetupLight ()
 Sets the light meshes and dynamic materials for the signals. More...
 
void SetLightOnOff (int32 InLightIndex, bool bInLightOn)
 Sets the light at index to be on or off. More...
 
void ToggleLight (int32 InLightIndex)
 Toggles one of the lights on or off. More...
 
void SetLightColor (int32 InLightIndex, FLinearColor InColor)
 Sets the color of the light at InLightIndex. More...
 
void StartLightBlink (int32 InLightIndex, float InSeconds)
 Sets a light to blink at the specified frequency. More...
 
void StopLightBlink (int32 InLightIndex)
 Stops a light from blinking. More...
 
void UpdateSignalStatus (ESignalStatus NewSignalStatus)
 Function needs to be implemented in blueprints.
 

Public Attributes

FName ID
 
ESignalType Type
 
ESignalStatus SignalStatus
 
UStaticMeshComponent * VisualComponent
 The visual component for the 3D model.
 
UStaticMesh * BaseLightMesh
 Base mesh for the lights.
 
UMaterialInterface * BaseLightMaterial
 Base material for the dynamic lights.
 
int32 NumLights = 2
 The number of lights to generate.
 
float MaxLightLevel = 10.0f
 The max emissive light level.
 
float LightBlinkPeriod = 2.0f
 The period of blinking lights.
 
bool bSnapToNearestRailway
 If true, the signal will snap to the nearest railway.
 
float OffsetFromRailway = 400.0f
 The sideways distance to add from the railway in centimeters.
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void EndPlay (EEndPlayReason::Type EndPlayReason) override
 
void RemoveLights ()
 Unregisters and removes the light components.
 
USplineComponent * GetNearestRailwaySplineComponent ()
 Locates the USplineComponent object nearest the location of a given vector in world space. More...
 
void SnapToNearestRailway ()
 Snaps this object to the nearest railway, if any.
 

Protected Attributes

TArray< FSignalLightLights
 Array of light components.
 

Detailed Description

Basic signal class, contains functionality to setup and use signal lights.

Needs to be extended into a blueprint class in order to be used. Switching light statuses depends on the type of signal, and each signal uses a custom amount of lights. The model should also be applied in the blueprint.

Member Function Documentation

◆ GetNearestRailwaySplineComponent()

USplineComponent * ABasicSignal::GetNearestRailwaySplineComponent ( )
protected

Locates the USplineComponent object nearest the location of a given vector in world space.

Returns
Returns a pointer to the relevant USplineComponent if any

◆ SetLightColor()

void ABasicSignal::SetLightColor ( int32  InLightIndex,
FLinearColor  InColor 
)

Sets the color of the light at InLightIndex.

Parameters
InLightIndex- The index of the light, 0 indexed
InColor- The color of the light

◆ SetLightOnOff()

void ABasicSignal::SetLightOnOff ( int32  InLightIndex,
bool  bInLightOn 
)

Sets the light at index to be on or off.

Parameters
InLightIndex- Index of the light, 0 indexed
bLightOn- True for On, False for Off

◆ SetupLight()

void ABasicSignal::SetupLight ( )

Sets the light meshes and dynamic materials for the signals.

Does this dynamically with sockets, allows for custom amounts of lights. Clears the previous lights to prevent duplicates

See also
RemoveLights

◆ StartLightBlink()

void ABasicSignal::StartLightBlink ( int32  InLightIndex,
float  InSeconds 
)

Sets a light to blink at the specified frequency.

Parameters
InLightIndex- Index of the light, 0 indexed
InSeconds- Seconds between on and off states

◆ StopLightBlink()

void ABasicSignal::StopLightBlink ( int32  InLightIndex)

Stops a light from blinking.

Parameters
InLightIndex- Index of the light, 0 indexed

◆ ToggleLight()

void ABasicSignal::ToggleLight ( int32  InLightIndex)

Toggles one of the lights on or off.

Parameters
InLightIndex- Index of the light to toggle, 0 indexed

The documentation for this class was generated from the following files: