C# Class Plugin.Plugin

Inheritance: OpenBveApi.Textures.TextureInterface
Show file Open project: leezer3/OpenBVE Class Usage Examples

Public Methods

Method Description
CanLoadSound ( string path ) : bool

Checks whether the plugin can load the specified sound.

CanLoadTexture ( string path ) : bool

Checks whether the plugin can load the specified texture.

DoorChange ( DoorStates oldState, DoorStates newState ) : void

Is called when the state of the doors changes.

Elapse ( ElapseData data ) : void

Is called every frame.

HornBlow ( HornTypes type ) : void

Is called when a horn is played or when the music horn is stopped.

Initialize ( InitializationModes mode ) : void

Is called when the plugin should initialize or reinitialize.

KeyDown ( VirtualKeys key ) : void

Is called when a virtual key is pressed.

KeyUp ( VirtualKeys key ) : void

Is called when a virtual key is released.

Load ( LoadProperties properties ) : bool

Is called when the plugin is loaded.

Load ( HostInterface host ) : void

Called when the plugin is loaded.

LoadSound ( string path, Sound &sound ) : bool

Loads the specified sound.

LoadTexture ( string path, Texture &texture ) : bool

Loads the specified texture.

PerformAI ( AIData data ) : void

Is called when the plugin should perform the AI.

QueryTextureDimensions ( string path, int &width, int &height ) : bool

Queries the dimensions of a texture.

SetBeacon ( BeaconData beacon ) : void

Is called when the train passes a beacon.

SetBrake ( int brakeNotch ) : void

Is called when the driver changes the brake notch.

SetPower ( int powerNotch ) : void

Is called when the driver changes the power notch.

SetReverser ( int reverser ) : void

Is called when the driver changes the reverser.

SetSignal ( SignalData signal ) : void

Is called when the aspect in the current or in any of the upcoming sections changes, or when passing section boundaries.

The signal array is guaranteed to have at least one element. When accessing elements other than index 0, you must check the bounds of the array first.

SetVehicleSpecs ( VehicleSpecs specs ) : void

Is called after loading to inform the plugin about the specifications of the train.

Unload ( ) : void

Is called when the plugin is unloaded.

Private Methods

Method Description
CanLoadFile ( string file ) : bool

Checks whether the specified file can be loaded as an ACE texture.

CanLoadUncompressedData ( byte data ) : bool

Checks whether the specified uncompressed data can be loaded as an ACE texture.

DecompressAce ( byte data ) : byte[]

Decompresses the specified zlib-compressed data.

GetColor ( ushort color ) : Color32

Gets a color from the specified integer.

GetInterpolatedColor11 ( Color32 a, Color32 b ) : Color32

Gets the color that is half-way between the two specified colors.

GetInterpolatedColor12 ( Color32 a, Color32 b ) : Color32

Gets the color that is one third the way between the two specified colors.

GetInterpolatedColor21 ( Color32 a, Color32 b ) : Color32

Gets the color that is two thirds the way between the two specified colors.

LoadFromFile ( string fileName ) : Sound

Reads wave data from a WAVE file.

LoadFromFile ( string file ) : Texture

Loads an ACE texture from the specified file.

LoadFromUncompressedData ( byte data ) : Texture

Loads an ACE texture from uncompressed data.

QueryDimensionsFromFile ( string file, int &width, int &height ) : void

Queries the texture dimensions of the specified file.

QueryDimensionsFromUncompressedData ( byte data, int &width, int &height ) : void

Queries the texture dimensions of the specified uncompressed data.

ReadUInt16 ( BinaryReader reader, Endianness endianness ) : ushort

Reads a System.UInt16 from a binary reader with the specified endianness.

ReadUInt32 ( BinaryReader reader, Endianness endianness ) : uint

Reads a System.UInt32 from a binary reader with the specified endianness.

Method Details

CanLoadSound() public method

Checks whether the plugin can load the specified sound.
public CanLoadSound ( string path ) : bool
path string The path to the file or folder that contains the sound.
return bool

CanLoadTexture() public method

Checks whether the plugin can load the specified texture.
public CanLoadTexture ( string path ) : bool
path string The path to the file or folder that contains the texture.
return bool

DoorChange() public method

Is called when the state of the doors changes.
public DoorChange ( DoorStates oldState, DoorStates newState ) : void
oldState DoorStates The old state of the doors.
newState DoorStates The new state of the doors.
return void

Elapse() public method

Is called every frame.
public Elapse ( ElapseData data ) : void
data ElapseData The data passed to the plugin.
return void

HornBlow() public method

Is called when a horn is played or when the music horn is stopped.
public HornBlow ( HornTypes type ) : void
type HornTypes The type of horn.
return void

Initialize() public method

Is called when the plugin should initialize or reinitialize.
public Initialize ( InitializationModes mode ) : void
mode InitializationModes The mode of initialization.
return void

KeyDown() public method

Is called when a virtual key is pressed.
public KeyDown ( VirtualKeys key ) : void
key VirtualKeys The virtual key that was pressed.
return void

KeyUp() public method

Is called when a virtual key is released.
public KeyUp ( VirtualKeys key ) : void
key VirtualKeys The virtual key that was released.
return void

Load() public method

Is called when the plugin is loaded.
public Load ( LoadProperties properties ) : bool
properties LoadProperties The properties supplied to the plugin on loading.
return bool

Load() public method

Called when the plugin is loaded.
public Load ( HostInterface host ) : void
host HostInterface The host that loaded the plugin.
return void

LoadSound() public method

Loads the specified sound.
public LoadSound ( string path, Sound &sound ) : bool
path string The path to the file or folder that contains the sound.
sound Sound Receives the sound.
return bool

LoadTexture() public method

Loads the specified texture.
public LoadTexture ( string path, Texture &texture ) : bool
path string The path to the file or folder that contains the texture.
texture Texture Receives the texture.
return bool

PerformAI() public method

Is called when the plugin should perform the AI.
public PerformAI ( AIData data ) : void
data AIData The AI data.
return void

QueryTextureDimensions() public method

Queries the dimensions of a texture.
public QueryTextureDimensions ( string path, int &width, int &height ) : bool
path string The path to the file or folder that contains the texture.
width int Receives the width of the texture.
height int Receives the height of the texture.
return bool

SetBeacon() public method

Is called when the train passes a beacon.
public SetBeacon ( BeaconData beacon ) : void
beacon BeaconData The beacon data.
return void

SetBrake() public method

Is called when the driver changes the brake notch.
public SetBrake ( int brakeNotch ) : void
brakeNotch int The new brake notch.
return void

SetPower() public method

Is called when the driver changes the power notch.
public SetPower ( int powerNotch ) : void
powerNotch int The new power notch.
return void

SetReverser() public method

Is called when the driver changes the reverser.
public SetReverser ( int reverser ) : void
reverser int The new reverser position.
return void

SetSignal() public method

Is called when the aspect in the current or in any of the upcoming sections changes, or when passing section boundaries.
The signal array is guaranteed to have at least one element. When accessing elements other than index 0, you must check the bounds of the array first.
public SetSignal ( SignalData signal ) : void
signal SignalData
return void

SetVehicleSpecs() public method

Is called after loading to inform the plugin about the specifications of the train.
public SetVehicleSpecs ( VehicleSpecs specs ) : void
specs VehicleSpecs The specifications of the train.
return void

Unload() public method

Is called when the plugin is unloaded.
public Unload ( ) : void
return void