diff --git a/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs b/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs new file mode 100644 index 00000000..b8fe1a18 --- /dev/null +++ b/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs @@ -0,0 +1,15 @@ +#if UNITY_EDITOR +using UnityEngine; + +namespace TEngine +{ + public class ComponentView: MonoBehaviour + { + public Entity Component + { + get; + set; + } + } +} +#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs.meta new file mode 100644 index 00000000..c91ec131 --- /dev/null +++ b/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 24bef9ebd1ca4a1cb8db0fba17ec5b2b +timeCreated: 1689576818 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs b/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs index 6c183179..04c119b9 100644 --- a/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs +++ b/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs @@ -28,6 +28,11 @@ namespace TEngine public abstract class Entity : IDisposable { +#if UNITY_EDITOR + [UnityEngine.HideInInspector] + public UnityEngine.GameObject ViewGO; +#endif + #region Status [BsonIgnore] [IgnoreDataMember] @@ -107,13 +112,7 @@ namespace TEngine [BsonIgnore] [IgnoreDataMember] - protected virtual string ViewName - { - get - { - return this.GetType().FullName; - } - } + protected virtual string ViewName => this.GetType().Name; #endregion @@ -222,8 +221,17 @@ namespace TEngine EntitiesSystem.Instance.Awake(entity); EntitiesSystem.Instance.StartUpdate(entity); } + + entity.IsCreated = true; entity.IsNew = true; + entity.OnCreate(); +#if UNITY_EDITOR + entity.ViewGO = new UnityEngine.GameObject(entity.ViewName); + entity.ViewGO.AddComponent().Component = entity; + entity.ViewGO.transform.SetParent(entity.Parent == null? + UnityEngine.GameObject.Find("[EntitySystem]").transform : entity.Parent.ViewGO.transform); +#endif return entity; } @@ -246,6 +254,13 @@ namespace TEngine } entity.IsCreated = true; entity.IsNew = true; + entity.OnCreate(); +#if UNITY_EDITOR + entity.ViewGO = new UnityEngine.GameObject(entity.ViewName); + entity.ViewGO.AddComponent().Component = entity; + entity.ViewGO.transform.SetParent(entity.Parent == null? + UnityEngine.GameObject.Find("[EntitySystem]").transform : entity.Parent.ViewGO.transform); +#endif return entity; } @@ -375,6 +390,15 @@ namespace TEngine component.Parent = this; component.Scene = Scene; component.IsComponent = true; +#if UNITY_EDITOR + if (component.ViewGO == null) + { + Log.Error($"{component} ‘s component.ViewGO is null"); + return; + } + component.ViewGO.transform.SetParent(component.Parent == null? + UnityEngine.GameObject.Find("[EntitySystem]").transform : component.Parent.ViewGO.transform); +#endif } #endregion @@ -570,6 +594,10 @@ namespace TEngine #endregion + #region OnCreate + public virtual void OnCreate() { } + #endregion + #region Dispose public virtual void Dispose() @@ -638,6 +666,15 @@ namespace TEngine Entities.Remove(runtimeId); Scene = null; Return(this); + +#if UNITY_EDITOR + if (this.ViewGO == null) + { + Log.Error($"{this} ‘s ViewGO is null"); + return; + } + UnityEngine.Object.Destroy(this.ViewGO);; +#endif } #endregion diff --git a/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs index 2e36222a..0a12670e 100644 --- a/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs +++ b/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs @@ -1,8 +1,12 @@ #if TENGINE_NET +using System.ComponentModel; using MongoDB.Bson; +using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Conventions; +using TrueSync; using Unity.Mathematics; +using MongoHelper = TEngine.Core.MongoHelper; namespace TEngine.Core; @@ -15,10 +19,21 @@ public sealed class MongoHelper : Singleton // 自动注册IgnoreExtraElements var conventionPack = new ConventionPack {new IgnoreExtraElementsConvention(true)}; ConventionRegistry.Register("IgnoreExtraElements", conventionPack, type => true); - BsonSerializer.TryRegisterSerializer(typeof(float2), new StructBsonSerialize()); - BsonSerializer.TryRegisterSerializer(typeof(float3), new StructBsonSerialize()); - BsonSerializer.TryRegisterSerializer(typeof(float4), new StructBsonSerialize()); - BsonSerializer.TryRegisterSerializer(typeof(quaternion), new StructBsonSerialize()); + RegisterStruct(); + RegisterStruct(); + RegisterStruct(); + RegisterStruct(); + + RegisterStruct(); + RegisterStruct(); + RegisterStruct(); + RegisterStruct(); + RegisterStruct(); + } + + public static void RegisterStruct() where T : struct + { + BsonSerializer.RegisterSerializer(typeof (T), new StructBsonSerialize()); } protected override void OnLoad(int assemblyName) @@ -43,6 +58,43 @@ public sealed class MongoHelper : Singleton } }); } + + private static readonly JsonWriterSettings defaultSettings = new() { OutputMode = JsonOutputMode.RelaxedExtendedJson }; + + public static string ToJson(object obj) + { + if (obj is ISupportInitialize supportInitialize) + { + supportInitialize.BeginInit(); + } + return obj.ToJson(defaultSettings); + } + + public static string ToJson(object obj, JsonWriterSettings settings) + { + if (obj is ISupportInitialize supportInitialize) + { + supportInitialize.BeginInit(); + } + return obj.ToJson(settings); + } + + public static T FromJson(string str) + { + try + { + return BsonSerializer.Deserialize(str); + } + catch (Exception e) + { + throw new Exception($"{str}\n{e}"); + } + } + + public static object FromJson(Type type, string str) + { + return BsonSerializer.Deserialize(str, type); + } public T Deserialize(byte[] bytes) { diff --git a/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs b/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs index aa7c4ab9..5c1c1c9d 100644 --- a/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs +++ b/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs @@ -13,7 +13,7 @@ namespace TEngine { // 初始化框架 GameContext.Init(); - new GameObject("[TEngine.Unity]").AddComponent(); + new GameObject("[EntitySystem]").AddComponent(); // 框架需要一个Scene来驱动、所以要创建一个Scene、后面所有的框架都会在这个Scene下 // 也就是把这个Scene给卸载掉、框架的东西都会清除掉 return Scene.Create("Unity"); diff --git a/Assets/GameScripts/Editor/Entitas.meta b/Assets/GameScripts/Editor/Entitas.meta new file mode 100644 index 00000000..db854cf5 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4c152230ddf4e46458f1bd516e896129 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs b/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs new file mode 100644 index 00000000..f570a027 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using Sirenix.OdinInspector.Editor; +using TEngine; +using UnityEditor; +using UnityEngine; + +[CustomEditor(typeof(ComponentView))] +public class ComponentViewEditor : OdinEditor +{ + public override void OnInspectorGUI() + { + ComponentView componentView = (ComponentView)target; + Entity component = componentView.Component; + ComponentViewHelper.Draw(component); + } +} + +public static class ComponentViewHelper +{ + private static readonly List typeDrawers = new List(); + + static ComponentViewHelper() + { + Assembly assembly = typeof(ComponentViewHelper).Assembly; + foreach (Type type in assembly.GetTypes()) + { + if (!type.IsDefined(typeof(TypeDrawerAttribute))) + { + continue; + } + + ITypeDrawer iTypeDrawer = (ITypeDrawer)Activator.CreateInstance(type); + typeDrawers.Add(iTypeDrawer); + } + } + + public static void Draw(Entity entity) + { + try + { + FieldInfo[] fields = entity.GetType() + .GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | + BindingFlags.FlattenHierarchy); + + EditorGUILayout.BeginVertical(); + + EditorGUILayout.LongField("RuntimeId: ", entity.RuntimeId); + + EditorGUILayout.LongField("Id: ", entity.Id); + + foreach (FieldInfo fieldInfo in fields) + { + Type type = fieldInfo.FieldType; + if (type.IsDefined(typeof(HideInInspector), false)) + { + continue; + } + + if (fieldInfo.IsDefined(typeof(HideInInspector), false)) + { + continue; + } + + object value = fieldInfo.GetValue(entity); + + foreach (ITypeDrawer typeDrawer in typeDrawers) + { + if (!typeDrawer.HandlesType(type)) + { + continue; + } + + string fieldName = fieldInfo.Name; + if (fieldName.Length > 17 && fieldName.Contains("k__BackingField")) + { + fieldName = fieldName.Substring(1, fieldName.Length - 17); + } + + try + { + value = typeDrawer.DrawAndGetNewValue(type, fieldName, value, null); + } + catch (Exception e) + { + Debug.LogError(e); + } + + fieldInfo.SetValue(entity, value); + break; + } + } + + EditorGUILayout.EndVertical(); + } + catch (Exception e) + { + Debug.Log($"component view error: {entity.GetType().FullName} {e}"); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs.meta b/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs.meta new file mode 100644 index 00000000..5daa476c --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fe2aac3a6ed717d4da185a29f2d2a386 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs new file mode 100644 index 00000000..42be5f8d --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs @@ -0,0 +1,11 @@ +using System; + +namespace TEngine +{ + public interface ITypeDrawer + { + bool HandlesType(Type type); + + object DrawAndGetNewValue(Type memberType, string memberName, object value, object target); + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs.meta new file mode 100644 index 00000000..298ae324 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ba82988cd3f6426cbb858d18eed4a8bb +timeCreated: 1689578308 \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer.meta new file mode 100644 index 00000000..32d1fbf2 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 965c500db0aa46ac9a6ff0fe19a9adda +timeCreated: 1689578308 \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs new file mode 100644 index 00000000..32db764c --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace TEngine +{ + [TypeDrawer] + public class AnimationCurveTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (AnimationCurve); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.CurveField(memberName, (AnimationCurve) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs.meta new file mode 100644 index 00000000..0704da21 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae2555143c20c6b49825eaa645fc626b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs new file mode 100644 index 00000000..15232da1 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs @@ -0,0 +1,19 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class BoolTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (bool); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.Toggle(memberName, (bool) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs.meta new file mode 100644 index 00000000..5ffe1919 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e8022a6e902073946b421230f287c214 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs new file mode 100644 index 00000000..71361ca5 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace TEngine +{ + [TypeDrawer] + public class BoundsTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (Bounds); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.BoundsField(memberName, (Bounds) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs.meta new file mode 100644 index 00000000..6a4c5ffb --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 56a153b48484f394cae46d7f2eed3b1b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs new file mode 100644 index 00000000..a85d72ff --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class CharTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (char); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + var str = EditorGUILayout.TextField(memberName, ((char) value).ToString()); + return str.Length > 0? str[0] : default (char); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs.meta new file mode 100644 index 00000000..df5a8024 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0ec6e79217cb2ea4abbd149361850719 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs new file mode 100644 index 00000000..ca239b30 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace TEngine +{ + [TypeDrawer] + public class ColorTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (Color); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.ColorField(memberName, (Color) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs.meta new file mode 100644 index 00000000..a8f9d022 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 89557fe3279f2cf43b9ab573d50af140 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs new file mode 100644 index 00000000..e9afa59c --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs @@ -0,0 +1,25 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class DateTimeTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (DateTime); + } + + // Note: This is a very basic implementation. The ToString() method conversion will cut off milliseconds. + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + var dateString = value.ToString(); + var newDateString = EditorGUILayout.TextField(memberName, dateString); + + return newDateString != dateString + ? DateTime.Parse(newDateString) + : value; + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs.meta new file mode 100644 index 00000000..f827d41d --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f0d0ce2464429cf4da779507e0707feb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs new file mode 100644 index 00000000..22f756a8 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class DictionaryIntLongTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (Dictionary); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + Dictionary dictionary = value as Dictionary; + + EditorGUILayout.LabelField($"{memberName}:"); + foreach ((int k, long v) in dictionary) + { + if (v == 0) + { + continue; + } + EditorGUILayout.LongField($" {k} :", v); + } + return value; + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs.meta new file mode 100644 index 00000000..8ef49af3 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b4f3ad48c3023dd4f9dbe2a6145be126 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs new file mode 100644 index 00000000..74af1e78 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs @@ -0,0 +1,19 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class DoubleTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (double); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.DoubleField(memberName, (double) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs.meta new file mode 100644 index 00000000..fe193096 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f7fb2f1ae08fdc643932c03d2fbdf7e5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs new file mode 100644 index 00000000..0b120d4a --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs @@ -0,0 +1,39 @@ +#if ENABLE_VIEW + +using System; +using System.Reflection; +using UnityEditor; +using UnityEngine; + +namespace TEngine +{ + [TypeDrawer] + public class EntityRefTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + if (!type.IsGenericType) + { + return false; + } + + if (type.GetGenericTypeDefinition() == typeof (EntityRef<>)) + { + return true; + } + + return false; + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + FieldInfo fieldInfo = memberType.GetField("entity", BindingFlags.NonPublic | BindingFlags.Instance); + Entity entity = (Entity)fieldInfo.GetValue(value); + GameObject go = entity?.ViewGO; + EditorGUILayout.ObjectField(memberName, go, memberType, true); + return value; + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs.meta new file mode 100644 index 00000000..91568bc0 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e13b5d8e25f279649895512cc6b21123 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs new file mode 100644 index 00000000..ea18caad --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs @@ -0,0 +1,24 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class EnumTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type.IsEnum; + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + if (memberType.IsDefined(typeof (FlagsAttribute), false)) + { + return EditorGUILayout.EnumFlagsField(memberName, (Enum) value); + } + + return EditorGUILayout.EnumPopup(memberName, (Enum) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs.meta new file mode 100644 index 00000000..9554e520 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29e6926674d4e6f49ad2bb925191c912 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs new file mode 100644 index 00000000..b1be3db9 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs @@ -0,0 +1,19 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class FloatTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (float); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.FloatField(memberName, (float) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs.meta new file mode 100644 index 00000000..71d727c8 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a812828c88a51f5438ac4f10d680daec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs new file mode 100644 index 00000000..b0e73725 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class IntTypeDrawer: ITypeDrawer + { + [TypeDrawer] + public bool HandlesType(Type type) + { + return type == typeof (int); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.IntField(memberName, (int) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs.meta new file mode 100644 index 00000000..c1db52fd --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bd314885fe993aa4995e2664c02d4aa5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs new file mode 100644 index 00000000..43fbed88 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class LongTypeDrawer: ITypeDrawer + { + [TypeDrawer] + public bool HandlesType(Type type) + { + return type == typeof (long); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.LongField(memberName, (long) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs.meta new file mode 100644 index 00000000..f35e073d --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d89f15e267d1ef04896ceed73e57d8f0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs new file mode 100644 index 00000000..57fe2bd1 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace TEngine +{ + [TypeDrawer] + public class RectTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (Rect); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.RectField(memberName, (Rect) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs.meta new file mode 100644 index 00000000..e4a1725d --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 051d3ab57c4efe346abdff5c64a4feee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs new file mode 100644 index 00000000..c3e08f5b --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs @@ -0,0 +1,19 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class StringTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (string); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.DelayedTextField(memberName, (string) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs.meta new file mode 100644 index 00000000..107bbbaa --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 30bc09383e1bc14409c952170fe70661 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs new file mode 100644 index 00000000..37de1c28 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; + +namespace TEngine +{ + [TypeDrawer] + public class UnityObjectTypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (UnityEngine.Object) || + type.IsSubclassOf(typeof (UnityEngine.Object)); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.ObjectField(memberName, (UnityEngine.Object) value, memberType, true); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs.meta new file mode 100644 index 00000000..68b93971 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a810aa11d0c17e548848c1745dbdb30c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs new file mode 100644 index 00000000..7b2a96e4 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace TEngine +{ + [TypeDrawer] + public class Vector2TypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (Vector2); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.Vector2Field(memberName, (Vector2) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs.meta new file mode 100644 index 00000000..7faedc90 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fac773feb8b254c409b8568ff7fbca16 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs new file mode 100644 index 00000000..69e119eb --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace TEngine +{ + [TypeDrawer] + public class Vector3TypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (Vector3); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.Vector3Field(memberName, (Vector3) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs.meta new file mode 100644 index 00000000..83145e0d --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b3229d49b3d935d41ae02afae1cc675f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs new file mode 100644 index 00000000..881f58fb --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs @@ -0,0 +1,20 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace TEngine +{ + [TypeDrawer] + public class Vector4TypeDrawer: ITypeDrawer + { + public bool HandlesType(Type type) + { + return type == typeof (Vector4); + } + + public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) + { + return EditorGUILayout.Vector4Field(memberName, (Vector4) value); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs.meta new file mode 100644 index 00000000..497df48f --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8455282b831decd44b5b15289adbe6db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs new file mode 100644 index 00000000..bfd77ec9 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs @@ -0,0 +1,6 @@ +using System; + +namespace TEngine +{ + public class TypeDrawerAttribute: Attribute { } +} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs.meta new file mode 100644 index 00000000..71318212 --- /dev/null +++ b/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 64d93f1343d249ea98a11ad1dfe9dc7d +timeCreated: 1689578308 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo.meta new file mode 100644 index 00000000..18cb954b --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ab10a5a730054c5aaa942164c750abfb +timeCreated: 1689576189 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core.meta new file mode 100644 index 00000000..7236d85e --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 94212c40840344b5bd6ba4fc82097d47 +timeCreated: 1689576337 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic.meta new file mode 100644 index 00000000..9966eb40 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 78e93a657ea64d5d97000e8b6cc83ffc +timeCreated: 1689576342 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs new file mode 100644 index 00000000..285f9ec9 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs @@ -0,0 +1,20 @@ +using TEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// 逻辑层实体。 + /// + public abstract class EntityLogic : Entity + { + public override void OnCreate() + { + base.OnCreate(); + } + + public override void Dispose() + { + base.Dispose(); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs.meta new file mode 100644 index 00000000..c118c2b5 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e7b01c5b166445d680dc411dfbe5c781 +timeCreated: 1689576203 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs new file mode 100644 index 00000000..03fdeb69 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs @@ -0,0 +1,15 @@ +namespace GameLogic.BattleDemo +{ + public class PlayerEntity : EntityLogic + { + public override void OnCreate() + { + base.OnCreate(); + } + + public override void Dispose() + { + base.Dispose(); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs.meta new file mode 100644 index 00000000..1fee6445 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9939517fe9f04f0d9c0c544fbdd43564 +timeCreated: 1689576650 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual.meta new file mode 100644 index 00000000..de49e3a1 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fad718b498934a5d8c63aa6d1e115485 +timeCreated: 1689576347 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/EntityVisual.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/EntityVisual.cs new file mode 100644 index 00000000..a7be02aa --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/EntityVisual.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// 表现层实体。 + /// + public abstract class EntityVisual:MonoBehaviour + { + public EntityLogic Entity { protected set; get;} + + + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/EntityVisual.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/EntityVisual.cs.meta new file mode 100644 index 00000000..c1cfb725 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/EntityVisual.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 892288dabf264b20b49b03ae91ccf5f8 +timeCreated: 1689576255 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs b/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs index 9f09fb6b..bbb8447c 100644 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs +++ b/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs @@ -46,7 +46,7 @@ namespace GameLogic public GameClientStatus Status { get; set; } = GameClientStatus.StatusInit; public Scene Scene { private set; get; } - private string _lastAddress = null; + private string _lastAddress = String.Empty; public GameClient() { diff --git a/Assets/TEngine/Runtime/Utility/EnumHelper.cs b/Assets/TEngine/Runtime/Utility/EnumHelper.cs new file mode 100644 index 00000000..c59a155e --- /dev/null +++ b/Assets/TEngine/Runtime/Utility/EnumHelper.cs @@ -0,0 +1,30 @@ +using System; + +namespace TEngine +{ + public static class EnumHelper + { + public static int EnumIndex(int value) + { + int i = 0; + foreach (object v in Enum.GetValues(typeof (T))) + { + if ((int) v == value) + { + return i; + } + ++i; + } + return -1; + } + + public static T FromString(string str) + { + if (!Enum.IsDefined(typeof(T), str)) + { + return default(T); + } + return (T)Enum.Parse(typeof(T), str); + } + } +} \ No newline at end of file diff --git a/Assets/TEngine/Runtime/Utility/EnumHelper.cs.meta b/Assets/TEngine/Runtime/Utility/EnumHelper.cs.meta new file mode 100644 index 00000000..1daa6980 --- /dev/null +++ b/Assets/TEngine/Runtime/Utility/EnumHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2638994be90d44a583fe978f8b92664d +timeCreated: 1689578753 \ No newline at end of file