Class GoalTrigger
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
stringThis 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
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
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
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
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
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
Name
This goal trigger's name.
public readonly string Name
Field Value
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
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
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
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
Methods
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
Equals(GoalTrigger)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(GoalTrigger other)
Parameters
other
GoalTriggerAn object to compare with this object.
Returns
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
TypeThe 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
TypeThe type of the value.
Returns
- bool
Whether the value is compatible.