Skip to content

Commit

Permalink
Merge pull request #85 from Kaioru/feat/duey-2.0
Browse files Browse the repository at this point in the history
Update Duey to 2.0.0, update templates to use new API
  • Loading branch information
Kaioru authored Oct 11, 2023
2 parents e358a7d + 02998bf commit d240364
Show file tree
Hide file tree
Showing 84 changed files with 813 additions and 934 deletions.
14 changes: 0 additions & 14 deletions Edelstein.sln
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edelstein.Protocol.Gameplay
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edelstein.Common.Gameplay.Login", "src\common\Edelstein.Common.Gameplay.Login\Edelstein.Common.Gameplay.Login.csproj", "{BB78E48F-1B59-4AD2-8863-1C8354260B56}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edelstein.Protocol.Data", "src\protocol\Edelstein.Protocol.Data\Edelstein.Protocol.Data.csproj", "{7C9711DD-B358-49D8-88F4-416362AA0CF3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edelstein.Common.Data.NX", "src\common\Edelstein.Common.Data.NX\Edelstein.Common.Data.NX.csproj", "{42EC73E4-8B41-4753-8F36-DCA17F9C0992}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edelstein.Protocol.Gameplay.Game", "src\protocol\Edelstein.Protocol.Gameplay.Game\Edelstein.Protocol.Gameplay.Game.csproj", "{E5001CBD-3BC5-49CD-B254-257B74A4B427}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edelstein.Common.Gameplay.Game", "src\common\Edelstein.Common.Gameplay.Game\Edelstein.Common.Gameplay.Game.csproj", "{C124BBAE-A5BE-491E-AF7B-C55396F5EC1A}"
Expand Down Expand Up @@ -123,8 +119,6 @@ Global
{5796C1BE-FB3C-48C6-8AEC-DE1573EED8DA} = {52AE6DEF-E54C-47DC-85F3-8AF3C6FCD504}
{02E88548-2855-4264-9A90-1C0BE49B22A6} = {7F8DD283-A64C-40EC-98F2-84FA38716C28}
{BB78E48F-1B59-4AD2-8863-1C8354260B56} = {52AE6DEF-E54C-47DC-85F3-8AF3C6FCD504}
{7C9711DD-B358-49D8-88F4-416362AA0CF3} = {7F8DD283-A64C-40EC-98F2-84FA38716C28}
{42EC73E4-8B41-4753-8F36-DCA17F9C0992} = {52AE6DEF-E54C-47DC-85F3-8AF3C6FCD504}
{E5001CBD-3BC5-49CD-B254-257B74A4B427} = {7F8DD283-A64C-40EC-98F2-84FA38716C28}
{C124BBAE-A5BE-491E-AF7B-C55396F5EC1A} = {52AE6DEF-E54C-47DC-85F3-8AF3C6FCD504}
{9A544A78-841F-4259-9088-0AE637FBA25A} = {7F8DD283-A64C-40EC-98F2-84FA38716C28}
Expand Down Expand Up @@ -205,14 +199,6 @@ Global
{BB78E48F-1B59-4AD2-8863-1C8354260B56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB78E48F-1B59-4AD2-8863-1C8354260B56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB78E48F-1B59-4AD2-8863-1C8354260B56}.Release|Any CPU.Build.0 = Release|Any CPU
{7C9711DD-B358-49D8-88F4-416362AA0CF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C9711DD-B358-49D8-88F4-416362AA0CF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C9711DD-B358-49D8-88F4-416362AA0CF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C9711DD-B358-49D8-88F4-416362AA0CF3}.Release|Any CPU.Build.0 = Release|Any CPU
{42EC73E4-8B41-4753-8F36-DCA17F9C0992}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42EC73E4-8B41-4753-8F36-DCA17F9C0992}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42EC73E4-8B41-4753-8F36-DCA17F9C0992}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42EC73E4-8B41-4753-8F36-DCA17F9C0992}.Release|Any CPU.Build.0 = Release|Any CPU
{E5001CBD-3BC5-49CD-B254-257B74A4B427}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5001CBD-3BC5-49CD-B254-257B74A4B427}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5001CBD-3BC5-49CD-B254-257B74A4B427}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AutoMapper;
using Edelstein.Application.Server.Configs;
using Edelstein.Application.Server.Configs;
using Edelstein.Protocol.Gameplay.Game;
using Edelstein.Protocol.Gameplay.Login;
using Edelstein.Protocol.Gameplay.Shop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<PackageReference Include="Autofac" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Duey.Provider.NX" Version="2.0.0" />
<PackageReference Include="Duey.Provider.WZ" Version="2.0.0" />
<PackageReference Include="Foundatio.JsonNet" Version="10.6.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
Expand All @@ -23,7 +25,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\common\Edelstein.Common.Data.NX\Edelstein.Common.Data.NX.csproj" />
<ProjectReference Include="..\..\common\Edelstein.Common.Database\Edelstein.Common.Database.csproj" />
<ProjectReference Include="..\..\common\Edelstein.Common.Gameplay.Game\Edelstein.Common.Gameplay.Game.csproj" />
<ProjectReference Include="..\..\common\Edelstein.Common.Gameplay.Login\Edelstein.Common.Gameplay.Login.csproj" />
Expand Down
20 changes: 17 additions & 3 deletions src/app/Edelstein.Application.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Autofac.Extensions.DependencyInjection;
using Duey.Abstractions;
using Duey.Provider.NX;
using Duey.Provider.WZ;
using Edelstein.Application.Server;
using Edelstein.Application.Server.Configs;
using Edelstein.Common.Data.NX;
using Edelstein.Common.Database;
using Edelstein.Common.Database.Repositories;
using Edelstein.Common.Scripting.Lua;
Expand All @@ -10,7 +12,6 @@
using Edelstein.Common.Services.Social;
using Edelstein.Common.Utilities.Templates;
using Edelstein.Common.Utilities.Tickers;
using Edelstein.Protocol.Data;
using Edelstein.Protocol.Gameplay.Models.Accounts;
using Edelstein.Protocol.Gameplay.Models.Characters;
using Edelstein.Protocol.Scripting;
Expand Down Expand Up @@ -78,7 +79,20 @@ await Host.CreateDefaultBuilder(args)
p.GetRequiredService<ProgramConfig>().TicksPerSecond
));

