Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename jobs to routine #586

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/extensions/NeoServer.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ProjectReference Include="..\..\src\ApplicationServer\NeoServer.Server.Commands\NeoServer.Server.Commands.csproj"/>
<ProjectReference Include="..\..\src\ApplicationServer\NeoServer.Server.Contracts\NeoServer.Server.Common.csproj"/>
<ProjectReference Include="..\..\src\ApplicationServer\NeoServer.Server.Events\NeoServer.Server.Events.csproj"/>
<ProjectReference Include="..\..\src\ApplicationServer\NeoServer.Server.Jobs\NeoServer.Server.Jobs.csproj"/>
<ProjectReference Include="..\..\src\ApplicationServer\NeoServer.Server.Routines\NeoServer.Server.Routines.csproj" />
<ProjectReference Include="..\..\src\ApplicationServer\NeoServer.Server\NeoServer.Server.csproj"/>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Linq;
using NeoServer.Game.Common.Contracts.Chats;

namespace NeoServer.Server.Jobs.Channels;
namespace NeoServer.Server.Routines.Channels;

public class ChatUserCleanupJob
public class ChatUserCleanupRoutine
{
public static void Execute(IChatChannel channel)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
using NeoServer.Server.Common.Contracts;
using NeoServer.Server.Tasks;

namespace NeoServer.Server.Jobs.Channels;
namespace NeoServer.Server.Routines.Channels;

public class GameChatChannelJob
public class GameChatChannelRoutine
{
private const ushort EVENT_CHECK_ITEM_INTERVAL = 10000;
private readonly IChatChannelStore _chatChannelStore;
private readonly IGameServer _game;

public GameChatChannelJob(IGameServer game, IChatChannelStore chatChannelStore)
public GameChatChannelRoutine(IGameServer game, IChatChannelStore chatChannelStore)
{
_game = game;
_chatChannelStore = chatChannelStore;
Expand All @@ -20,6 +20,6 @@ public void StartChecking()
{
_game.Scheduler.AddEvent(new SchedulerEvent(EVENT_CHECK_ITEM_INTERVAL, StartChecking));

foreach (var channel in _chatChannelStore.All) ChatUserCleanupJob.Execute(channel);
foreach (var channel in _chatChannelStore.All) ChatUserCleanupRoutine.Execute(channel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using NeoServer.Game.Combat.Conditions;
using NeoServer.Game.Common.Contracts.Creatures;

namespace NeoServer.Server.Jobs.Creatures;
namespace NeoServer.Server.Routines.Creatures;

public static class CreatureConditionJob
public static class CreatureConditionRoutine
{
public static void Execute(ICombatActor creature)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using NeoServer.Server.Common.Contracts;
using NeoServer.Server.Tasks;

namespace NeoServer.Server.Jobs.Creatures;
namespace NeoServer.Server.Routines.Creatures;

public static class CreatureDefenseJob
public static class CreatureDefenseRoutine
{
public static void Execute(IMonster monster, IGameServer game)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
using NeoServer.Game.World.Models.Spawns;
using NeoServer.Server.Commands.Player;
using NeoServer.Server.Common.Contracts;
using NeoServer.Server.Jobs.Creatures.Npc;
using NeoServer.Server.Routines.Creatures.Npc;
using NeoServer.Server.Tasks;

namespace NeoServer.Server.Jobs.Creatures;
namespace NeoServer.Server.Routines.Creatures;

public class GameCreatureJob
public class GameCreatureRoutine
{
private const ushort EVENT_CHECK_CREATURE_INTERVAL = 500;
private readonly IGameServer _game;
private readonly PlayerLogOutCommand _playerLogOutCommand;
private readonly SpawnManager _spawnManager;
private readonly ISummonService _summonService;

public GameCreatureJob(IGameServer game, SpawnManager spawnManager, PlayerLogOutCommand playerLogOutCommand,
public GameCreatureRoutine(IGameServer game, SpawnManager spawnManager, PlayerLogOutCommand playerLogOutCommand,
ISummonService summonService)
{
_game = game;
Expand All @@ -41,34 +41,34 @@ public void StartChecking()

CheckNpc(creature);

RespawnJob.Execute(_spawnManager);
RespawnRoutine.Execute(_spawnManager);
}
}

private static void CheckCreature(ICreature creature)
{
if (creature is ICombatActor combatActor) CreatureConditionJob.Execute(combatActor);
if (creature is ICombatActor combatActor) CreatureConditionRoutine.Execute(combatActor);
}

private static void CheckNpc(ICreature creature)
{
if (creature is INpc npc) NpcJob.Execute(npc);
if (creature is INpc npc) NpcRoutine.Execute(npc);
}

private void CheckMonster(ICreature creature)
{
if (creature is not IMonster monster) return;

CreatureDefenseJob.Execute(monster, _game);
MonsterStateJob.Execute(monster, _summonService);
MonsterYellJob.Execute(monster);
CreatureDefenseRoutine.Execute(monster, _game);
MonsterStateRoutine.Execute(monster, _summonService);
MonsterYellRoutine.Execute(monster);
}

private void CheckPlayer(ICreature creature)
{
if (creature is not IPlayer player) return;

PlayerPingJob.Execute(player, _playerLogOutCommand, _game);
PlayerRecoveryJob.Execute(player);
PlayerPingRoutine.Execute(player, _playerLogOutCommand, _game);
PlayerRecoveryRoutine.Execute(player);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using NeoServer.Game.Common.Contracts.Services;
using NeoServer.Game.Creatures.Monster.Managers;

namespace NeoServer.Server.Jobs.Creatures;
namespace NeoServer.Server.Routines.Creatures;

public static class MonsterStateJob
public static class MonsterStateRoutine
{
public static void Execute(IMonster monster, ISummonService summonService)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using NeoServer.Game.Common.Contracts.Creatures;

namespace NeoServer.Server.Jobs.Creatures;
namespace NeoServer.Server.Routines.Creatures;

public static class MonsterYellJob
public static class MonsterYellRoutine
{
public static void Execute(IMonster monster)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using NeoServer.Game.Common.Contracts.Creatures;

namespace NeoServer.Server.Jobs.Creatures.Npc;
namespace NeoServer.Server.Routines.Creatures.Npc;

public class NpcJob
public class NpcRoutine
{
private static readonly IntervalControl Interval = new(3_000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using NeoServer.Server.Commands.Player;
using NeoServer.Server.Common.Contracts;

namespace NeoServer.Server.Jobs.Creatures;
namespace NeoServer.Server.Routines.Creatures;

public static class PlayerPingJob
public static class PlayerPingRoutine
{
private const int PING_INTERVAL = 5000;
private const int CONNECTION_LOST_INTERVAL = 60000;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using NeoServer.Game.Common.Contracts.Creatures;

namespace NeoServer.Server.Jobs.Creatures;
namespace NeoServer.Server.Routines.Creatures;

public static class PlayerRecoveryJob
public static class PlayerRecoveryRoutine
{
public static void Execute(IPlayer player)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using NeoServer.Game.World.Models.Spawns;

namespace NeoServer.Server.Jobs.Creatures;
namespace NeoServer.Server.Routines.Creatures;

public static class RespawnJob
public static class RespawnRoutine
{
private const int INTERVAL = 10000;
private static long _lastRespawn;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace NeoServer.Server.Jobs;
namespace NeoServer.Server.Routines;

public class IntervalControl
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using NeoServer.Server.Common.Contracts;
using NeoServer.Server.Tasks;

namespace NeoServer.Server.Jobs.Items;
namespace NeoServer.Server.Routines.Items;

public class GameItemJob
public class GameItemRoutine
{
private const ushort EVENT_CHECK_ITEM_INTERVAL = 1000;
private readonly IGameServer _game;

public GameItemJob(IGameServer game)
public GameItemRoutine(IGameServer game)
{
_game = game;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using NeoServer.Game.Common.Contracts.World.Tiles;
using NeoServer.Server.Common.Contracts;

namespace NeoServer.Server.Jobs.Items;
namespace NeoServer.Server.Routines.Items;

public class LiquidPoolJob
public class LiquidPoolRoutine
{
public static void Execute(ILiquid item, IGameServer game)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
using NeoServer.Server.Configurations;
using Serilog;

namespace NeoServer.Server.Jobs.Persistence;
namespace NeoServer.Server.Routines.Persistence;

public class PlayerPersistenceJob
public class PlayerPersistenceRoutine
{
private readonly DepotManager _depotManager;
private readonly IGameServer _gameServer;
Expand All @@ -24,7 +24,7 @@ public class PlayerPersistenceJob

private int _saveInterval;

public PlayerPersistenceJob(IGameServer gameServer, IPlayerRepository playerRepository, ILogger logger,
public PlayerPersistenceRoutine(IGameServer gameServer, IPlayerRepository playerRepository, ILogger logger,
ServerConfiguration serverConfiguration,
IPlayerDepotItemRepository playerDepotItemRepository,
DepotManager depotManager)
Expand Down
4 changes: 2 additions & 2 deletions src/NeoServer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoServer.Loaders", "Loader
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoServer.Game.World", "GameWorldSimulator\NeoServer.Game.World\NeoServer.Game.World.csproj", "{EEE980F3-5916-45FD-9ABA-8F5D078E115C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoServer.Server.Jobs", "ApplicationServer\NeoServer.Server.Jobs\NeoServer.Server.Jobs.csproj", "{966C5E69-B1DF-4594-8C6F-C7F32C02866F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoServer.Server.Routines", "ApplicationServer\NeoServer.Server.Routines\NeoServer.Server.Routines.csproj", "{966C5E69-B1DF-4594-8C6F-C7F32C02866F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoServer.Benchmarks", "..\benchmarks\NeoServer.Benchmarks\NeoServer.Benchmarks.csproj", "{96C4E3BF-842D-4132-9A23-0BA35F2660F2}"
EndProject
Expand Down Expand Up @@ -77,7 +77,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoServer.Loaders.Tests", "
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{41D4D3B5-6FC6-48F5-9D05-EA8C293DB44B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "game world simulator", "game world simulator", "{EB46ABE5-1719-4A52-BACB-A05D6EACCAB5}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{EB46ABE5-1719-4A52-BACB-A05D6EACCAB5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "loaders", "loaders", "{FA691E87-E79B-4778-9996-52077E6802B0}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/NeoServer.IoC/NeoServer.Shared.IoC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ProjectReference Include="..\..\ApplicationServer\NeoServer.Server.Contracts\NeoServer.Server.Common.csproj"/>
<ProjectReference Include="..\..\GameWorldSimulator\NeoServer.Game.Items\NeoServer.Game.Items.csproj"/>
<ProjectReference Include="..\..\GameWorldSimulator\NeoServer.Game.World\NeoServer.Game.World.csproj"/>
<ProjectReference Include="..\..\ApplicationServer\NeoServer.Server.Jobs\NeoServer.Server.Jobs.csproj"/>
<ProjectReference Include="..\..\ApplicationServer\NeoServer.Server.Routines\NeoServer.Server.Routines.csproj" />
<ProjectReference Include="..\..\ApplicationServer\NeoServer.Server\NeoServer.Server.csproj"/>
<ProjectReference Include="..\..\ApplicationServer\NeoServer.Server.Events\NeoServer.Server.Events.csproj"/>
<ProjectReference Include="..\..\GameWorldSimulator\NeoServer.Game.Creatures\NeoServer.Game.Creatures.csproj"/>
Expand Down
16 changes: 8 additions & 8 deletions src/Standalone/IoC/Modules/JobInjection.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Autofac;
using NeoServer.Server.Jobs.Channels;
using NeoServer.Server.Jobs.Creatures;
using NeoServer.Server.Jobs.Items;
using NeoServer.Server.Jobs.Persistence;
using NeoServer.Server.Routines.Channels;
using NeoServer.Server.Routines.Creatures;
using NeoServer.Server.Routines.Items;
using NeoServer.Server.Routines.Persistence;

namespace NeoServer.Server.Standalone.IoC.Modules;

Expand All @@ -11,10 +11,10 @@ public static class JobInjection
public static ContainerBuilder AddJobs(this ContainerBuilder builder)
{
//todo: inherit these jobs from interface and register by implementation
builder.RegisterType<GameCreatureJob>().SingleInstance();
builder.RegisterType<GameItemJob>().SingleInstance();
builder.RegisterType<GameChatChannelJob>().SingleInstance();
builder.RegisterType<PlayerPersistenceJob>().SingleInstance();
builder.RegisterType<GameCreatureRoutine>().SingleInstance();
builder.RegisterType<GameItemRoutine>().SingleInstance();
builder.RegisterType<GameChatChannelRoutine>().SingleInstance();
builder.RegisterType<PlayerPersistenceRoutine>().SingleInstance();
return builder;
}
}
2 changes: 1 addition & 1 deletion src/Standalone/NeoServer.Server.Standalone.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<ProjectReference Include="..\ApplicationServer\NeoServer.Server.Contracts\NeoServer.Server.Common.csproj"/>
<ProjectReference Include="..\GameWorldSimulator\NeoServer.Game.Items\NeoServer.Game.Items.csproj"/>
<ProjectReference Include="..\GameWorldSimulator\NeoServer.Game.World\NeoServer.Game.World.csproj"/>
<ProjectReference Include="..\ApplicationServer\NeoServer.Server.Jobs\NeoServer.Server.Jobs.csproj"/>
<ProjectReference Include="..\ApplicationServer\NeoServer.Server.Routines\NeoServer.Server.Routines.csproj" />
<ProjectReference Include="..\ApplicationServer\NeoServer.Server\NeoServer.Server.csproj"/>
<ProjectReference Include="..\ApplicationServer\NeoServer.Server.Events\NeoServer.Server.Events.csproj"/>
<ProjectReference Include="..\GameWorldSimulator\NeoServer.Game.Creatures\NeoServer.Game.Creatures.csproj"/>
Expand Down
16 changes: 8 additions & 8 deletions src/Standalone/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
using NeoServer.Server.Configurations;
using NeoServer.Server.Events.Subscribers;
using NeoServer.Server.Helpers.Extensions;
using NeoServer.Server.Jobs.Channels;
using NeoServer.Server.Jobs.Creatures;
using NeoServer.Server.Jobs.Items;
using NeoServer.Server.Jobs.Persistence;
using NeoServer.Server.Routines.Channels;
using NeoServer.Server.Routines.Creatures;
using NeoServer.Server.Routines.Items;
using NeoServer.Server.Routines.Persistence;
using NeoServer.Server.Security;
using NeoServer.Server.Standalone.IoC;
using NeoServer.Server.Tasks;
Expand Down Expand Up @@ -99,10 +99,10 @@ public static async Task Main()
scheduler.Start(cancellationToken);
persistenceDispatcher.Start(cancellationToken);

scheduler.AddEvent(new SchedulerEvent(1000, container.Resolve<GameCreatureJob>().StartChecking));
scheduler.AddEvent(new SchedulerEvent(1000, container.Resolve<GameItemJob>().StartChecking));
scheduler.AddEvent(new SchedulerEvent(1000, container.Resolve<GameChatChannelJob>().StartChecking));
container.Resolve<PlayerPersistenceJob>().Start(cancellationToken);
scheduler.AddEvent(new SchedulerEvent(1000, container.Resolve<GameCreatureRoutine>().StartChecking));
scheduler.AddEvent(new SchedulerEvent(1000, container.Resolve<GameItemRoutine>().StartChecking));
scheduler.AddEvent(new SchedulerEvent(1000, container.Resolve<GameChatChannelRoutine>().StartChecking));
container.Resolve<PlayerPersistenceRoutine>().Start(cancellationToken);

container.Resolve<EventSubscriber>().AttachEvents();
container.Resolve<IEnumerable<IStartup>>().ToList().ForEach(x => x.Run());
Expand Down
Loading