Class Vehicle
An instance of this class represents an object that can be, or is, part of a Map.
public class Vehicle : MapObject, IGenericDataHolder, IUpdatingObject
- Inheritance
-
JsonTypeSafeGenericDataHolderVehicle
- Implements
-
IGenericDataHolder
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
Vehicle(Guid, Map, Vector2, float, VehicleType)
public Vehicle(Guid id, Map map, Vector2 position, float floor, Vehicle.VehicleType type)
Parameters
id
Guidmap
Mapposition
Vector2floor
floattype
Vehicle.VehicleType
Fields
Action
The id of the drive action.
[DataMember]
public Guid Action
Field Value
Driver
The id of the person driving the car
[DataMember]
public Guid Driver
Field Value
Rotation
The rotation that this car has
[DataMember]
public Direction2 Rotation
Field Value
- Direction2
Type
The type that this vehicle has
[DataMember]
public Vehicle.VehicleType Type
Field Value
Methods
Draw(GameTime, object, Vector2, Color?, List<Item>)
Draws this object on the current Map, at the current Position. To draw a map object while invoking all the required events, use DoDraw(GameTime, object, Color?, bool, List<Item>).
public override void Draw(GameTime time, object batch, Vector2 drawPos, Color? overrideColor, List<StaticSpriteBatch.Item> items)
Parameters
time
GameTimeThe current time
batch
objectThe sprite batch to use for drawing, which is either a Microsoft.Xna.Framework.Graphics.SpriteBatch or MLEM.Graphics.StaticSpriteBatch.
drawPos
Vector2The position, in draw space, to draw this furniture at
overrideColor
Color?The color that should be used instead of this object's actual color. If null, the object's regular color should be used.
items
List<StaticSpriteBatch.Item>A list of sprite batch items that items should be added to if the
batch
is a MLEM.Graphics.StaticSpriteBatch.
GetDebugLines(GameImpl, List<string>)
Returns the debug lines that should be displayed in Debug when hovering over this object. By default, OnGetDebugLines is invoked, and the id and position of this object are appended to the list of lines.
public override void GetDebugLines(GameImpl game, List<string> lines)
Parameters
GetHoverInfo(Tooltip)
Allows adding a set of paragraphs and other ui elements to the given tooltip
, which is then displayed when this object is hovered over using the cursor in the world.
By default, this method raises OnGetHoverInfo for MapObject, and adds additional information for Furniture and PersonLike.
public override void GetHoverInfo(Tooltip tooltip)
Parameters
tooltip
TooltipThe tooltip that will be displayed.
GetSpeed()
Returns the speed that this vehicle has
public virtual float GetSpeed()
Returns
- float
This vehicle's speed
OnCameraRotationChanged(Direction2, Direction2)
This method is invoked when the game's camera rotation changes. Additionally, the old and new rotations are passed.
public override void OnCameraRotationChanged(Direction2 oldRotation, Direction2 newRotation)
Parameters
oldRotation
Direction2The old camera rotation
newRotation
Direction2The new camera rotation
OnRemoved()
This method is called when this object is removed from a Map. By default, it does nothing.
public override void OnRemoved()
ResetToStatic(bool, bool)
Resets this map object to a static state when the Map that is on is exported.
public override bool ResetToStatic(bool thorough, bool custom)
Parameters
thorough
boolWhether a more thorough reset is expected, which usually involves normalizing additional data and cleaning up player data entirely.
custom
boolWhether the static reset is happening in a custom context, that is, a Household being exported normally rather than through cheats, or a custom Map being exported.
Returns
- bool
Whether this object should stay on the map after the static reset. If false is returned, this object is removed.
Update(GameTime, TimeSpan, float)
The update method, which is called every update frame by the underlying Map, as well as additional places like the FurnitureStorage. Because of this, some actions might only want to be invoked if an object IsInWorld. To call this method while invoking all required events, use DoUpdate(GameTime, TimeSpan, float).
public virtual void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)