services.AddSingleton<IDataManager>(new NXDataManager(ctx.Configuration.GetSection("Data")["Directory"] ?? throw new InvalidOperationException()));
switch (ctx.Configuration.GetSection("Data")["Type"])
{
case "NX":
services.AddSingleton<IDataNamespace>(
new NXNamespace(ctx.Configuration.GetSection("Data")["Directory"] ?? throw new InvalidOperationException())
);
break;
case "WZ":
services.AddSingleton<IDataNamespace>(new WZNamespace(
ctx.Configuration.GetSection("Data")["Directory"] ?? throw new InvalidOperationException(),
ctx.Configuration.GetSection("Data")["Key"] ?? throw new InvalidOperationException()));
break;
}

services.AddSingleton<IScriptEngine>(new LuaScriptEngine(ctx.Configuration.GetSection("Scripts")["Directory"] ?? throw new InvalidOperationException()));
services.AddSingleton(typeof(ITemplateManager<>), typeof(TemplateManager<>));
})
Expand Down

This file was deleted.

39 changes: 0 additions & 39 deletions src/common/Edelstein.Common.Data.NX/NXDataManager.cs

This file was deleted.

44 changes: 0 additions & 44 deletions src/common/Edelstein.Common.Data.NX/NXDataNode.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Edelstein.Protocol.Data;
using Duey.Abstractions;
using Edelstein.Protocol.Gameplay.Game.Continents.Templates;

