Skip to content

Commit e5a58b2

Browse files
authored
Merge pull request KaBooMa#52 from HazDS/haz/NPCSitFix
2 parents 54cc2d8 + 4085da9 commit e5a58b2

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

S1API/Entities/NPCPrefabBuilder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ private void PrecreateActionsForSpecs(List<IScheduleActionSpec> specs)
867867

868868
var mgr = EnsureScheduleManager();
869869

870-
int walkTo = 0, stayInBuilding = 0, locationDialogue = 0, locationBasedAction = 0, useVending = 0, driveToCarPark = 0, dealSignal = 0, useATM = 0;
870+
int walkTo = 0, stayInBuilding = 0, locationDialogue = 0, locationBasedAction = 0, useVending = 0, driveToCarPark = 0, dealSignal = 0, useATM = 0, sit = 0;
871871
bool requiresSmokeBreak = false, requiresGraffiti = false, requiresDrinking = false, requiresHoldItem = false;
872872
for (int i = 0; i < specs.Count; i++)
873873
{
@@ -898,6 +898,7 @@ private void PrecreateActionsForSpecs(List<IScheduleActionSpec> specs)
898898
else if (s is DriveToCarParkSpec) driveToCarPark++;
899899
else if (s is EnsureDealSignalSpec) dealSignal = Math.Max(dealSignal, 1);
900900
else if (s is UseATMSpec) useATM++;
901+
else if (s is SitSpec) sit++;
901902
}
902903

903904
if (requiresSmokeBreak)
@@ -937,6 +938,7 @@ private void PrecreateActionsForSpecs(List<IScheduleActionSpec> specs)
937938
EnsurePrefabAction<S1NPCsSchedules.NPCSignal_UseVendingMachine>(useVending, "UseVending");
938939
EnsurePrefabAction<S1NPCsSchedules.NPCSignal_DriveToCarPark>(driveToCarPark, "DriveToCarPark");
939940
EnsurePrefabAction<S1NPCsSchedules.NPCSignal_UseATM>(useATM, "UseATM");
941+
EnsurePrefabAction<S1NPCsSchedules.NPCEvent_Sit>(sit, "Sit");
940942
}
941943

942944
private void EnsurePrefabAction<T>(int count, string namePrefix) where T : S1NPCsSchedules.NPCAction

S1API/Entities/Schedule/ActionSpecs/SitSpec.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ namespace S1API.Entities.Schedule
2626
public sealed class SitSpec : IScheduleActionSpec
2727
{
2828
/// <summary>
29-
/// Gets or sets the start time for this action, in minutes from midnight.
29+
/// Gets or sets the start time for this action, in 24-hour time (e.g. 830 for 8:30 AM).
3030
/// </summary>
3131
public int StartTime { get; set; }
3232

33+
/// <summary>
34+
/// Gets or sets the duration of the sit action in minutes.
35+
/// If not set (0 or negative), defaults to the time remaining until the next scheduled action.
36+
/// </summary>
37+
public int DurationMinutes { get; set; }
38+
3339
/// <summary>
3440
/// Gets or sets the optional display name for this action. Defaults to "Sit".
3541
/// </summary>
@@ -98,6 +104,7 @@ void IScheduleActionSpec.ApplyTo(NPCSchedule schedule)
98104
}
99105

100106
action.WarpIfSkipped = WarpIfSkipped;
107+
action.Duration = DurationMinutes > 0 ? DurationMinutes : 60;
101108
}
102109

103110
private S1AvatarAnimation.AvatarSeatSet ResolveSeatSet(NPCSchedule schedule)

S1API/Entities/Schedule/NPCScheduleBuilder.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public PrefabScheduleBuilder WalkTo(UnityEngine.Vector3 destination, int startTi
6464
/// Adds a seating action that moves the NPC to an available seat within the specified seat set.
6565
/// </summary>
6666
/// <param name="seatSetName">The GameObject name of the <c>AvatarSeatSet</c> to use.</param>
67-
/// <param name="startTime">The time when this action should start, in minutes from midnight (0-1439).</param>
67+
/// <param name="startTime">The time when this action should start, in 24-hour time (e.g. 830 for 8:30 AM).</param>
68+
/// <param name="durationMinutes">Duration of the sit action in minutes. Defaults to 60.</param>
6869
/// <param name="warpIfSkipped">Whether the NPC should be warped to the seat if the action is skipped. Default is <c>false</c>.</param>
6970
/// <param name="name">Optional custom name for this action; defaults to "Sit".</param>
7071
/// <returns>This builder instance for method chaining.</returns>
@@ -73,14 +74,15 @@ public PrefabScheduleBuilder WalkTo(UnityEngine.Vector3 destination, int startTi
7374
/// lookup scenarios (GUIDs, transform paths, direct references) instantiate <see cref="SitSpec"/> manually and
7475
/// add it via <see cref="Add(IScheduleActionSpec)"/>.
7576
/// </remarks>
76-
public PrefabScheduleBuilder SitAtSeatSet(string seatSetName, int startTime, bool warpIfSkipped = false, string name = null)
77+
public PrefabScheduleBuilder SitAtSeatSet(string seatSetName, int startTime, int durationMinutes = 60, bool warpIfSkipped = false, string name = null)
7778
{
7879
if (!string.IsNullOrEmpty(seatSetName))
7980
{
8081
_specs.Add(new SitSpec
8182
{
8283
SeatSetName = seatSetName,
8384
StartTime = startTime,
85+
DurationMinutes = durationMinutes,
8486
WarpIfSkipped = warpIfSkipped,
8587
Name = name
8688
});

0 commit comments

Comments
 (0)