SocialAction - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life


SocialAction Class

A social action is an action that involves two Person 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 : TinyLife.Actions.Action

Inheritance System.Object 🡒 MLEM.Misc.GenericDataHolder 🡒 Action 🡒 SocialAction



SocialAction.SocialAction(ActionType, ActionInfo) Constructor

Creates a new action from the given ActionType

public SocialAction(TinyLife.Actions.ActionType type, TinyLife.Actions.ActionInfo info);


type ActionType
The type to create this action from

info ActionInfo
The information for this action


SocialAction.PartnerCompletion Field

The current completion type of the Partner's action.
If this is not set, the partner completion is irrelevant for this action's completion behavior.

protected Nullable<CompletionType> PartnerCompletion;

Field Value



SocialAction.ConversationTime Property

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 IsMainPerson to reach the Partner.

public System.TimeSpan ConversationTime { get; set; }

Property Value


SocialAction.Id Property

The internal id of this action

protected System.Guid Id { get; set; }

Property Value


SocialAction.IsMain Property

Whether or not this is the action that started the social interaction
The PartnerAction will always have the inverse value of this value.

public bool IsMain { get; set; }

Property Value


SocialAction.Partner Property

The Person that we're interacting with

public TinyLife.Objects.Person Partner { get; }

Property Value


SocialAction.PartnerAction Property

The SocialAction that the Partner of this action instantiated as part of the interaction

public TinyLife.Actions.SocialAction PartnerAction { get; }

Property Value



SocialAction.CanCancel(Action) Method

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(TinyLife.Actions.Action cancelSource);


cancelSource Action
The source of the cancelation, or null if the player canceled it


true if the action can be canceled

SocialAction.CanMultitask(Action) Method

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(TinyLife.Actions.Action other);


other Action
The action to multi-task with


Whether this action can be multi-tasked

SocialAction.GetDisplayName() Method

Returns a localized string that explains this action in short.
By default, this method returns GetDisplayName(ActionInfo, bool).

public override string GetDisplayName();


This action's display name

SocialAction.GetInProgressTime() Method

Returns 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 System.TimeSpan GetInProgressTime();


The amount of time that this action has properly been in progress for

SocialAction.GetTimeWeWaitForPartner() Method

Returns the amount of time that the Person should wait for their Partner for before the interaction is canceled.
By default, this method returns 30 minutes if the PartnerIsCloseForTalking(Vector2), and 15 minutes otherwise.

protected virtual System.TimeSpan GetTimeWeWaitForPartner();


The amount of in-game time that this person should wait for their partner

SocialAction.Initialize() Method

This method is called when the action is first started by a Person.
Note that it is not called when the action gets added to the ActionQueue, but when it is moved to CurrentActions.

public override void Initialize();

SocialAction.InitializeConversation() Method

SocialAction version of Initialize().
This method is called when the conversation part of this action first starts.
By default, this method does nothing.

protected virtual void InitializeConversation();

SocialAction.InvokeForBoth(Action<Person,Person>) Method

Invokes the given action for both the Person and the Partner, passing both of them in the following way:

action(Person, Partner);  
action(Partner, Person);  
public void InvokeForBoth(System.Action<TinyLife.Objects.Person,TinyLife.Objects.Person> action);


action System.Action<Person,Person>
The action to invoke for both people of this conversation

SocialAction.IsCompleted() Method

This method is called every update frame by a Person if this action is currently active to check if it should be stopped.
If this returns a result other than Completed, OnCompleted(CompletionType) will be called and the action is stopped.
By default, only ForceFail modifies the completion type, otherwise Active is returned.

public sealed override TinyLife.Actions.Action.CompletionType IsCompleted();


The current completion type of this action

SocialAction.IsConversationCompleted() Method

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

protected virtual TinyLife.Actions.Action.CompletionType IsConversationCompleted();


Whether or not this conversation is completed

SocialAction.OnCompleted(CompletionType) Method

This method is called when this action IsCompleted(), or if it is canceled from an outside source.
Note that, if this method is called as a result of IsCompleted(), the CompletionType passed will be the same.

public override void OnCompleted(TinyLife.Actions.Action.CompletionType type);


type CompletionType
The type that this action completed with

SocialAction.SpeakInConversation(GameTime, GameSpeed, EmoteCategory, SpeakStyle, Nullable<EmoteCategory>, Nullable<SpeakStyle>, int) Method

Helper method to display emotes over each conversation partner in a back and forth fashion to make it seem like they are conversing

protected bool SpeakInConversation(Microsoft.Xna.Framework.GameTime time, TinyLife.GameSpeed speed, TinyLife.Actions.EmoteCategory emoteCategories, TinyLife.Objects.SpeakStyle speakStyles, System.Nullable<TinyLife.Actions.EmoteCategory> partnerEmoteCategories=null, System.Nullable<TinyLife.Objects.SpeakStyle> partnerSpeakStyles=null, int totalAmount=int.MaxValue);


time Microsoft.Xna.Framework.GameTime
The current game time

speed GameSpeed
The game's current speed

emoteCategories EmoteCategory
A combined flag representing the categories that emotes can be picked from

speakStyles SpeakStyle
The speak styles to use for speech sounds, can be a combined flag

partnerEmoteCategories System.Nullable<EmoteCategory>
The emote categories for the interaction partner to use, or null to use emoteCategories

partnerSpeakStyles System.Nullable<SpeakStyle>
The speak styles for the interaction partner to use, or null to use speakStyles

totalAmount System.Int32
The total amount of emotes that should be shown (not per person, but in total)


If totalAmount is set, true is returned if the emote back-and-forth is completed

SocialAction.Update(GameTime, TimeSpan, GameSpeed) Method

This method is called every update frame if this action is currently active.
By default, only the ElapsedTime is modified in this method and ActionUpdate(Action, GameTime, TimeSpan, GameSpeed, bool) is called.

public override void Update(Microsoft.Xna.Framework.GameTime time, System.TimeSpan passedInGame, TinyLife.GameSpeed speed);


time Microsoft.Xna.Framework.GameTime
The current game time

passedInGame System.TimeSpan
The amount of time that has passed, in game time

speed GameSpeed
The game's current speed setting

SocialAction.UpdateConversation(GameTime, TimeSpan, GameSpeed) Method

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

protected virtual void UpdateConversation(Microsoft.Xna.Framework.GameTime time, System.TimeSpan passedInGame, TinyLife.GameSpeed speed);


time Microsoft.Xna.Framework.GameTime
The game's time

passedInGame System.TimeSpan
The amount of time passed in game time

speed GameSpeed
The current game speed

SocialAction.Validate(Person) Method

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(TinyLife.Objects.Person person);


person Person
The person that this action belongs to


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