Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
DatabaseObjectType.cs
浏览该文件的文档.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Engine;
5
6namespace TemplatesDatabase {
7 public class DatabaseObjectType {
8 string m_name;
9
11
12 string m_iconName;
13
15
17
19
21
23
24 List<DatabaseObjectType> m_allowedNestingParents;
25
26 List<DatabaseObjectType> m_allowedInheritanceParents;
27
28 List<DatabaseObjectType> m_allowedNestingChildren = [];
29
30 List<DatabaseObjectType> m_allowedInheritanceChildren = [];
31
33
34 public bool IsInitialized => m_allowedNestingParents != null;
35
36 public string Name => m_name;
37
39
40 public string IconName => m_iconName;
41
42 public int Order => m_order;
43
45
46 public bool MustInherit => m_mustInherit;
47
49
51
52 public ReadOnlyList<DatabaseObjectType> AllowedNestingParents => new(m_allowedNestingParents);
53
54 public ReadOnlyList<DatabaseObjectType> AllowedInheritanceParents => new(m_allowedInheritanceParents);
55
56 public ReadOnlyList<DatabaseObjectType> AllowedNestingChildren => new(m_allowedNestingChildren);
57
58 public ReadOnlyList<DatabaseObjectType> AllowedInheritanceChildren => new(m_allowedInheritanceChildren);
59
61
62 public DatabaseObjectType(string name,
63 string defaultInstanceName,
64 string iconName,
65 int order,
66 bool supportsValue,
67 bool mustInherit,
68 int nameLengthLimit,
69 bool saveStandalone) {
70 m_name = name;
71 m_defaultInstanceName = defaultInstanceName;
72 m_iconName = iconName;
73 m_order = order;
74 m_supportsValue = supportsValue;
75 m_mustInherit = mustInherit;
76 m_nameLengthLimit = nameLengthLimit;
77 m_saveStandalone = saveStandalone;
78 }
79
80 public void InitializeRelations(IEnumerable<DatabaseObjectType> allowedNestingParents,
81 IEnumerable<DatabaseObjectType> allowedInheritanceParents,
82 DatabaseObjectType nestedValueType) {
83 if (IsInitialized) {
84 throw new InvalidOperationException("InitializeRelations of this DatabaseObjectType was already called.");
85 }
86 m_nestedValueType = nestedValueType;
87 if (allowedNestingParents != null) {
88 m_allowedNestingParents = allowedNestingParents.Distinct().ToList();
89 foreach (DatabaseObjectType allowedNestingParent in m_allowedNestingParents) {
90 allowedNestingParent.m_allowedNestingChildren.Add(this);
91 }
92 }
93 else {
95 }
96 if (allowedInheritanceParents != null) {
97 m_allowedInheritanceParents = allowedInheritanceParents.Distinct().ToList();
98 foreach (DatabaseObjectType allowedInheritanceParent in m_allowedInheritanceParents) {
99 allowedInheritanceParent.m_allowedInheritanceChildren.Add(this);
100 }
101 }
102 else {
104 }
105 }
106
107 public override string ToString() => Name;
108 }
109}
ReadOnlyList< DatabaseObjectType > AllowedNestingChildren
ReadOnlyList< DatabaseObjectType > AllowedInheritanceChildren
List< DatabaseObjectType > m_allowedInheritanceChildren
List< DatabaseObjectType > m_allowedInheritanceParents
List< DatabaseObjectType > m_allowedNestingParents
ReadOnlyList< DatabaseObjectType > AllowedNestingParents
ReadOnlyList< DatabaseObjectType > AllowedInheritanceParents
void InitializeRelations(IEnumerable< DatabaseObjectType > allowedNestingParents, IEnumerable< DatabaseObjectType > allowedInheritanceParents, DatabaseObjectType nestedValueType)
DatabaseObjectType(string name, string defaultInstanceName, string iconName, int order, bool supportsValue, bool mustInherit, int nameLengthLimit, bool saveStandalone)
List< DatabaseObjectType > m_allowedNestingChildren