Fence - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Objects

Fence Class

A fence is a furniture used by things like TinyLife.Objects.FurnitureType.CountryFence that auto-connects similarly to CornerFurniture, but by actually adding additional connection textures onto the regular object textures

public class Fence : TinyLife.Objects.Furniture

Inheritance System.Object 🡒 MLEM.Misc.GenericDataHolder 🡒 MapObject 🡒 Furniture 🡒 Fence

Constructors

Fence.Fence(Guid, FurnitureType, int[], Map, Vector2) Constructor

Creates a new furniture instance.
By default, this is done using Construct(int[], Map, Vector2, Nullable<Guid>).

public Fence(System.Guid id, TinyLife.Objects.FurnitureType type, int[] colors, TinyLife.World.Map map, Microsoft.Xna.Framework.Vector2 pos);

Parameters

id System.Guid
The id to apply to the created furniture instance

type FurnitureType
The type to create an instance of

colors System.Int32[]
The colors to apply to the furniture

map Map
The map to create the furniture on

pos Microsoft.Xna.Framework.Vector2
The position that the furniture should have

Methods

Fence.Draw(GameTime, SpriteBatch, Vector2, Vector2, Nullable<Color>, Direction2, int[], float, bool, Furniture, AbstractSpot, float, bool) Method

Draws this furniture in the world with the given settings.
This is a more generalized version of Draw(GameTime, SpriteBatch, Vector2, Nullable<Color>)

public override void Draw(Microsoft.Xna.Framework.GameTime time, Microsoft.Xna.Framework.Graphics.SpriteBatch batch, Microsoft.Xna.Framework.Vector2 pos, Microsoft.Xna.Framework.Vector2 drawPos, System.Nullable<Microsoft.Xna.Framework.Color> overrideColor, MLEM.Misc.Direction2 rotation, int[] colors, float drawScale, bool pivot, TinyLife.Objects.Furniture parent, TinyLife.Objects.AbstractSpot parentSpot, float depthOffset, bool held);

Parameters

time Microsoft.Xna.Framework.GameTime
The game time

batch Microsoft.Xna.Framework.Graphics.SpriteBatch
The sprite batch to draw with

pos Microsoft.Xna.Framework.Vector2
The position, in world space, that the furniture is at

drawPos Microsoft.Xna.Framework.Vector2
The position, in draw space, to draw the furniture at

overrideColor System.Nullable<Microsoft.Xna.Framework.Color>
An optional color to override the default colors of the furniture

rotation MLEM.Misc.Direction2
The rotation of the furniture

colors System.Int32[]
The colors to draw the furniture with

drawScale System.Single
The scale to draw the furniture with

pivot System.Boolean
Whether or not to move the furniture by its texture's pivot point

parent Furniture
The object that this furniture is latched on to, or null if there is none

parentSpot AbstractSpot
The object spot that this furntiture is in, or null if there is none

depthOffset System.Single
A value that is added onto the calculated depth of the object

held System.Boolean
Whether or not this item is currently being held by a Person

Fence.OnNeighborChanged(Furniture) Method

This method gets called when any neighboring furniture changes. The neighboring furniture is passed.
By default, this method does nothing, so calling base is not necessary.

protected override void OnNeighborChanged(TinyLife.Objects.Furniture neighbor);

Parameters

neighbor Furniture
The neighbor furniture that changed

Fence.ShouldConnectTo(Furniture) Method

This method returns whether this furniture instance should connect to the neighbor furniture.
By default, this is only true if the FurnitureType is the same.

protected virtual bool ShouldConnectTo(TinyLife.Objects.Furniture neighbor);

Parameters

neighbor Furniture
The neighbor furniture

Returns

System.Boolean
Whether they should connect

Fence.Validate() Method

This method is called when this object is loaded from disk.
Returning false on this method causes the object to be removed from the map.
By default, this method invokes OnValidated and OnEventsAttachable.

public override bool Validate();

Returns

System.Boolean
false if the object is not valid, true otherwise