Project - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Goals

Project Class

A project is a thing that can be done, saved, completed and monetized by a Person.
A project should be used for actions like writing and programming, where there isn't a physical, MapObject-based representation of the projecgt in the world (like with paintings).

public class Project : MLEM.Misc.GenericDataHolder

Inheritance System.Object 🡒 MLEM.Misc.GenericDataHolder 🡒 Project

Constructors

Project.Project(Person, string, string) Constructor

Creates a new project with the given settings

public Project(TinyLife.Objects.Person person, string type, string name);

Parameters

person Person
The person that owns this project

type System.String
The type of the project

name System.String
The name of the project

Fields

Project.Name Field

The name of this project, which is usually user-entered using OpenTextPrompt(string, Action<string>, Predicate<string>, Rule)

public readonly string Name;

Field Value

System.String

Project.Quality Field

The quality of this project, which defaults to Terrible, and does not have to be used

public Quality Quality;

Field Value

Quality

Project.Type Field

The type of this project, which is an arbitrary string.
Book writing projects, for example, have the type set to "Book".

public readonly string Type;

Field Value

System.String

Properties

Project.DailyPay Property

The daily pay value of this project.
If this is set, and DailyPayReductionFactor is also set, daily royalties will be paid to the Person that owns it.

public float DailyPay { get; set; }

Property Value

System.Single

Project.DailyPayReductionFactor Property

The amount by which the DailyPay of this project is reduced every day.
If this value is set to 0.1, for example, the DailyPay will be multiplied by 1 - 0.1 (= 0.9) every day.

public float DailyPayReductionFactor { get; set; }

Property Value

System.Single

Project.Person Property

The person that owns this project

public TinyLife.Objects.Person Person { get; set; }

Property Value

Person

Project.Progress Property

The progress of this project, which can be an arbitrary number.
Most projects in the default game use a progress between 0 and 1 or between 0 and 100.

public float Progress { get; set; }

Property Value

System.Single

Methods

Project.CreateActions(ActionSettings) Method

Creates a set of action settings (which can be registered using RegisterAll(IEnumerable<TypeSettings>)) that involve creating, continuing and scrapping projects of a specified type.
It is recommended to use the provided non-default constructor of ActionSettings for this method.

public static System.Collections.Generic.ICollection<TinyLife.Actions.ActionType.TypeSettings> CreateActions(TinyLife.Goals.Project.ActionSettings settings);

Parameters

settings ActionSettings
The action settings

Returns

System.Collections.Generic.ICollection<TypeSettings>
A set of type settings for a start, continue and scrap action

Project.GetAndReduceDailyPay() Method

Returns the DailyPay value of this project and reduces it by the DailyPayReductionFactor.
By default, this method also Remove()s this project if the daily pay reached 0.
In essence, this method causes one day to pass in the project's eyes.

public virtual float GetAndReduceDailyPay();

Returns

System.Single
The daily pay

Project.GetVarieties(ActionInfo, string, Predicate<Project>, Func<Project,string>) Method

Returns the varieties that a Person has at their disposal for a given project Type.
The varieties returned include all of the projects that the Person has in their project list.

public static System.Collections.Generic.IEnumerable<TinyLife.Actions.ActionVariety> GetVarieties(TinyLife.Actions.ActionInfo info, string type, System.Predicate<TinyLife.Goals.Project> condition=null, System.Func<TinyLife.Goals.Project,string> projectDisplayName=null);

Parameters

info ActionInfo
The action info

type System.String
The type of projects to return varieties for

condition System.Predicate<Project>
A condition that determines whether a project should be turned into a variety

projectDisplayName System.Func<Project,System.String>
A function that determines the display name of each project, or null to display its Name

Returns

System.Collections.Generic.IEnumerable<ActionVariety>
A set of action varieties

Project.MakeProgress(float, GameSpeed, SkillType, float) Method

Makes progress on the project, updating the Progress value based on the Person's Skill and general efficiency modifier

public virtual void MakeProgress(float amount, TinyLife.GameSpeed speed, TinyLife.Skills.SkillType skill=null, float levelModifier=0.1f);

Parameters

amount System.Single
The amount to add to the Progress

speed GameSpeed
The current game speed

skill SkillType
The (optional) skill that influences progress gain using GetEfficiencyModifier(SkillType, float)

levelModifier System.Single
The (optiona) amount that each level of the skill influences progress gain. Defaults to 0.1.

Project.Remove() Method

Removes this project from the Person's project list, effectively deleting it

public virtual void Remove();

Project.SetDailyPay(float, float, bool) Method

Sets the daily pay amount of this project, optionally based on its Quality.
If influencedByQuality is true, the daily pay and daily reduction factor will be modified to suit the quality better.

public void SetDailyPay(float amount, float dailyReductionFactor, bool influencedByQuality=true);

Parameters

amount System.Single
The amount to pay daily

dailyReductionFactor System.Single
The amount that the daily pay should be reduced by. amount is multiplied with 1 - dailyReductionFactor every day.

influencedByQuality System.Boolean
Whether the current Quality should have an effect on the pay

Project.Validate(Person) Method

Validates this project, setting the Person that owns it after the game is loaded.

public virtual bool Validate(TinyLife.Objects.Person person);

Parameters

person Person
The person that owns this project

Returns

System.Boolean
Whether this project is considered valid