Client LuaCsForBarotrauma
RandomEventsFile.cs
1
using
System.Xml.Linq;
2
3
namespace
Barotrauma
4
{
5
[RequiredByCorePackage]
6
sealed
class
RandomEventsFile
:
ContentFile
7
{
8
public
RandomEventsFile
(
ContentPackage
contentPackage,
ContentPath
path) : base(contentPackage, path) { }
9
10
public
void
LoadFromXElement
(
ContentXElement
parentElement,
bool
overriding)
11
{
12
Identifier elemName =
new
Identifier(parentElement.
Name
.ToString());
13
if
(parentElement.
IsOverride
())
14
{
15
foreach
(var element
in
parentElement.
Elements
())
16
{
17
LoadFromXElement
(element,
true
);
18
}
19
}
20
else
if
(elemName ==
"randomevents"
)
21
{
22
foreach
(var element
in
parentElement.
Elements
())
23
{
24
LoadFromXElement
(element, overriding);
25
}
26
}
27
else
if
(elemName ==
"eventprefabs"
)
28
{
29
foreach
(var subElement
in
parentElement.
Elements
())
30
{
31
if
(subElement.NameAsIdentifier() ==
"traitorevent"
)
32
{
33
var prefab =
new
TraitorEventPrefab
(subElement,
this
);
34
EventPrefab
.
Prefabs
.Add(prefab, overriding);
35
}
36
else
37
{
38
var prefab =
new
EventPrefab
(subElement,
this
);
39
EventPrefab
.
Prefabs
.Add(prefab, overriding);
40
}
41
}
42
}
43
else
if
(elemName ==
"eventsprites"
)
44
{
45
#if CLIENT
46
foreach
(var subElement
in
parentElement.
Elements
())
47
{
48
var prefab =
new
EventSprite
(subElement,
this
);
49
EventSprite
.
Prefabs
.Add(prefab, overriding);
50
}
51
#endif
52
}
53
else
if
(elemName ==
"eventset"
)
54
{
55
var prefab =
new
EventSet
(parentElement,
this
);
56
EventSet
.
Prefabs
.Add(prefab, overriding);
57
}
58
else
if
(elemName ==
"clear"
)
59
{
60
EventPrefab
.
Prefabs
.AddOverrideFile(
this
);
61
EventSet
.
Prefabs
.AddOverrideFile(
this
);
62
#if CLIENT
63
EventSprite
.
Prefabs
.AddOverrideFile(
this
);
64
#endif
65
}
66
else
67
{
68
DebugConsole.ThrowError($
"RandomEventsFile: Invalid {GetType().Name} element: {parentElement.Name} in {Path}"
,
69
contentPackage: parentElement.
ContentPackage
);
70
}
71
}
72
73
public
override
void
LoadFile
()
74
{
75
XDocument doc = XMLExtensions.TryLoadXml(Path);
76
if
(doc ==
null
) {
return
; }
77
78
var rootElement = doc.Root.FromPackage(
ContentPackage
);
79
LoadFromXElement
(rootElement,
false
);
80
}
81
82
public
override
void
UnloadFile
()
83
{
84
EventPrefab
.
Prefabs
.RemoveByFile(
this
);
85
EventSet
.
Prefabs
.RemoveByFile(
this
);
86
#if CLIENT
87
EventSprite
.
Prefabs
.RemoveByFile(
this
);
88
#endif
89
}
90
91
public
override
void
Sort
()
92
{
93
EventPrefab
.
Prefabs
.SortAll();
94
EventSet
.
Prefabs
.SortAll();
95
#if CLIENT
96
EventSprite
.
Prefabs
.SortAll();
97
#endif
98
}
99
}
100
}
Barotrauma.ContentFile
Base class for content file types, which are loaded from filelist.xml via reflection....
Definition:
ContentFile.cs:23
Barotrauma.ContentPackage
Definition:
ContentPackage.cs:18
Barotrauma.ContentPath
Definition:
ContentPath.cs:11
Barotrauma.ContentXElement
Definition:
ContentXElement.cs:13
Barotrauma.ContentXElement.ContentPackage
ContentPackage? ContentPackage
Definition:
ContentXElement.cs:14
Barotrauma.ContentXElement.Name
XName Name
Definition:
ContentXElement.cs:27
Barotrauma.ContentXElement.Elements
IEnumerable< ContentXElement > Elements()
Barotrauma.ContentXElement.IsOverride
bool IsOverride()
Barotrauma.EventPrefab
Definition:
EventPrefab.cs:10
Barotrauma.EventPrefab.Prefabs
static readonly PrefabCollection< EventPrefab > Prefabs
Definition:
EventPrefab.cs:11
Barotrauma.EventSet
Event sets are sets of random events that occur within a level (most commonly, monster spawns and scr...
Definition:
EventSet.cs:31
Barotrauma.EventSet.Prefabs
static readonly PrefabCollection< EventSet > Prefabs
Definition:
EventSet.cs:44
Barotrauma.EventSprite
Definition:
EventSet.cs:12
Barotrauma.EventSprite.Prefabs
static readonly PrefabCollection< EventSprite > Prefabs
Definition:
EventSet.cs:13
Barotrauma.RandomEventsFile
Definition:
RandomEventsFile.cs:7
Barotrauma.RandomEventsFile.LoadFromXElement
void LoadFromXElement(ContentXElement parentElement, bool overriding)
Definition:
RandomEventsFile.cs:10
Barotrauma.RandomEventsFile.Sort
override void Sort()
Definition:
RandomEventsFile.cs:91
Barotrauma.RandomEventsFile.UnloadFile
override void UnloadFile()
Definition:
RandomEventsFile.cs:82
Barotrauma.RandomEventsFile.LoadFile
override void LoadFile()
Definition:
RandomEventsFile.cs:73
Barotrauma.RandomEventsFile.RandomEventsFile
RandomEventsFile(ContentPackage contentPackage, ContentPath path)
Definition:
RandomEventsFile.cs:8
Barotrauma.TraitorEventPrefab
Definition:
TraitorEventPrefab.cs:14
Barotrauma
Definition:
AchievementManager.cs:12
Barotrauma
BarotraumaShared
SharedSource
ContentManagement
ContentFile
RandomEventsFile.cs
Generated by
1.9.1