Table of Contents

Class HelpAction

Namespace
TinyLife.Actions
Assembly
Tiny Life.dll

An action class derived from SocialAction that represents a complex action that involves a person being helped by a helper, and that can be started from both parties ("Ask for Help" and "Offer Help"). An action type for actions of this class should be created using CreateActions(string, ObjectCategory, Type, CanExecuteDelegate, CanExecuteDelegate, AiSettings?, AiSettings?).

public abstract class HelpAction : SocialAction, IGenericDataHolder
Inheritance
JsonTypeSafeGenericDataHolder
HelpAction
Implements
IGenericDataHolder
Inherited Members
JsonTypeSafeGenericDataHolder.GetDataKeys()
Extension Methods

Constructors

HelpAction(ActionInfo, bool, PersonLike)

public HelpAction(ActionInfo info, bool wasOffered, PersonLike person = null)

Parameters

info ActionInfo
wasOffered bool
person PersonLike

HelpAction(ActionType, ActionInfo, bool, PersonLike)

public HelpAction(ActionType type, ActionInfo info, bool wasOffered, PersonLike person = null)

Parameters

type ActionType
info ActionInfo
wasOffered bool
person PersonLike

Properties

HelpedAction

Returns the action that is currently being helped, which is based on whether this action belongs to the Helper.

public Action HelpedAction { get; }

Property Value

Action

Helper

Returns the helper, which is the person for whom IsHelper is true.

public PersonLike Helper { get; }

Property Value

PersonLike

IsHelper

Returns whether this action belongs to the helper.

public bool IsHelper { get; }

Property Value

bool

Methods

AndThenOnCompleted(CompletionType)

MultiAction version of OnCompleted(CompletionType). This method gets called when the main action completes.

protected override void AndThenOnCompleted(CompletionType type)

Parameters

type CompletionType

The completion of the main action

CanMultitask(Action)

Return true on this method if this action can be multi-tasked along with the passed Action. To actually check this property, CanMultitask(Action, Action) should be used as it compares both objects. A multi-tasking is an action that is currently active along with another action. By default, multi-tasking is disallowed for any action.

public override bool CanMultitask(Action other)

Parameters

other Action

The action to multi-task with

Returns

bool

Whether this action can be multi-tasked

CreateActions(string, ObjectCategory, Type, CanExecuteDelegate, CanExecuteDelegate, AiSettings?, AiSettings?)

Creates and returns a set of ActionType.TypeSettings instances that contains an "Ask" action, as well as an "Offer" action, using CreateAskOffer(string, ObjectCategory, Type, CanExecuteDelegate, CanExecuteDelegate, AiSettings?, AiSettings?, CanExecuteResult?).

public static IEnumerable<ActionType.TypeSettings> CreateActions(string name, ObjectCategory context, Type constructedType, ActionType.CanExecuteDelegate canRecipientExecute, ActionType.CanExecuteDelegate canHelperExecute, ActionType.AiSettings? askAi = null, ActionType.AiSettings? offerAi = null)

Parameters

name string

The base action name, which has "Ask" and "Offer" appended to it automatically.

context ObjectCategory

The context.

constructedType Type

The constructed action type.

canRecipientExecute ActionType.CanExecuteDelegate

A ActionType.CanExecuteDelegate that determines whether the recipient of this action (the person that is offered help, or the person that asks for help) can execute it.

canHelperExecute ActionType.CanExecuteDelegate

A ActionType.CanExecuteDelegate that determines whether the helper of this action (the person that offers help, or the person that is asked for help) can execute it.

askAi ActionType.AiSettings?

The ActionType.AiSettings for the "Ask" version of this action.

offerAi ActionType.AiSettings?

The ActionType.AiSettings for the "Offer" version of this action.

Returns

IEnumerable<ActionType.TypeSettings>

The "Ask" and "Offer" action type settings.

CreateFirstActions()

