Table of Contents

Class Fridge

Namespace
TinyLife.Objects
Assembly
TinyLife.dll

A fridge is a Furniture that can contain a set of Items that a PersonLike can interact with. For any Items that are food, their ExpirationTime is increased while in a fridge.

public class Fridge : Furniture, IGenericDataHolder, IUpdatingObject, IContainerObject<Furniture>
Inheritance
JsonTypeSafeGenericDataHolder
Fridge
Implements
IGenericDataHolder
Inherited Members
JsonTypeSafeGenericDataHolder.GetDataKeys()
Extension Methods

Constructors

Fridge(Guid, FurnitureType, int[], Map, Vector2, float)

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

public Fridge(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos, float floor)

Parameters

id Guid

The id to apply to the created furniture instance

type FurnitureType

The type to create an instance of

colors int[]

The colors to apply to the furniture

map Map

The map to create the furniture on

pos Vector2

The position that the furniture should have

floor float

The floor that this object is on.

Fields

Items

The items that this fridge contains. To add or remove items to or from this fridge, simply modify this collection.

[DataMember]
public readonly HashSet<Furniture> Items

Field Value

HashSet<Furniture>

Properties

Content

public IEnumerable<Furniture> Content { get; }

Property Value

IEnumerable<Furniture>

Methods

AddContent(Furniture)

public bool AddContent(Furniture content)

Parameters

content Furniture

Returns

bool

MoveToMap(Map, Vector2?, float?)

Moves this object to the given map, changing the current Map in the process. If the object is currently on its Map (IsInWorld), then it is removed from it using RemoveObject(MapObject) and added to the new map using AddObject(MapObject). If the object is not currently on its Map, then its map is changed without subsequently adding it to the new map.

public override bool MoveToMap(Map map, Vector2? position = null, float? floor = null)

Parameters

map Map

The map to move to.

position Vector2?

The position on the new map to move to, or null to keep it the same.

floor float?

The floor to move to, or null to keep it the same.

Returns

bool

Whether moving to the map was successful, which is false if this object's Map is already the given map. If true is returned, its IsInWorld state is additionally guaranteed to be the same as it was before this method was called. If false is returned, no action was performed.

RemoveContent(Furniture)

public bool RemoveContent(Furniture content)

Parameters

content Furniture

Returns

bool

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 bool

Whether a more thorough reset is expected, which usually involves normalizing additional data and cleaning up player data entirely. This is true when a map with this object on it is exported, as well as when households are exported for official usage in the game.

custom bool

Whether 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 void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)

Parameters

time GameTime

The game's time

passedInGame TimeSpan

The amount of time that has passed since the last call

speedMultiplier float

The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed

Validate(AppliedMigrations)

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(AppliedMigrations appliedMigrations)

Parameters

appliedMigrations AppliedMigrations

Returns

bool

false if the object is not valid, true otherwise