-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
86 lines (75 loc) · 2.72 KB
/
Copy pathProgram.cs
File metadata and controls
86 lines (75 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using GameServer.Repositories;
using Microsoft.Extensions.Logging;
using RavenNest.BusinessLogic.Data;
using Shinobytes.Ravenfall.Data;
using Shinobytes.Ravenfall.Data.EntityFramework.Legacy;
using Shinobytes.Ravenfall.RavenNet.Core;
using Shinobytes.Ravenfall.RavenNet.Models;
using System;
using System.Linq;
namespace DataImporter
{
class Program
{
static void Main(string[] args)
{
var logger = new ConsoleLogger();
try
{
var dbCtxProvider = new RavenfallDbContextProvider(new AppSettings
{
DbConnectionString = "Server=localhost;Database=Ravenfall2;Trusted_Connection=True;Integrated Security=True;"
});
IGameData gameData = new GameData(
dbCtxProvider,
logger,
new Kernel(),
new QueryBuilder());
ImportGameObjects(logger, gameData);
}
catch (Exception exc)
{
logger.LogError(exc.ToString());
while (true)
{
System.Threading.Thread.Sleep(1000);
}
}
}
static void ImportGameObjects(ILogger logger, IGameData gameData)
{
var repo = new JsonBasedWorldObjectRepository();
var objs = repo.AllObjects();
if (objs.Count > 0)
{
logger.LogDebug("Removing existing objects..");
var objects = gameData.GetAllGameObjects();
foreach (GameObject obj in objects)
{
var transform = gameData.GetTransform(obj.TransformId);
if (transform != null)
{
gameData.Remove(transform);
}
gameData.Remove(obj);
}
logger.LogDebug("Importing objects from json file..");
foreach (var obj in objs)
{
var transform = gameData.CreateTransform();
transform.SetPosition(obj.Position);
transform.SetRotation(obj.Rotation);
var newObj = gameData.CreateGameObject();
newObj.Id = obj.Id;
newObj.Type = obj.Type;
newObj.InteractItemType = obj.InteractItemType;
newObj.RespawnMilliseconds = obj.RespawnMilliseconds;
newObj.Static = obj.Static;
newObj.Experience = obj.Experience;
newObj.TransformId = transform.Id;
}
}
gameData.Flush();
}
}
}