namespace Edelstein.Common.Gameplay.Game.Continents.Templates;
Expand All @@ -7,32 +7,32 @@ public record ContiMoveTemplate : IContiMoveTemplate
{
public ContiMoveTemplate(
int id,
IDataProperty property,
IDataProperty field,
IDataProperty scheduler,
IDataProperty? genMob,
IDataProperty time
IDataNode node,
IDataNode field,
IDataNode scheduler,
IDataNode? genMob,
IDataNode time
)
{
ID = id;

Name = property.ResolveOrDefault<string>("info") ?? "NO-NAME";
Name = node.ResolveString("info") ?? "NO-NAME";

StartShipMoveFieldID = field.Resolve<int>("startShipMoveFieldID") ?? 999999999;
WaitFieldID = field.Resolve<int>("waitFieldID") ?? 999999999;
MoveFieldID = field.Resolve<int>("moveFieldID") ?? 999999999;
CabinFieldID = field.Resolve<int>("cabinFieldID");
EndFieldID = field.Resolve<int>("endFieldID") ?? 999999999;
EndShipMoveFieldID = field.Resolve<int>("endShipMoveFieldID") ?? 999999999;
StartShipMoveFieldID = field.ResolveInt("startShipMoveFieldID") ?? 999999999;
WaitFieldID = field.ResolveInt("waitFieldID") ?? 999999999;
MoveFieldID = field.ResolveInt("moveFieldID") ?? 999999999;
CabinFieldID = field.ResolveInt("cabinFieldID");
EndFieldID = field.ResolveInt("endFieldID") ?? 999999999;
EndShipMoveFieldID = field.ResolveInt("endShipMoveFieldID") ?? 999999999;

Term = scheduler.Resolve<int>("tTerm") ?? 1;
Delay = scheduler.Resolve<int>("tDelay") ?? 0;
Term = scheduler.ResolveInt("tTerm") ?? 1;
Delay = scheduler.ResolveInt("tDelay") ?? 0;

if (genMob != null) GenMob = new ContiMoveTemplateGenMob(genMob);

Wait = time.Resolve<int>("tWait") ?? 1;
EventEnd = time.Resolve<int>("tEventEnd") ?? 0;
Required = time.Resolve<int>("tRequired") ?? 0;
Wait = time.ResolveInt("tWait") ?? 1;
EventEnd = time.ResolveInt("tEventEnd") ?? 0;
Required = time.ResolveInt("tRequired") ?? 0;
}

public int ID { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using Edelstein.Common.Utilities.Spatial;
using Edelstein.Protocol.Data;
using Duey.Abstractions;
using Edelstein.Common.Utilities.Spatial;
using Edelstein.Protocol.Gameplay.Game.Continents.Templates;
using Edelstein.Protocol.Utilities.Spatial;

namespace Edelstein.Common.Gameplay.Game.Continents.Templates;

public record ContiMoveTemplateGenMob : IContiMoveTemplateGenMob
{
public ContiMoveTemplateGenMob(IDataProperty genMob)
public ContiMoveTemplateGenMob(IDataNode genMob)
{
ItemID = genMob.Resolve<int>("genMobItemID") ?? 0;
ItemID = genMob.ResolveInt("genMobItemID") ?? 0;
Position = new Point2D(
genMob.Resolve<int>("genMobPosition_x") ?? 0,
genMob.Resolve<int>("genMobPosition_y") ?? 0
genMob.ResolveInt("genMobPosition_x") ?? 0,
genMob.ResolveInt("genMobPosition_y") ?? 0
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
using Duey.Abstractions;
using Edelstein.Common.Utilities.Templates;
using Edelstein.Protocol.Data;
using Edelstein.Protocol.Gameplay.Game.Continents.Templates;
using Edelstein.Protocol.Utilities.Templates;

namespace Edelstein.Common.Gameplay.Game.Continents.Templates;

public class ContiMoveTemplateLoader : ITemplateLoader
{
private readonly IDataManager _data;
private readonly IDataNamespace _data;
private readonly ITemplateManager<IContiMoveTemplate> _manager;

public ContiMoveTemplateLoader(IDataManager data, ITemplateManager<IContiMoveTemplate> manager)
public ContiMoveTemplateLoader(IDataNamespace data, ITemplateManager<IContiMoveTemplate> manager)
{
_data = data;
_manager = manager;
}

public async Task<int> Load()
{
var directory = _data.Resolve("Server/Continent.img");
var directory = _data.ResolvePath("Server/Continent.img");

if (directory == null) return 0;

Expand All @@ -30,11 +30,11 @@ await _manager.Insert(new TemplateProviderLazy<IContiMoveTemplate>(
id,
() => new ContiMoveTemplate(
id,
n.ResolveAll(),
n.Resolve("field")!.ResolveAll(),
n.Resolve("scheduler")!.ResolveAll(),
n.Resolve("genMob")?.ResolveAll(),
n.Resolve("time")!.ResolveAll()
n.Cache(),
n.ResolvePath("field")!.Cache(),
n.ResolvePath("scheduler")!.Cache(),
n.ResolvePath("genMob")?.Cache(),
n.ResolvePath("time")!.Cache()
)
));
}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Edelstein.Common.Gameplay.Packets;
using Edelstein.Common.Utilities.Packets;
using Edelstein.Protocol.Gameplay.Game.Contracts;
using Edelstein.Protocol.Gameplay.Game.Objects.User;
using Edelstein.Protocol.Utilities.Packets;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Edelstein.Protocol.Gameplay.Game.Movements;
using Edelstein.Protocol.Gameplay.Game.Objects;
using Edelstein.Protocol.Gameplay.Game.Objects.User;
using Edelstein.Protocol.Gameplay.Game.Spatial;
using Edelstein.Protocol.Utilities.Packets;
using Edelstein.Protocol.Utilities.Spatial;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Edelstein.Protocol.Data;
using Duey.Abstractions;
using Edelstein.Protocol.Gameplay.Game.Objects.Mob.Templates;

namespace Edelstein.Common.Gameplay.Game.Objects.Mob.Templates;
Expand All @@ -8,9 +8,9 @@ public record MobStringTemplate : IMobStringTemplate
public int ID { get; }
public string Name { get; }

public MobStringTemplate(int id, IDataProperty property)
public MobStringTemplate(int id, IDataNode node)
{
ID = id;
Name = property.ResolveOrDefault<string>("name") ?? string.Empty;
Name = node.ResolveString("name") ?? string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
using Edelstein.Common.Gameplay.Game.Objects.NPC.Templates;
using Duey.Abstractions;
using Edelstein.Common.Utilities.Templates;
using Edelstein.Protocol.Data;
using Edelstein.Protocol.Gameplay.Game.Objects.Mob.Templates;
using Edelstein.Protocol.Gameplay.Game.Objects.NPC.Templates;
using Edelstein.Protocol.Utilities.Templates;

namespace Edelstein.Common.Gameplay.Game.Objects.Mob.Templates;

public record MobStringTemplateLoader : ITemplateLoader
{
private readonly IDataManager _data;
private readonly IDataNamespace _data;
private readonly ITemplateManager<IMobStringTemplate> _manager;

public MobStringTemplateLoader(IDataManager data, ITemplateManager<IMobStringTemplate> manager)
public MobStringTemplateLoader(IDataNamespace data, ITemplateManager<IMobStringTemplate> manager)
{
_data = data;
_manager = manager;
}

public async Task<int> Load()
{
await Task.WhenAll(_data.Resolve("String/Mob.img")?.Children
await Task.WhenAll(_data.ResolvePath("String/Mob.img")?.Children
.Select(async n =>
{
var id = Convert.ToInt32(n.Name);
await _manager.Insert(new TemplateProviderEager<IMobStringTemplate>(
id,
new MobStringTemplate(
id,
n.ResolveAll()
n.Cache()
)
));
}) ?? Array.Empty<Task>());
Expand Down
Loading

0 comments on commit d240364

Please sign in to comment.