Class TimbnNpcDay
A person's day for the plugin's Npcs.Schedule, made of blocks that each start at a time of day. A block's intro runs once when it starts on time and its loop repeats until the next block starts. A block joined late, after a load, a sleep or a jump of the clock, runs its join late steps in place of the intro. A new block waits for a trip picked by Decide to end. The person stops for a conversation or a story scene, and when the game moves them itself the day leaves them to it until a later block starts. A plugin's RunSteps(TimbnNpcSteps, Action?) on them takes over until it ends, and then the day joins the block of the moment late. Shut a vendor's trade window with the plugin's Npcs.CloseTradeWhen.
public sealed class TimbnNpcDay
- Inheritance
-
TimbnNpcDay
- Inherited Members
Examples
var day = new TimbnNpcDay()
.Block("working", 0.25f, block => block
.Origin("RT_herm_spawn")
.Intro(steps => steps.FireEvent(TimbnGameIds.NpcEvents.Herm.GoToSpawn))
.LateIntro(steps => steps.FireEvent(TimbnGameIds.NpcEvents.Herm.TpToSpawn))
.Loop(steps => steps.WaitGameMinutes(10, 30).Decide(PickTrip)))
.Block("night", 0.85f, block => block
.Intro(steps => steps.FireEvent(TimbnGameIds.NpcEvents.Herm.GoHome))
.LateIntro(steps => steps.FireEvent(TimbnGameIds.NpcEvents.Herm.TpToSpot)));
Npcs.Schedule(TimbnGameIds.Npcs.Herm, day);
Methods
Block(string, float, Action<TimbnNpcBlock>)
Adds a block to the day.
public TimbnNpcDay Block(string name, float start, Action<TimbnNpcBlock> build)
Parameters
namestringA name for the status and the log, such as working.
startfloatWhen it starts, as a time of day from 0 at midnight, 0.25 at dawn, 0.5 at noon to 0.75 at dusk.
buildAction<TimbnNpcBlock>Fills in the block's intro, join late steps and loop.
Returns
Doorway(string, string, TimbnWalk)
Makes every walk that sets off from a point go by another point first, and every walk heading to it come by that point last, such as a home point behind a counter. The hop between the two is over the navmesh unless another walk is given.
public TimbnNpcDay Doorway(string pointId, string viaId, TimbnWalk walk = TimbnWalk.Navmesh)
Parameters
pointIdstringThe point, such as a home point.
viaIdstringThe point every walk to or from it passes.
walkTimbnWalkHow to cross between the two.
Returns
Examples
day.Doorway("RT_tavern_owner_spawn", "village_letter_owner_spawn", TimbnWalk.Straight);
LogSteps(Func<bool>?)
Writes every step, walk, claim and skip to the plugin's log at the debug level, each line starting with the game day and time. Pass a check to log only while it holds, such as a hidden setting, since it is asked each time.
public TimbnNpcDay LogSteps(Func<bool>? when = null)
Parameters
Returns
Examples
.LogSteps(() => PluginConfig.WriteDebugLog.Value)
OnlyWhile(Func<bool>)
Runs the day only while a check is true, such as once a quest is done. While it is false the person is left alone, and when it turns true the block of the moment is joined late.
public TimbnNpcDay OnlyWhile(Func<bool> condition)
Parameters
Returns
Examples
day.OnlyWhile(() => TimbnQuests.StatusOf("29_port_linda_meet") == QuestStatus.Completed);
ResumeWhenAt(string)
After the game moved the person itself, the day carries on at a later block start only while they stand on this point, such as their home point. Without it the day carries on at the next block start wherever they are.
public TimbnNpcDay ResumeWhenAt(string pointId)
Parameters
pointIdstring
Returns
StartWhenAt(string)
Starts the day in a save only once the person stands on this point, such as their spawn point, so someone the story keeps somewhere else is left alone until the story brings them there. Once the day started it is not checked again until the save closes or the day's check turns false.
public TimbnNpcDay StartWhenAt(string pointId)
Parameters
pointIdstringThe point the person must stand on, such as RT_larry_spawn.
Returns
Examples
day.StartWhenAt("RT_larry_spawn");