Return a set of actions that should be executed before this action. Even if the yield statement is used, all actions will be collected into a list at the start of this action's invocation. If no action gets returned in this function, this action fails. If the returned set only contains null items, no first actions will be executed.

protected override IEnumerable<Action> CreateFirstActions()

Returns

IEnumerable<Action>

A set of actions that should run before this action

CreateHelpedAction(ActionInfo)

A method that is called when the action that is being helped with should be created. The passed mainInfo should be used as the action's ActionInfo.

protected abstract Action CreateHelpedAction(ActionInfo mainInfo)

Parameters

mainInfo ActionInfo

The info for the helped action.

Returns

Action

The helped action.

GetNextAction(CompletionType)

Returns an action that should be queued up immediately after this action completes. The queued up action is immediately started in the slot that this action occupied. Can be null, and is null by default.

public override Action GetNextAction(CompletionType completion)

Parameters

completion CompletionType

The type that this action completed with

Returns

Action

The follow-up action

GetProgress()

Optionally returns the progress that this action's execution currently exhibits, in a range between 0 and 1. The returned progress will be displayed below the action icon in the top left as a green bar that is expected to fill up slowly as progress is made. Returning an empty value causes no progress bar to be displayed, and is also the default behavior.

public override float? GetProgress()

Returns

float?

This action's progress.

InitializeConversation()

Initializes the conversation. This method is called for both partners in AndThenInitialize() by the partner who initializes this action last. By default, this method does nothing.

protected override void InitializeConversation()

IsConversationCompleted()

SocialAction version of IsCompleted(). This method returns whether the conversation should be marked as completed. Note that this method is only called for the IsMain part of the conversation.

protected override CompletionType IsConversationCompleted()

Returns

CompletionType

Whether this conversation is completed

OnChildCompleted(Action, CompletionType, bool)

This method is invoked automatically when an action completes that is marked as this action's child. A child action is one started through a MultiActionHandler or UnderlyingActionHandler. By default, this method calls OnChildCompleted(Action, CompletionType, bool) on this action's Parent, if there is one.

protected override void OnChildCompleted(Action child, CompletionType type, bool grandchild)

Parameters

child Action

The child that completed.

type CompletionType

The child's completion type.

grandchild bool

Whether the given child is a grandchild, rather than a direct child.

OnHelpedActionCompleted(Action, CompletionType)

A method that is called when the helped action (created using CreateHelpedAction(ActionInfo)) is completed.

protected virtual void OnHelpedActionCompleted(Action helpedAction, CompletionType type)

Parameters

helpedAction Action

The helped action.

type CompletionType

The completion type.

UpdateConversation(GameTime, TimeSpan, float)

SocialAction version of Update(GameTime, TimeSpan, float). This method is called every update frame during an active conversation for both conversation partners. By default, this method only increases ConversationTime.

protected override void UpdateConversation(GameTime time, TimeSpan passedInGame, float speedMultiplier)

Parameters

time GameTime

The game's time

passedInGame TimeSpan

The amount of time passed in game time

speedMultiplier float

The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed

UpdateHelpedAction(Action, GameTime, TimeSpan, float)

A method that is called when the helped action (created using CreateHelpedAction(ActionInfo)) is updated.

protected abstract void UpdateHelpedAction(Action helpedAction, GameTime time, TimeSpan passedInGame, float speedMultiplier)

Parameters

helpedAction Action

The helped action.

time GameTime

The game time.

passedInGame TimeSpan

The amount of time passed in game.

speedMultiplier float

The game's speed multiplier.

Validate(PersonLike, AppliedMigrations)

Validates this action's data. This is called when a map is loaded from disk. When returning false on this method, the action is removed from the Person.

public override bool Validate(PersonLike person, AppliedMigrations appliedMigrations)

Parameters

person PersonLike

The person that this action belongs to

appliedMigrations AppliedMigrations

The migrations that have been applied so far

Returns

bool

Whether or not the action is still valid (or if it has invalid data)