generated from AriasCreations/vsmodtemplate
parent
e56a123cb8
commit
12d10a9a3c
4 changed files with 8 additions and 58 deletions
|
@ -15,21 +15,5 @@ public class ASUModClient : ModSystem
|
||||||
public override void StartClientSide(ICoreClientAPI api)
|
public override void StartClientSide(ICoreClientAPI api)
|
||||||
{
|
{
|
||||||
CAPI = api;
|
CAPI = api;
|
||||||
api.Network.RegisterChannel("asutimeaccel")
|
|
||||||
.RegisterMessageType<ASUTimeAcceleration>()
|
|
||||||
.SetMessageHandler<ASUTimeAcceleration>(onReceiveTimeAccel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onReceiveTimeAccel(ASUTimeAcceleration packet)
|
|
||||||
{
|
|
||||||
// Time acceleration handler
|
|
||||||
accel = packet.Sleeping;
|
|
||||||
CAPI.Logger.Notification("Time acceleration: " + packet.Sleeping);
|
|
||||||
|
|
||||||
if (accel)
|
|
||||||
{
|
|
||||||
CAPI.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000);
|
|
||||||
}
|
|
||||||
else CAPI.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -96,10 +96,6 @@ namespace AriasServerUtils
|
||||||
//api.Event.PlayerLeave += OnPlayerDC;
|
//api.Event.PlayerLeave += OnPlayerDC;
|
||||||
|
|
||||||
|
|
||||||
ServerNetworkChannel = api.Network.RegisterChannel("asutimeaccel")
|
|
||||||
.RegisterMessageType<ASUTimeAcceleration>();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
api.ChatCommands.Create("setspawn").RequiresPrivilege(Privilege.controlserver).HandleWith(Events.HandleSetSpawn);
|
api.ChatCommands.Create("setspawn").RequiresPrivilege(Privilege.controlserver).HandleWith(Events.HandleSetSpawn);
|
||||||
api.ChatCommands.Create("spawn").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSpawn);
|
api.ChatCommands.Create("spawn").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSpawn);
|
||||||
|
@ -273,18 +269,15 @@ namespace AriasServerUtils
|
||||||
{
|
{
|
||||||
Hours = API.World.Calendar.TotalHours;
|
Hours = API.World.Calendar.TotalHours;
|
||||||
SleepingPlayers.Add(isp.Entity);
|
SleepingPlayers.Add(isp.Entity);
|
||||||
|
API.Logger.Notification($"Game Hours: {API.World.Calendar.TotalHours}, Difference: {API.World.Calendar.TotalHours - Hours}");
|
||||||
EntityAgent Agent = isp.Entity;
|
EntityAgent Agent = isp.Entity;
|
||||||
EntityBehaviorTiredness ebt = Agent.GetBehavior("tiredness") as EntityBehaviorTiredness;
|
|
||||||
|
EntityBehaviorTiredness ebt = Agent.GetBehavior<EntityBehaviorTiredness>();
|
||||||
|
|
||||||
ebt.IsSleeping = true;
|
ebt.IsSleeping = true;
|
||||||
ebt.Tiredness = 100;
|
ebt.Tiredness = 100;
|
||||||
Sleeping = true;
|
Sleeping = true;
|
||||||
|
|
||||||
|
|
||||||
ServerNetworkChannel.BroadcastPacket(new ASUTimeAcceleration
|
|
||||||
{
|
|
||||||
Sleeping = true
|
|
||||||
});
|
|
||||||
|
|
||||||
API.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000);
|
API.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,11 +300,6 @@ namespace AriasServerUtils
|
||||||
OriginalSpeed = 0.5f;
|
OriginalSpeed = 0.5f;
|
||||||
ebt.IsSleeping = true;
|
ebt.IsSleeping = true;
|
||||||
|
|
||||||
ServerNetworkChannel.BroadcastPacket(new ASUTimeAcceleration
|
|
||||||
{
|
|
||||||
Sleeping = true
|
|
||||||
});
|
|
||||||
|
|
||||||
API.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000);
|
API.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000);
|
||||||
|
|
||||||
SendMessageTo(isp, "Applied calendar speed multiplier");
|
SendMessageTo(isp, "Applied calendar speed multiplier");
|
||||||
|
@ -322,11 +310,6 @@ namespace AriasServerUtils
|
||||||
OriginalSpeed = 0;
|
OriginalSpeed = 0;
|
||||||
ebt.IsSleeping = false;
|
ebt.IsSleeping = false;
|
||||||
|
|
||||||
ServerNetworkChannel.BroadcastPacket(new ASUTimeAcceleration
|
|
||||||
{
|
|
||||||
Sleeping = false
|
|
||||||
});
|
|
||||||
|
|
||||||
API.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
|
API.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
|
||||||
|
|
||||||
SendMessageTo(isp, "Restored default calendar speed");
|
SendMessageTo(isp, "Restored default calendar speed");
|
||||||
|
@ -341,7 +324,8 @@ namespace AriasServerUtils
|
||||||
if (API.Side == EnumAppSide.Client) return; // This must only ever be called on the server!
|
if (API.Side == EnumAppSide.Client) return; // This must only ever be called on the server!
|
||||||
if (Sleeping)
|
if (Sleeping)
|
||||||
{
|
{
|
||||||
if (API.World.Calendar.TotalHours - Hours >= 7)
|
API.Logger.Notification($"Game Hours: {API.World.Calendar.TotalHours}, Difference: {API.World.Calendar.TotalHours - Hours}");
|
||||||
|
if (API.World.Calendar.TotalHours - Hours >= 6)
|
||||||
{
|
{
|
||||||
Sleeping = false;
|
Sleeping = false;
|
||||||
foreach (var player in SleepingPlayers)
|
foreach (var player in SleepingPlayers)
|
||||||
|
@ -353,12 +337,6 @@ namespace AriasServerUtils
|
||||||
|
|
||||||
SleepingPlayers.Clear();
|
SleepingPlayers.Clear();
|
||||||
|
|
||||||
|
|
||||||
ServerNetworkChannel.BroadcastPacket(new ASUTimeAcceleration
|
|
||||||
{
|
|
||||||
Sleeping = false
|
|
||||||
});
|
|
||||||
|
|
||||||
API.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
|
API.World.Calendar.RemoveTimeSpeedModifier("asu_psp");
|
||||||
|
|
||||||
API.Logger.Notification("Stopping PSP Time Acceleration");
|
API.Logger.Notification("Stopping PSP Time Acceleration");
|
||||||
|
@ -407,11 +385,6 @@ namespace AriasServerUtils
|
||||||
if (Percentage >= config.PlayerSleepingPercentage)
|
if (Percentage >= config.PlayerSleepingPercentage)
|
||||||
{
|
{
|
||||||
|
|
||||||
ServerNetworkChannel.BroadcastPacket(new ASUTimeAcceleration
|
|
||||||
{
|
|
||||||
Sleeping = true
|
|
||||||
});
|
|
||||||
|
|
||||||
API.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000);
|
API.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000);
|
||||||
|
|
||||||
// Call the API to make sleep happen
|
// Call the API to make sleep happen
|
||||||
|
|
|
@ -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:53 PM MST",
|
"description": "A collection of server utilities\n\nBuild Date: 05-3-2025 @ 1:56 PM MST",
|
||||||
"version": "1.0.10-dev.3",
|
"version": "1.0.10-dev.9",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"game": ""
|
"game": ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class ASUTimeAcceleration
|
|
||||||
{
|
|
||||||
public bool Sleeping = false;
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue