generated from AriasCreations/vsmodtemplate
#5: Add debug to player sleeping percentage
This commit is contained in:
parent
4c585f647e
commit
e56a123cb8
4 changed files with 26 additions and 10 deletions
|
@ -7,6 +7,7 @@ using Vintagestory.API.Config;
|
||||||
using Vintagestory.API.MathTools;
|
using Vintagestory.API.MathTools;
|
||||||
using Vintagestory.API.Server;
|
using Vintagestory.API.Server;
|
||||||
using Vintagestory.API.Util;
|
using Vintagestory.API.Util;
|
||||||
|
using Vintagestory.GameContent;
|
||||||
|
|
||||||
namespace AriasServerUtils
|
namespace AriasServerUtils
|
||||||
{
|
{
|
||||||
|
@ -577,5 +578,15 @@ namespace AriasServerUtils
|
||||||
}
|
}
|
||||||
return TextCommandResult.Success(sReturn);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,10 +24,11 @@ public class ASUModClient : ModSystem
|
||||||
{
|
{
|
||||||
// Time acceleration handler
|
// Time acceleration handler
|
||||||
accel = packet.Sleeping;
|
accel = packet.Sleeping;
|
||||||
|
CAPI.Logger.Notification("Time acceleration: " + packet.Sleeping);
|
||||||
|
|
||||||
if (accel)
|
if (accel)
|
||||||
{
|
{
|
||||||
CAPI.World.Calendar.SetTimeSpeedModifier("asu_psp", 500);
|
CAPI.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000);
|
||||||
}
|
}
|
||||||
else CAPI.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
|
else CAPI.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ namespace AriasServerUtils
|
||||||
.HandleWith(Events.HandleASU)
|
.HandleWith(Events.HandleASU)
|
||||||
.WithDescription("Lists all Aria's Server Utils commands")
|
.WithDescription("Lists all Aria's Server Utils commands")
|
||||||
.EndSubCommand()
|
.EndSubCommand()
|
||||||
/*.BeginSubCommand("test")
|
.BeginSubCommand("test")
|
||||||
.RequiresPlayer()
|
.RequiresPlayer()
|
||||||
.RequiresPrivilege(Privilege.controlserver)
|
.RequiresPrivilege(Privilege.controlserver)
|
||||||
.BeginSubCommand("sleep")
|
.BeginSubCommand("sleep")
|
||||||
|
@ -246,12 +246,7 @@ namespace AriasServerUtils
|
||||||
.RequiresPrivilege(Privilege.controlserver)
|
.RequiresPrivilege(Privilege.controlserver)
|
||||||
.HandleWith(TestSleep)
|
.HandleWith(TestSleep)
|
||||||
.EndSubCommand()
|
.EndSubCommand()
|
||||||
.BeginSubCommand("calendarspeed")
|
.EndSubCommand();
|
||||||
.RequiresPlayer()
|
|
||||||
.RequiresPrivilege(Privilege.controlserver)
|
|
||||||
.HandleWith(TestCalendarSpeed)
|
|
||||||
.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("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);
|
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("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("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)
|
private TextCommandResult TestSleep(TextCommandCallingArgs args)
|
||||||
{
|
{
|
||||||
// Initiate the sleep process
|
// Initiate the sleep process
|
||||||
// Basically run all the same commands as we would on a player in bed
|
// Basically run all the same commands as we would on a player in bed
|
||||||
|
Events.HandleSleepyDebug(args);
|
||||||
|
|
||||||
OriginalSpeed = API.World.Calendar.CalendarSpeedMul;
|
OriginalSpeed = API.World.Calendar.CalendarSpeedMul;
|
||||||
if (args.Caller.Player is IServerPlayer isp)
|
if (args.Caller.Player is IServerPlayer isp)
|
||||||
{
|
{
|
||||||
|
@ -361,6 +360,8 @@ namespace AriasServerUtils
|
||||||
});
|
});
|
||||||
|
|
||||||
API.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
|
API.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
|
||||||
|
|
||||||
|
API.Logger.Notification("Stopping PSP Time Acceleration");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -422,6 +423,9 @@ namespace AriasServerUtils
|
||||||
EntityBehaviorTiredness EBT = bed.MountedBy.GetBehavior<EntityBehaviorTiredness>();
|
EntityBehaviorTiredness EBT = bed.MountedBy.GetBehavior<EntityBehaviorTiredness>();
|
||||||
|
|
||||||
EBT.IsSleeping = true;
|
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.
|
bed.MountedBy.TryUnmount(); // Stand up. We cant trigger the real sleep phase, but all code for starting time accel has been executed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"modid": "ariasserverutils",
|
"modid": "ariasserverutils",
|
||||||
"name": "Aria's Server Utilities",
|
"name": "Aria's Server Utilities",
|
||||||
"authors": ["zontreck"],
|
"authors": ["zontreck"],
|
||||||
"description": "A collection of server utilities\n\nBuild Date: 05-3-2025 @ 12:40 PM MST",
|
"description": "A collection of server utilities\n\nBuild Date: 05-3-2025 @ 12:53 PM MST",
|
||||||
"version": "1.0.10-dev.2",
|
"version": "1.0.10-dev.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"game": ""
|
"game": ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue