Class SocialAction
A social action is an action that involves two PersonLike instances. Before a social action "actually" starts, both parties have to have the action as their current action. For this to happen, the person that initiates the action follows the Partner until they reach them (or give up).
public abstract class SocialAction : MultiAction, IGenericDataHolder
- Inheritance
-
JsonTypeSafeGenericDataHolderSocialAction
- Implements
-
IGenericDataHolder
- Derived
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
SocialAction(ActionInfo)
Creates a new typeless action with the given action information.
protected SocialAction(ActionInfo info)
Parameters
info
ActionInfoThe information for this action.
SocialAction(ActionType, ActionInfo)
Creates a new action with the given action information.
protected SocialAction(ActionType type, ActionInfo info)
Parameters
type
ActionTypeThe type for this action.
info
ActionInfoThe information for this action.
Properties
ConversationTime
The amount of time that the actual conversation has been going on for. This is the total amount of time (ElapsedTime) minus the amount of time it took for the IsMain PersonLike to reach the Partner.
[DataMember]
public TimeSpan ConversationTime { get; protected set; }
Property Value
InProgressTime
Represents the amount of time that this action has "properly" been in progress for. This is used by MultiAction and SocialAction and returns true only once the first actions are completed or the conversation has started, respectively. By default, ElapsedTime is returned.
public override TimeSpan InProgressTime { get; }
Property Value
- TimeSpan
The amount of time that this action has properly been in progress for
IsMain
Whether or not this is the action that started the social interaction The PartnerAction will always have the inverse value of this value.
[DataMember]
public bool IsMain { get; protected set; }
Property Value
MainAction
The SocialAction that is the main action, which is either this or PartnerAction, based on whether this action IsMain.
public SocialAction MainAction { get; }
Property Value
Partner
The PersonLike that we're interacting with, which is the first PersonLike result from GetInvolvedObject<T>(ObjectCategory, bool, bool, Func<T, bool>) that isn't Person.
public PersonLike Partner { get; }
Property Value
PartnerAction
The SocialAction that the Partner of this action instantiated as part of the interaction
public SocialAction PartnerAction { get; }
Property Value
Methods
AndThenInitialize()
Initializes the main action. This method is called after Handler has all completed.
protected override sealed void AndThenInitialize()
AndThenIsCompleted()
MultiAction version of IsCompleted(). This method returns whether or not the main action is completed.
protected override sealed CompletionType AndThenIsCompleted()
Returns
- CompletionType
Whether the main action is completed
AndThenOnCompleted(CompletionType)
MultiAction version of OnCompleted(CompletionType). This method gets called when the main action completes.
protected override void AndThenOnCompleted(CompletionType type)
Parameters
type
CompletionTypeThe completion of the main action
AndThenUpdate(GameTime, TimeSpan, float)
MultiAction version of Update(GameTime, TimeSpan, float). This method is called every update frame while the main action is active. By default, only MainElapsedTime is increased.
protected override sealed void AndThenUpdate(GameTime time, TimeSpan passedInGame, float speedMultiplier)
Parameters
time
GameTimeThe current game time
passedInGame
TimeSpanThe amount of time that has passed, in game time
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
AndThenUpdateBoth(GameTime, TimeSpan, float)
A SocialAction-specific version of AndThenUpdate(GameTime, TimeSpan, float) that is invoked only when both partners have already started their instances of the SocialAction. Note that, unlike UpdateConversation(GameTime, TimeSpan, float), this method is invoked even when one of the involved partners is not yet in the Main stage. By default, this method calls UpdateConversation(GameTime, TimeSpan, float) if both partners are in the action's main stage.
protected virtual void AndThenUpdateBoth(GameTime time, TimeSpan passedInGame, float speedMultiplier)
Parameters
time
GameTimeThe game's time
passedInGame
TimeSpanThe amount of time passed in game time
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
CanCancel(Action)
Returns whether or not this action can be canceled by the given outside source.
Note that the outside source can be null, and if it is, it means that the player canceled the action manually.
By default, actions can only be canceled if the cancelSource
is null.
public override bool CanCancel(Action cancelSource)
Parameters
cancelSource
ActionThe source of the cancelation, or null if the player canceled it
Returns
- bool
true if the action can be canceled
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
ActionThe action to multi-task with
Returns
- bool
Whether this action can be multi-tasked
CanStartNow()
Return true on this method if this action can be started right now. This method is queried when this action moves from a person's ActionQueue to their CurrentActions. If this method returns false, it stays in the ActionQueue.
By default, MultiAction overrides this behavior to only allow the action to be started if the Person is not being held, and not currently occupying an action spot that has the Stay
flag set.
public override bool CanStartNow()
Returns
- bool
Whether this action can start now.
CreateAskOffer(string, ObjectCategory, Type, CanExecuteDelegate, CanExecuteDelegate, AiSettings?, AiSettings?, CanExecuteResult?)
Creates and returns a set of ActionType.TypeSettings instances that contains an "Ask" action, as well as an "Offer" action, for a specific Action class. The returned ActionType.TypeSettings have an additional bool entry in their ConstructorArguments that determines whether the action was started from the offering party, rather than the asking party. It can be evaluated using IsHelper(bool) and related methods.
The returned ActionType.TypeSettings also automatically include an ActionArgument evaluator that displays a list of potential action partners if no action partner was immediately selected through the context
.
This means that the constructedType
's constructor should accept the usual ActionType and ActionInfo, but also the wasOffered
bool and the (optional) PersonLike passed from the ActionArgument.
public static IEnumerable<ActionType.TypeSettings> CreateAskOffer(string name, ObjectCategory context, Type constructedType, ActionType.CanExecuteDelegate canRecipientExecute, ActionType.CanExecuteDelegate canHelperExecute, ActionType.AiSettings? askAi = null, ActionType.AiSettings? offerAi = null, CanExecuteResult? noValidArgumentsResult = null)
Parameters
name
stringThe base action name, which has "Ask" and "Offer" appended to it automatically.
context
ObjectCategoryThe context.
constructedType
TypeThe constructed action type.
canRecipientExecute
ActionType.CanExecuteDelegateA 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.CanExecuteDelegateA 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.
noValidArgumentsResult
CanExecuteResult?A CanExecuteResult that is used when no free people are found.
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
EnqueuePartnerAction(ActionInfo)
A method that is called to enqueue the action that the Partner should execute. The returned action will have its IsMain value set to false, as well as its PartnerAction linked to this action's Id and vice versa. By default, this causes this action's Type to be enqueued using EnqueueAction<T>(ActionType, ActionInfo, bool, bool, bool, params ActionArgument[]).
protected virtual SocialAction EnqueuePartnerAction(ActionInfo info)
Parameters
info
ActionInfoThe action info to use.
Returns
- SocialAction
The action that was enqueued for the Partner.
GetDisplayName()
Returns a localized string that explains this action in short. By default, this method returns GetDisplayName(ActionInfo, bool).
public override string GetDisplayName()
Returns
- string
This action's display name
GetHelper(bool)
Returns the helper party of this action, based on whether help was offered through this action. This should be used in conjunction with CreateAskOffer(string, ObjectCategory, Type, CanExecuteDelegate, CanExecuteDelegate, AiSettings?, AiSettings?, CanExecuteResult?).
protected PersonLike GetHelper(bool wasOffered)
Parameters
wasOffered
boolWhether help was offered through this action.
Returns
- PersonLike
This action's helper party, which is either PersonLike or Partner.
GetMaxWaitTime()
Returns the amount of time that the action PersonLike should wait next to the person they want to talk to before the action is canceled. By default, this returns 30 minutes for an action that was StartedAutomatically, and 2 hours for a manual action.
protected virtual TimeSpan GetMaxWaitTime()
Returns
- TimeSpan
The amount of time until this action is canceled.
GetPartnerArguments(ActionInfo)
A method that is called in EnqueuePartnerAction(ActionInfo) that determines what ActionArgument should be used. By default, null is returned.
protected virtual IEnumerable<ActionArgument> GetPartnerArguments(ActionInfo info)
Parameters
info
ActionInfoThe action info to use.
Returns
- IEnumerable<ActionArgument>
The ActionArgument to use for the partner action.
GetRecipientAction(bool)
Returns the recipient action of this action, based on whether help was offered through this action. This should be used in conjunction with CreateAskOffer(string, ObjectCategory, Type, CanExecuteDelegate, CanExecuteDelegate, AiSettings?, AiSettings?, CanExecuteResult?).
protected SocialAction GetRecipientAction(bool wasOffered)
Parameters
wasOffered
boolWhether help was offered through this action.
Returns
- SocialAction
This action's recipient action, which is either PartnerAction or this.
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 virtual void InitializeConversation()
InvokeForBoth(Action<PersonLike, PersonLike>)
Invokes the given action for both the PersonLike and the Partner using InvokeForBoth(PersonLike, PersonLike, Action<PersonLike, PersonLike>).
public void InvokeForBoth(Action<PersonLike, PersonLike> action)
Parameters
action
Action<PersonLike, PersonLike>The action to invoke for both people of this conversation
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 abstract CompletionType IsConversationCompleted()
Returns
- CompletionType
Whether this conversation is completed
IsHelper(bool)
Returns whether this action is the helper action, based on whether help was offered through this action. This should be used in conjunction with CreateAskOffer(string, ObjectCategory, Type, CanExecuteDelegate, CanExecuteDelegate, AiSettings?, AiSettings?, CanExecuteResult?).
protected bool IsHelper(bool wasOffered)
Parameters
wasOffered
boolWhether help was offered through this action.
Returns
- bool
Whether this action is the helper action.
OnBothCompleted(CompletionType)
A method that is called when both actions (this action and the PartnerAction) have been completed. This method is called for both partners in AndThenOnCompleted(CompletionType) before either partner has cleared the action from their queue.
protected virtual void OnBothCompleted(CompletionType type)
Parameters
type
CompletionTypeThe completion type.
TryForceResult(CompletionType, CanExecuteResult?, MapObject)
This is an external version of ForceResult which can be called from outside sources, like a BreakableFurniture object. A reason is provided that can be used to decide whether the external object can cause this action to fail. By default, this action sets ForceResult to true and returns true if IgnoreObjectConditions doesn't return true.
public override bool TryForceResult(CompletionType result, CanExecuteResult? reason = null, MapObject source = null)
Parameters
result
CompletionTypeThe result to force.
reason
CanExecuteResult?The reason for this action to fail. Can be null.
source
MapObjectThe object that is trying to force this action to fail. Can be null.
Returns
- bool
Whether this action was successfully forced to fail (if returning true, ForceResult should also be set to true).
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 virtual void UpdateConversation(GameTime time, TimeSpan passedInGame, float speedMultiplier)