Particle - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Objects

Particle Class

A particle is a MLEM.Animations.SpriteAnimation that can be moved and displayed in world space.
A particle is simply a MapObject that does not collide or interact directly with the world, but has all of the same properties.
A new particle can be added for display using Spawn(Particle).

public class Particle

Inheritance System.Object 🡒 Particle

Constructors

Particle.Particle(SpriteAnimation, TimeSpan, Vector2) Constructor

Creates a new particle with the given settings

public Particle(MLEM.Animations.SpriteAnimation animation, System.TimeSpan timeToLive, Microsoft.Xna.Framework.Vector2 position);

Parameters

animation MLEM.Animations.SpriteAnimation
The animation that this particle should display with

timeToLive System.TimeSpan
The amount of real time that this particle should stay alive for

position Microsoft.Xna.Framework.Vector2
The position that this particle should have, in world space

Particle.Particle(TextureRegion, TimeSpan, Vector2) Constructor

Creates a new particle with the given settings

public Particle(MLEM.Textures.TextureRegion region, System.TimeSpan timeToLive, Microsoft.Xna.Framework.Vector2 position);

Parameters

region MLEM.Textures.TextureRegion
The texture that this particle should display with

timeToLive System.TimeSpan
The amount of real time that this particle should stay alive for

position Microsoft.Xna.Framework.Vector2
The position that this particle should have, in world space

Fields

Particle.Alpha Field

An MLEM.Misc.Easings.Easing that determines how this particle's alpha changes based on its TimeToLive and TimeLived

public Easing Alpha;

Field Value

MLEM.Misc.Easings.Easing

Particle.Animation Field

The MLEM.Animations.SpriteAnimation that this particle displays over its lifespan

protected readonly SpriteAnimation Animation;

Field Value

MLEM.Animations.SpriteAnimation

Particle.AttachedFurniture Field

The furniture that this particle is attached to.
If this is set, DrawColumns(Map, Vector2, SpriteBatch, Vector2, TextureRegion, Color, float, Point, bool, Furniture, AbstractSpot, Direction2, float, bool, bool, bool, bool, bool) is used to draw this particle with the ParentFurniture and ParentObjectSpot of the object set here.

public Furniture AttachedFurniture;

Field Value

Furniture

Particle.DepthOffset Field

The amount of tiles that this particle's depth display calculation is offset by, from its Position

public Vector2 DepthOffset;

Field Value

Microsoft.Xna.Framework.Vector2

Particle.DrawOffset Field

The amount of tiles that this particle's display position is offset by, from its Position

public Vector2 DrawOffset;

Field Value

Microsoft.Xna.Framework.Vector2

Particle.Friction Field

The friction that is applied to this particle's Motion every Update(GameTime, TimeSpan, GameSpeed) frame

public Vector2 Friction;

Field Value

Microsoft.Xna.Framework.Vector2

Particle.Gravity Field

The amount that this particle's Motion should be modified by each update frame

public float Gravity;

Field Value

System.Single

Particle.Motion Field

The amount that this particle's Position is modified by each Update(GameTime, TimeSpan, GameSpeed) frame

public Vector2 Motion;

Field Value

Microsoft.Xna.Framework.Vector2

Particle.Position Field

The position in the world of this particle

public Vector2 Position;

Field Value

Microsoft.Xna.Framework.Vector2

Particle.Scale Field

An MLEM.Misc.Easings.Easing that determines how this particle's scale (display size) changes based on its TimeToLive and TimeLived

public Easing Scale;

Field Value

MLEM.Misc.Easings.Easing

Particle.TimeLived Field

The amount of real time that this particle has lived for.
This time span will always be lower than or equal to TimeToLive.

protected TimeSpan TimeLived;

Field Value

System.TimeSpan

Particle.TimeToLive Field

The amount of real time that this particle should stay alive for until it disappears

public TimeSpan TimeToLive;

Field Value

System.TimeSpan

Particle.UpwardsMotion Field

The motion that this particle's UpwardsOffset is moved by every update frame.
If Gravity is set, this value is modified by Gravity every update frame as well.
This value is not affected by Friction.

public Vector2 UpwardsMotion;

Field Value

Microsoft.Xna.Framework.Vector2

Particle.UpwardsOffset Field

The offset from this particle's Position that is added in visual space only, using ToVisualY(Vector2).
This value is used by VisualPosition.

public Vector2 UpwardsOffset;

Field Value

Microsoft.Xna.Framework.Vector2

Properties

Particle.Map Property

The map that this particle is on.
Note that this always returns Map

protected static TinyLife.World.Map Map { get; }

Property Value

Map

Particle.VisualPosition Property

The position that this particle has in world space, but with the UpwardsOffset applied.
This offset represents the world space version of what the camera sees.

public Microsoft.Xna.Framework.Vector2 VisualPosition { get; }

Property Value

Microsoft.Xna.Framework.Vector2

Methods

Particle.Draw(GameTime, SpriteBatch) Method

Draws this particle on the current Map, at the current Position.

public virtual void Draw(Microsoft.Xna.Framework.GameTime time, Microsoft.Xna.Framework.Graphics.SpriteBatch batch);

Parameters

time Microsoft.Xna.Framework.GameTime
The current time

batch Microsoft.Xna.Framework.Graphics.SpriteBatch
The sprite batch to use for drawing

Particle.Spawn(Particle) Method

Adds a new particle to the map

public static void Spawn(TinyLife.Objects.Particle particle);

Parameters

particle Particle
The particle to spawn

Particle.Update(GameTime, TimeSpan, GameSpeed) Method

The update method, which is called every update frame by the underlying Map

public virtual void Update(Microsoft.Xna.Framework.GameTime time, System.TimeSpan passedInGame, TinyLife.GameSpeed speed);

Parameters

time Microsoft.Xna.Framework.GameTime
The game's time

passedInGame System.TimeSpan
The amount of time that has passed since the last call

speed GameSpeed
The game's speed