Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
EntityData.cs
浏览该文件的文档.
1
using
System;
2
using
System.Xml.Linq;
3
using
TemplatesDatabase
;
4
using
XmlUtilities
;
5
6
namespace
GameEntitySystem
{
7
public
class
EntityData
{
8
public
int
Id
;
9
10
public
ValuesDictionary
ValuesDictionary
;
11
12
public
EntityData
() { }
13
14
public
EntityData
(
GameDatabase
gameDatabase, XElement entityNode) {
15
Id
=
XmlUtils
.
GetAttributeValue
<
int
>(entityNode,
"Id"
);
16
Guid attributeValue =
XmlUtils
.
GetAttributeValue
(entityNode,
"Guid"
, Guid.Empty);
17
string
attributeValue2 =
XmlUtils
.
GetAttributeValue
(entityNode,
"Name"
,
string
.Empty);
18
DatabaseObject
databaseObject;
19
if
(attributeValue != Guid.Empty) {
20
databaseObject = gameDatabase.
Database
.
FindDatabaseObject
(attributeValue, gameDatabase.
EntityTemplateType
,
true
);
21
}
22
else
{
23
if
(
string
.IsNullOrEmpty(attributeValue2)) {
24
throw
new
InvalidOperationException(
"Entity template guid or name must be specified."
);
25
}
26
databaseObject = gameDatabase.
Database
.
FindDatabaseObject
(attributeValue2, gameDatabase.
EntityTemplateType
,
true
);
27
}
28
ValuesDictionary
= [];
29
ValuesDictionary
.PopulateFromDatabaseObject(databaseObject);
30
ValuesDictionary
.ApplyOverrides(entityNode);
31
}
32
33
public
void
Save
(XElement entityNode) {
34
XmlUtils
.
SetAttributeValue
(entityNode,
"Id"
,
Id
);
35
XmlUtils
.
SetAttributeValue
(entityNode,
"Guid"
,
ValuesDictionary
.DatabaseObject.Guid);
36
XmlUtils
.
SetAttributeValue
(entityNode,
"Name"
,
ValuesDictionary
.DatabaseObject.Name);
37
ValuesDictionary
.Save(entityNode);
38
}
39
}
40
}
GameEntitySystem.EntityData.EntityData
EntityData()
定义
EntityData.cs:12
GameEntitySystem.EntityData.Id
int Id
定义
EntityData.cs:8
GameEntitySystem.EntityData.EntityData
EntityData(GameDatabase gameDatabase, XElement entityNode)
定义
EntityData.cs:14
GameEntitySystem.EntityData.ValuesDictionary
ValuesDictionary ValuesDictionary
定义
EntityData.cs:10
GameEntitySystem.EntityData.Save
void Save(XElement entityNode)
定义
EntityData.cs:33
GameEntitySystem.GameDatabase
定义
GameDatabase.cs:4
GameEntitySystem.GameDatabase.Database
Database Database
定义
GameDatabase.cs:5
GameEntitySystem.GameDatabase.EntityTemplateType
DatabaseObjectType EntityTemplateType
定义
GameDatabase.cs:15
TemplatesDatabase.Database.FindDatabaseObject
DatabaseObject FindDatabaseObject(Guid guid, DatabaseObjectType type, bool throwIfNotFound)
定义
Database.cs:43
TemplatesDatabase.DatabaseObject
定义
DatabaseObject.cs:5
XmlUtilities.XmlUtils
定义
XmlUtils.cs:10
XmlUtilities.XmlUtils.SetAttributeValue
static void SetAttributeValue(XElement node, string attributeName, object value)
定义
XmlUtils.cs:37
XmlUtilities.XmlUtils.GetAttributeValue
static object GetAttributeValue(XElement node, string attributeName, Type type)
定义
XmlUtils.cs:11
GameEntitySystem
定义
Component.cs:6
TemplatesDatabase
定义
Database.cs:6
XmlUtilities
定义
XmlUtils.cs:9
SurvivalcraftApi 1.8.2.3
EntitySystem
GameEntitySystem
EntityData.cs
制作者
1.16.1