Class GoalSet
A goal set is a set of Goal instances that manages them. Goal sets are used by a Job's DailyTasks as well as by the LifeGoal system.
[DataContract]
public class GoalSet : JsonTypeSafeGenericDataHolder, IGenericDataHolder, IGoalTriggerable
- Inheritance
-
JsonTypeSafeGenericDataHolderGoalSet
- Implements
-
IGenericDataHolder
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
GoalSet(GoalSetInfo)
Creates a new goal set with the given settings
public GoalSet(GoalSetInfo info)
Parameters
info
GoalSetInfoThe underlying goal set info
Properties
Goals
The goals in this goal set.
public ICollection<Goal> Goals { get; }
Property Value
Info
The underlying GoalSetInfo that this goal set was constructed from
public GoalSetInfo Info { get; }
Property Value
Methods
GetDisplay(Anchor, bool)
Returns a MLEM.Ui.Elements.Group of elements that display the progress of this goal set dynamically
public Group GetDisplay(Anchor anchor, bool descriptionAsChild = false)
Parameters
anchor
AnchorThe anchor that the returned group should have
descriptionAsChild
boolWhether the description should be returned as a child of the returned group, rather than added as a tooltip.
Returns
- Group
A group that displays this goal set's progress
GetGoal<T>()
Returns the single Goal instance in this goal set of the given type. If there are more goals of the given type, this method will throw an InvalidOperationException.
public T GetGoal<T>() where T : Goal
Returns
- T
The single goal of the given type
Type Parameters
T
The type of goal to return
GetGoal<T>(string)
Returns the Goal instance in this goal set with the given name, or null if there is no matching goal
public T GetGoal<T>(string name) where T : Goal
Parameters
name
stringThe name of the goal to return
Returns
- T
The goal with the given name and type
Type Parameters
T
The type of goal to return
GetGoals<T>()
Returns a set of all of the Goal instnaces that are contained in this goal set, optionally matching the specified type parameter T
public IEnumerable<T> GetGoals<T>() where T : Goal
Returns
- IEnumerable<T>
The goals in this goal set
Type Parameters
T
The type of goal to return
GetProgress()
Returns the progress of this goal set as a percentage between 0 and 1, which is a combination of the GetProgress() values from the underlying Goal instances
public float GetProgress()
Returns
- float
The progress, between 0 and 1
IsCompleted()
Returns whether this goal set is completed. This returns whether GetProgress() is greater than or equal to 1.
public bool IsCompleted()
Returns
- bool
Whether this goal set is completed
Reset()
Resets this goal set by calling the Reset() methods of the underlying goals
public void Reset()
Validate(GoalSetInfo)
Validates this goal set and all of the underlying Goal instances. This method should be called when this goal set is loaded from disk.
public bool Validate(GoalSetInfo info)
Parameters
info
GoalSetInfoThe underlying goal set info that this goal set was constructed from
Returns
- bool
Whether this goal set is considered valid