forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticObjTable.cs
More file actions
133 lines (116 loc) · 4.72 KB
/
Copy pathStaticObjTable.cs
File metadata and controls
133 lines (116 loc) · 4.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System;
using System.Collections.Generic;
using System.IO;
using L2dotNET.Logging.Abstraction;
using L2dotNET.Models.Npcs.Decor;
using L2dotNET.Models.Stats;
using L2dotNET.Utility;
using L2dotNET.World;
namespace L2dotNET.Tables
{
class StaticObjTable
{
private static readonly ILog Log = LogProvider.GetCurrentClassLogger();
private static volatile StaticObjTable _instance;
private static readonly object SyncRoot = new object();
public static StaticObjTable Instance
{
get
{
if (_instance != null)
return _instance;
lock (SyncRoot)
{
if (_instance == null)
_instance = new StaticObjTable();
}
return _instance;
}
}
public SortedList<int, L2StaticObject> Objects;
public void Initialize()
{
Objects = new SortedList<int, L2StaticObject>();
using (StreamReader reader = new StreamReader(new FileInfo(@"scripts\staticobjects.txt").FullName))
{
while (!reader.EndOfStream)
{
string line = reader.ReadLine() ?? string.Empty;
if ((line.Length == 0) || line.StartsWithIgnoreCase("#"))
continue;
string[] pt = line.Split('\t');
L2StaticObject obj = null;
switch (pt[1])
{
case "map":
// obj = new L2TownMap(IdFactory.Instance.NextId(),null);
break;
case "chair":
// obj = new L2Chair(IdFactory.Instance.NextId(), null);
break;
case "pvp":
//obj = new L2PvPSign(IdFactory.Instance.NextId(), null);
break;
case "door":
//obj = new L2Door(IdFactory.Instance.NextId(), null);
break;
}
if (obj == null)
continue;
obj.StaticId = Convert.ToInt32(pt[0]);
for (byte ord = 2; ord < pt.Length; ord++)
{
string parameter = pt[ord];
string value = parameter.Substring(parameter.IndexOf('{') + 1);
value = value.Remove(value.Length - 1);
switch (parameter.Split('{')[0].ToLower())
{
case "spawn":
obj.SetLoc(value.Split(' '));
break;
case "tex":
obj.SetTex(value.Split(' '));
break;
case "htm":
obj.Htm = value;
break;
case "hp":
obj.CharacterStat = new CharacterStat(obj);
break;
case "defence":
obj.Pdef = Convert.ToInt32(value.Split(' ')[0]);
obj.Mdef = Convert.ToInt32(value.Split(' ')[1]);
break;
case "unlock":
{
foreach (string str in value.Split(' '))
{
switch (str)
{
case "trigger":
obj.UnlockTrigger = true;
break;
case "skill":
obj.UnlockSkill = true;
break;
case "drop":
obj.UnlockNpc = true;
break;
}
}
}
break;
}
}
Objects.Add(obj.StaticId, obj);
}
}
foreach (L2StaticObject o in Objects.Values)
{
L2World.Instance.AddObject(o);
o.OnSpawn();
}
Log.Info($"Spawned {Objects.Count} objects.");
}
}
}