CornerFurniture - Ellpeck/TinyLifeExampleMod Wiki
A corner furniture is a piece of furniture that has an additional set of corner textures that it can display in various conditions.
The default CornerFurniture class can be used for things like hedges, which only have a single vertical and horizontal rotation each.
For objects like counters which have four distinct rotations, the subclass Counter can be used.
For objects with custom connection logic, you can override ShouldConnectTo(Furniture) and GetCornerStatus(Dictionary<Direction2,Direction2>).
public class CornerFurniture : TinyLife.Objects.Furniture
CornerFurniture.CornerFurniture(Guid, FurnitureType, int, Map, Vector2) Constructor
Creates a new furniture instance.
By default, this is done using Construct(int, Map, Vector2, Nullable<Guid>).
public CornerFurniture(System.Guid id, TinyLife.Objects.FurnitureType type, int colors, TinyLife.World.Map map, Microsoft.Xna.Framework.Vector2 pos);
The id to apply to the created furniture instance
The type to create an instance of
The map to create the furniture on
The position that the furniture should have
CornerFurniture.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);
The game time
The sprite batch to draw with
The position, in world space, that the furniture is at
The position, in draw space, to draw the furniture at
The rotation of the furniture
The scale to draw the furniture with
Whether or not to move the furniture by its texture's pivot point
The object that this furniture is latched on to, or null if there is none
The object spot that this furntiture is in, or null if there is none
A value that is added onto the calculated depth of the object
A method that is used to determine the corner status that this furniture should have, based on the given neighborRotations.
The neighbor rotations are previously gathered based on the information returned for each neighbor in ShouldConnectTo(Furniture).
protected virtual MLEM.Misc.Direction2 GetCornerStatus(System.Collections.Generic.Dictionary<MLEM.Misc.Direction2,MLEM.Misc.Direction2> neighborRotations);
The rotations of each neighbor, where the keys are the direction that the neighbor is in, and the values are the neighbor's Rotation
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);
The neighbor furniture that changed
A method that determines whether this corner furniture should connect to the given neighboring furniture.
If this method returns true, the neighbor's rotation is passed to GetCornerStatus(Dictionary<Direction2,Direction2>).
protected virtual bool ShouldConnectTo(TinyLife.Objects.Furniture neighbor);
The neighbor to connect to
Whether this object should connect to the neighbor furniture
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();
false if the object is not valid, true otherwise