Class Project
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).
[DataContract]
public class Project : JsonTypeSafeGenericDataHolder, IGenericDataHolder
- Inheritance
-
JsonTypeSafeGenericDataHolderProject
- Implements
-
IGenericDataHolder
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
Project(Person, string, string)
Creates a new project with the given settings
public Project(Person person, string type, string name)
Parameters
person
PersonThe person that owns this project
type
stringThe type of the project
name
stringThe name of the project
Fields
Name
The name of this project, which is usually user-entered using OpenTextPrompt(string, Action<string>, Predicate<string>, Rule, string, TextureRegion)
[DataMember]
public readonly string Name
Field Value
Quality
The quality of this project, which defaults to Terrible, and does not have to be used
[DataMember(EmitDefaultValue = false)]
public Quality Quality
Field Value
Type
The type of this project, which is an arbitrary string. Book writing projects, for example, have the type set to "Book".
[DataMember]
public readonly string Type
Field Value
Properties
Archived
A property that stores whether this project is archived. A project is archived automatically in OnNewDay() once its DailyPay reaches 0.
[DataMember]
public bool Archived { get; protected set; }
Property Value
Completed
Returns whether this project is completed. For default projects, this returns whether Progress is greater than or equal to 100.
public virtual bool Completed { get; }
Property Value
DailyPay
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.
[DataMember(EmitDefaultValue = false)]
public float DailyPay { get; protected set; }
Property Value
DailyPayReductionFactor
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.
[DataMember(EmitDefaultValue = false)]
public float DailyPayReductionFactor { get; protected set; }
Property Value
Person
The person that owns this project
public Person Person { get; protected set; }
Property Value
Progress
The progress of this project, which can be an arbitrary number. Most projects in the default game use a progress between 0 and 100, at which point Completed will also return true by default.
public float Progress { get; set; }
Property Value
Methods
CreateActions(ActionSettings)
Creates a set of action settings (which can be registered using Register(TypeSettings)) that involve creating, continuing and scrapping projects of a specified type. It is recommended to use the provided non-default constructor of Project.ActionSettings for this method.
public static IEnumerable<ActionType.TypeSettings> CreateActions(Project.ActionSettings settings)
Parameters
settings
Project.ActionSettingsThe action settings
Returns
- IEnumerable<ActionType.TypeSettings>
A set of type settings for a start, continue and scrap action
GetPossibleArguments(ActionInfo, string, Predicate<Project>, Func<Project, string>)
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 IEnumerable<ActionArgument> GetPossibleArguments(ActionInfo info, string type, Predicate<Project> condition = null, Func<Project, string> projectDisplayName = null)
Parameters
info
ActionInfoThe action info
type
stringThe type of projects to return varieties for
condition
Predicate<Project>A condition that determines whether a project should be turned into a variety
projectDisplayName
Func<Project, string>A function that determines the display name of each project, or null to display its Name
Returns
- IEnumerable<ActionArgument>
A set of action varieties
MakeProgress(float, float, ActionInfo, SkillType, float)
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, float speedMultiplier, ActionInfo info = null, SkillType skill = null, float levelModifier = 0.1)
Parameters
amount
floatThe amount to add to the Progress
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
info
ActionInfoThe action informatio nthat optionally influences progress gain using GetEfficiencyModifier(float, ActionInfo, SkillType, float)
skill
SkillTypeThe (optional) skill that influences progress gain using GetEfficiencyModifier(float, ActionInfo, SkillType, float)
levelModifier
floatThe (optional) amount that each level of the
skill
influences progress gain. Defaults to 0.1.
OnCompleted()
A method called automatically when Completed turns to true after Progress changes. Note that, if Completed has a custom implementation, this method will respect that.
protected virtual void OnCompleted()
OnNewDay()
This method gets called when a new day is reached. By default, this method reduces the DailyPay by the DailyPayReductionFactor and sets Archived to true if the DailyPay goes below 1.
public virtual void OnNewDay()
OpenNamePrompt(Action, string, Action<Project>, string)
A helper method that uses OpenTextPrompt(string, Action<string>, Predicate<string>, Rule, string, TextureRegion) to open a prompt that the player can enter a project name in when starting a new project.
Additionally, a (random or single) defaultName
can be specified to fill the text field by default.
public static void OpenNamePrompt(Action action, string type, Action<Project> onNameChosen, string defaultName = null)
Parameters
action
ActionThe action to open the prompt for.
type
stringThe type of project to start and name.
onNameChosen
Action<Project>An action that is invoked when the name is chosen and the project is started.
defaultName
stringThe default name to fill the text field with.
OpenScrapPrompt(Action, string, string, Action)
A helper method that uses OpenTextPrompt(string, Action<string>, Predicate<string>, Rule, string, TextureRegion) to open a prompt for when a project should be scrapped by a player.
public static void OpenScrapPrompt(Action action, string type, string name, Action onScrapped = null)
Parameters
action
ActionThe action to open the prompt for.
type
stringThe type of project to scrap.
name
stringThe name of the project to scrap.
onScrapped
ActionAn action that is invoked when the project is scrapped.
Remove()
Removes this project from the Person's project list, effectively deleting it
public virtual void Remove()
SetDailyPay(float, float, bool)
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
floatThe amount to pay daily
dailyReductionFactor
floatThe amount that the daily pay should be reduced by.
amount
is multiplied with 1 - dailyReductionFactor every day.influencedByQuality
boolWhether the current Quality should have an effect on the pay
Validate(Person)
Validates this project, setting the Person that owns it after the game is loaded.
public virtual bool Validate(Person person)
Parameters
person
PersonThe person that owns this project
Returns
- bool
Whether this project is considered valid