#5: Add debug to player sleeping percentage

This commit is contained in:
zontreck 2025-05-03 12:53:44 -07:00
parent 4c585f647e
commit e56a123cb8
4 changed files with 26 additions and 10 deletions

View file

@ -7,6 +7,7 @@ using Vintagestory.API.Config;
using Vintagestory.API.MathTools;
using Vintagestory.API.Server;
using Vintagestory.API.Util;
using Vintagestory.GameContent;
namespace AriasServerUtils
{
@ -577,5 +578,15 @@ namespace AriasServerUtils
}
return TextCommandResult.Success(sReturn);
}
internal static TextCommandResult HandleSleepyDebug(TextCommandCallingArgs args)
{
EntityBehaviorTiredness sleepy = args.Caller.Entity.GetBehavior<EntityBehaviorTiredness>();
if (sleepy != null)
{
sleepy.Tiredness = 100;
}
return TextCommandResult.Success();
}
}
}

View file

@ -24,10 +24,11 @@ public class ASUModClient : ModSystem
{
// Time acceleration handler
accel = packet.Sleeping;
CAPI.Logger.Notification("Time acceleration: " + packet.Sleeping);
if (accel)
{
CAPI.World.Calendar.SetTimeSpeedModifier("asu_psp", 500);
CAPI.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000);
}
else CAPI.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
}

View file

@ -238,7 +238,7 @@ namespace AriasServerUtils
.HandleWith(Events.HandleASU)
.WithDescription("Lists all Aria's Server Utils commands")
.EndSubCommand()
/*.BeginSubCommand("test")
.BeginSubCommand("test")
.RequiresPlayer()
.RequiresPrivilege(Privilege.controlserver)
.BeginSubCommand("sleep")
@ -246,12 +246,7 @@ namespace AriasServerUtils
.RequiresPrivilege(Privilege.controlserver)
.HandleWith(TestSleep)
.EndSubCommand()
.BeginSubCommand("calendarspeed")
.RequiresPlayer()
.RequiresPrivilege(Privilege.controlserver)
.HandleWith(TestCalendarSpeed)
.EndSubCommand()
.EndSubCommand()*/ ;
.EndSubCommand();
api.ChatCommands.Create("setwarp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Creates a new server warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarpUpdate);
api.ChatCommands.Create("warp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Warp to the specified server warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarp);
@ -263,12 +258,16 @@ namespace AriasServerUtils
api.ChatCommands.Create("rtp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithArgs(parsers.OptionalInt("maxDist", defaultValue: -1)).WithDescription("Seeks a position possibly thousands of blocks away to teleport to.").HandleWith(Events.HandleRTP);
api.ChatCommands.Create("listcooldowns").RequiresPrivilege(Privilege.chat).WithDescription("Lists the cooldown settings on the server, as well as your own active cooldowns if applicable.").HandleWith(Events.HandleListCooldowns);
api.ChatCommands.Create("debugasu_sleepy").RequiresPlayer().RequiresPrivilege(Privilege.controlserver).WithDescription("Debugging command to test the sleeping system").HandleWith(Events.HandleSleepyDebug);
}
private TextCommandResult TestSleep(TextCommandCallingArgs args)
{
// Initiate the sleep process
// Basically run all the same commands as we would on a player in bed
Events.HandleSleepyDebug(args);
OriginalSpeed = API.World.Calendar.CalendarSpeedMul;
if (args.Caller.Player is IServerPlayer isp)
{
@ -361,6 +360,8 @@ namespace AriasServerUtils
});
API.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
API.Logger.Notification("Stopping PSP Time Acceleration");
}
return;
}
@ -422,6 +423,9 @@ namespace AriasServerUtils
EntityBehaviorTiredness EBT = bed.MountedBy.GetBehavior<EntityBehaviorTiredness>();
EBT.IsSleeping = true;
API.Logger.Notification("Starting PSP Time Acceleration");
bed.MountedBy.TryUnmount(); // Stand up. We cant trigger the real sleep phase, but all code for starting time accel has been executed.
}

View file

@ -3,8 +3,8 @@
"modid": "ariasserverutils",
"name": "Aria's Server Utilities",
"authors": ["zontreck"],
"description": "A collection of server utilities\n\nBuild Date: 05-3-2025 @ 12:40 PM MST",
"version": "1.0.10-dev.2",
"description": "A collection of server utilities\n\nBuild Date: 05-3-2025 @ 12:53 PM MST",
"version": "1.0.10-dev.3",
"dependencies": {
"game": ""
}