-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMapLoader.cs
More file actions
76 lines (66 loc) · 2.07 KB
/
Copy pathMapLoader.cs
File metadata and controls
76 lines (66 loc) · 2.07 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
using System;
using System.IO;
using RFMapToolSharp.Collision;
using RFMapToolSharp.Materials;
using RFMapToolSharp.Models;
using RFMapToolSharp.Rvp;
using RFMapToolSharp.Spt;
using RFMapToolSharp.Textures;
namespace RFMapToolSharp;
public static class MapLoader
{
public static MapScene LoadMap(string gameRoot, string mapName)
{
var scene = new MapScene
{
Name = mapName,
RootPath = Path.Combine(gameRoot, "map", mapName)
};
var mapDir = scene.RootPath;
if (!Directory.Exists(mapDir))
throw new DirectoryNotFoundException($"Папка карты не найдена: {mapDir}");
// R3T
var r3tPath = Path.Combine(mapDir, mapName + ".r3t");
if (File.Exists(r3tPath))
{
var r3t = R3TFile.Load(r3tPath);
scene.Textures.AddRange(r3t.Textures);
}
// R3M — материалы (пока заглушка)
var r3mPath = Path.Combine(mapDir, mapName + ".r3m");
if (File.Exists(r3mPath))
{
scene.MaterialFile = R3MMaterialFile.Load(r3mPath);
}
var r3xPath = Path.Combine(mapDir, mapName + ".r3x");
if (File.Exists(r3xPath))
{
scene.MaterialExt = R3XMaterialFile.Load(r3xPath);
}
// BSP / EBP
var bspPath = Path.Combine(mapDir, mapName + ".bsp");
if (File.Exists(bspPath))
{
scene.Bsp = BspFile.Load(bspPath);
}
var ebpPath = Path.Combine(mapDir, mapName + ".ebp");
if (File.Exists(ebpPath))
{
scene.ExtBsp = ExtBspFile.Load(ebpPath);
}
// SPT
var sptPath = Path.Combine(mapDir, mapName + ".spt");
if (File.Exists(sptPath))
{
var spt = SptFile.Load(sptPath);
scene.Particles.AddRange(spt.Particles);
}
// RVP
var rvpPath = Path.Combine(mapDir, mapName + ".rvp");
if (File.Exists(rvpPath))
{
scene.Movie = RvpFile.Load(rvpPath);
}
return scene;
}
}