Table of Contents

Class GoalTrigger

Namespace
TinyLife.Goals
Assembly
Tiny Life.dll

A goal trigger is used by AutoTriggerGoal instances to determine whether they should be triggered. Goal triggers are compared only by their Name, so mods can add goal triggers that work for other mods without explicit compatibility. If there is only one ValidObjects entry, it is preferred to use one of the generic types GoalTrigger<TObject, TValue>, GoalTrigger<TObject, TValue1, TValue2>, or GoalTrigger<TObject, TValue1, TValue2, TValue3> for compile-time type safety.

public class GoalTrigger : IEquatable<GoalTrigger>
Inheritance
GoalTrigger
Implements
Derived
GoalTrigger<TObject, TValue>
GoalTrigger<TObject, TValue1, TValue2>
GoalTrigger<TObject, TValue1, TValue2, TValue3>
Inherited Members
Extension Methods

Constructors

GoalTrigger(string, IEnumerable<Type>, IEnumerable<Type>)

Creates a new goal trigger with the given settings. If there is only one validObjects entry, it is preferred to use one of the generic types GoalTrigger<TObject, TValue>, GoalTrigger<TObject, TValue1, TValue2>, or GoalTrigger<TObject, TValue1, TValue2, TValue3> for compile-time type safety.

public GoalTrigger(string name, IEnumerable<Type> validObjects, IEnumerable<Type> validGoals)

Parameters

name string

This goal trigger's name.

validObjects IEnumerable<Type>

A set of types that determine which objects are valid trigger objects for this goal trigger. This validates the obj parameter of Trigger(IGoalTriggerable, object, GoalTrigger, params object[]).

validGoals IEnumerable<Type>

A set of types that determine which values are valid trigger values for this goal trigger. When a subtype of AutoTriggerGoal is passed, the valid value will be extracted from the type's generic type arguments. Otherwise, the type itself will be used. This validates the values parameter of Trigger(IGoalTriggerable, object, GoalTrigger, params object[]).

Fields

ActionCompleted

A goal trigger for when an Action is completed succesfully (the result is Completed) by a PersonLike. This goal trigger supports the Action object type and the ConditionedGoal, AmountGoal and DistinctGoal<T> of type Action goal types.

public static readonly GoalTrigger<Action, bool, Action, float> ActionCompleted

Field Value

GoalTrigger<Action, bool, Action, float>

ActionEnded

A goal trigger for when an Action is completed in any way (the CompletionType doesn't matter) by a PersonLike. This goal trigger supports the Action object type and the ConditionedGoal, AmountGoal and DistinctGoal<T> of type Action goal types.

public static readonly GoalTrigger<Action, bool, Action, float> ActionEnded

Field Value

GoalTrigger<Action, bool, Action, float>

ActionUpdate

A goal trigger for when an Action is updated. This goal trigger supports the Action object type and the TimedGoal goal type.

public static readonly GoalTrigger<Action, TimeSpan> ActionUpdate

Field Value

GoalTrigger<Action, TimeSpan>

EarnMoney

A goal trigger for when a PersonLike earns money through an Action or Project. By default, this trigger is used in EarnMoney(float, object). This goal trigger supports the Project, Furniture, Action, Job and LotEmployment.Instance object types and the ConditionedGoal and AmountGoal goal types.

public static readonly GoalTrigger EarnMoney

Field Value

GoalTrigger

EmotionGained

A goal trigger for when a EmotionModifier is added to a PersonLike using AddEmotion(EmotionModifier, int, TimeSpan, IEmotionSource, bool). This goal trigger supports the EmotionModifier.Instance object type and the ConditionedGoal, AmountGoal and DistinctGoal<T> of type EmotionModifier goal types.

public static readonly GoalTrigger<EmotionModifier.Instance, bool, EmotionModifier.Instance, float> EmotionGained

Field Value

GoalTrigger<EmotionModifier.Instance, bool, EmotionModifier.Instance, float>

EmotionLost

A goal trigger for when a EmotionModifier is removed from a PersonLike in RemoveEmotion(EmotionModifier) or when it runs out. This goal trigger supports the EmotionModifier.Instance object type and the ConditionedGoal, AmountGoal and DistinctGoal<T> of type EmotionModifier goal types.

public static readonly GoalTrigger<EmotionModifier.Instance, bool, EmotionModifier.Instance, float> EmotionLost

Field Value

GoalTrigger<EmotionModifier.Instance, bool, EmotionModifier.Instance, float>

FoodEaten

A goal trigger for when a FoodType item is eaten by a PersonLike in InvokeOnEaten(ActionInfo, FoodTypedItem). This goal trigger supports the FoodTypedItem object type and the ConditionedGoal, AmountGoal and DistinctGoal<T> of type FoodTypedItem goal types.

public static readonly GoalTrigger<FoodTypedItem, bool, FoodTypedItem, float> FoodEaten

Field Value

GoalTrigger<FoodTypedItem, bool, FoodTypedItem, float>

FurnitureCreated

A goal trigger for when a Furniture item is created by a PersonLike. By default, this trigger is used in SetCreator(PersonLike, bool). This goal trigger supports the Furniture object type and the ConditionedGoal, AmountGoal and DistinctGoal<T> of type Furniture goal types.

public static readonly GoalTrigger<Furniture, bool, Furniture, float> FurnitureCreated

Field Value

GoalTrigger<Furniture, bool, Furniture, float>

Name

This goal trigger's name.

public readonly string Name

Field Value

string

PersonUpdate

A goal trigger for when a PersonLike's Update(GameTime, TimeSpan, float) method is called. This goal trigger supports the PersonLike object type and the TimedGoal and ConditionedGoal goal types.

public static readonly GoalTrigger<PersonLike, TimeSpan, bool> PersonUpdate

Field Value

GoalTrigger<PersonLike, TimeSpan, bool>

ProjectCompleted

A goal trigger for when a Project is marked as completed in OnCompleted(). This goal trigger supports the Project object type and the ConditionedGoal, AmountGoal and DistinctGoal<T> of type Project goal types.

public static readonly GoalTrigger<Project, bool, Project, float> ProjectCompleted

Field Value

GoalTrigger<Project, bool, Project, float>

ValidObjects

A set of types that determine which objects are valid trigger objects for this goal trigger. This validates the obj parameter of Trigger(IGoalTriggerable, object, GoalTrigger, params object[]).

public readonly List<Type> ValidObjects

Field Value

List<Type>

ValidValues

A set of types that determine which values are valid trigger values for this goal trigger. This validates the values parameter of Trigger(IGoalTriggerable, object, GoalTrigger, params object[]).

public readonly List<Type> ValidValues

Field Value

List<Type>

Methods

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

Equals(GoalTrigger)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(GoalTrigger other)

Parameters

other GoalTrigger

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

IsObjectCompatible(Type)

Returns whether an object of the given objType is compatible with this goal trigger, based on ValidObjects. This validates the obj parameter of Trigger(IGoalTriggerable, object, GoalTrigger, params object[])

public bool IsObjectCompatible(Type objType)

Parameters

objType Type

The type of the object.

Returns

bool

Whether the object is compatible.

IsValueCompatible(Type)

Returns whether a value of the given valueType is compatible with this goal trigger, based on ValidValues. This validates the values parameter of Trigger(IGoalTriggerable, object, GoalTrigger, params object[])

public bool IsValueCompatible(Type valueType)

Parameters

valueType Type

The type of the value.

Returns

bool

Whether the value is compatible.