Explorar el Código

EntityType改成枚举类型

tanghai hace 9 años
padre
commit
ea387074c2

+ 3 - 3
Server/Model/Server.Model.csproj

@@ -164,6 +164,9 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Object\Entity.cs">
       <Link>Object\Entity.cs</Link>
     </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Object\EntityType.cs">
+      <Link>Object\EntityType.cs</Link>
+    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Object\IAwake.cs">
       <Link>Object\IAwake.cs</Link>
     </Compile>
@@ -185,9 +188,6 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Object\ObjectManager.cs">
       <Link>Object\ObjectManager.cs</Link>
     </Compile>
-    <Compile Include="..\..\Unity\Assets\Scripts\Other\EntityType.cs">
-      <Link>Other\EntityType.cs</Link>
-    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Other\Options.cs">
       <Link>Other\Options.cs</Link>
     </Compile>

+ 3 - 5
Unity/Assets/Scripts/Config/AConfig.cs

@@ -1,17 +1,15 @@
-using Base;
-
-namespace Model
+namespace Model
 {
 	/// <summary>
 	/// 每个Config的基类
 	/// </summary>
 	public abstract class AConfig: Entity
 	{
-		public AConfig(string entityType): base(entityType)
+		public AConfig(EntityType entityType): base(entityType)
 		{
 		}
 
-		public AConfig(long id, string entityType): base(id, entityType)
+		public AConfig(long id, EntityType entityType): base(id, entityType)
 		{
 		}
 	}

+ 1 - 2
Unity/Assets/Scripts/Config/AConfigComponent.cs

@@ -1,5 +1,4 @@
-using Base;
-using MongoDB.Bson.Serialization.Attributes;
+using MongoDB.Bson.Serialization.Attributes;
 
 namespace Model
 {

+ 2 - 2
Unity/Assets/Scripts/Entity/Config/BuffConfig.cs

@@ -8,11 +8,11 @@ namespace Model
 		public string Name { get; set; }
 		public int Time { get; set; }
 
-		public BuffConfig(): base(EntityType.BuffConfig)
+		public BuffConfig(): base(EntityType.Config)
 		{
 		}
 
-		public BuffConfig(long id): base(id, EntityType.BuffConfig)
+		public BuffConfig(long id): base(id, EntityType.Config)
 		{
 		}
 	}

+ 3 - 3
Unity/Assets/Scripts/Object/Entity.cs

@@ -8,7 +8,7 @@ namespace Model
 {
 	public class Entity: Object
 	{
-		public string Type { get; set; }
+		public EntityType Type { get; set; }
 
 		[BsonElement]
 		[BsonIgnoreIfNull]
@@ -17,12 +17,12 @@ namespace Model
 		[BsonIgnore]
 		private Dictionary<Type, Component> componentDict = new Dictionary<Type, Component>();
 
-		protected Entity(string entityType)
+		protected Entity(EntityType entityType)
 		{
 			this.Type = entityType;
 		}
 
-		protected Entity(long id, string entityType) : base(id)
+		protected Entity(long id, EntityType entityType) : base(id)
 		{
 			this.Type = entityType;
 		}

+ 12 - 0
Unity/Assets/Scripts/Object/EntityType.cs

@@ -0,0 +1,12 @@
+namespace Model
+{
+	public enum EntityType
+	{
+		None,
+		Scene,
+		Session,
+		UI,
+		Config,
+		Network,
+	}
+}

+ 0 - 0
Unity/Assets/Scripts/Other/EntityType.cs.meta → Unity/Assets/Scripts/Object/EntityType.cs.meta


+ 0 - 15
Unity/Assets/Scripts/Other/EntityType.cs

@@ -1,15 +0,0 @@
-namespace Model
-{
-	public static class EntityType
-	{
-		public const string None = "None";
-		public const string Scene = "Scene";
-		public const string Session = "Session";
-		public const string UI = "UI";
-		public const string Config = "Config";
-		public const string Network = "Network";
-
-		// Config
-		public const string BuffConfig = "BuffConfig";
-	}
-}

+ 1 - 1
Unity/Unity.CSharp.csproj

@@ -135,7 +135,7 @@
     <Compile Include="Assets\Scripts\Object\Object.cs" />
     <Compile Include="Assets\Scripts\Object\ObjectEventAttribute.cs" />
     <Compile Include="Assets\Scripts\Object\ObjectManager.cs" />
-    <Compile Include="Assets\Scripts\Other\EntityType.cs" />
+    <Compile Include="Assets\Scripts\Object\EntityType.cs" />
     <Compile Include="Assets\Scripts\Other\GameException.cs" />
     <Compile Include="Assets\Scripts\Other\Options.cs" />
     <Compile Include="Assets\Scripts\Entity\Config\StartConfig.cs" />