diff options
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts')
26 files changed, 464 insertions, 55 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Battle/Metadata/StageMetadata.cs b/WorldlineKeepers/Assets/Scripts/Battle/Metadata/StageMetadata.cs index 4a2afdb..240f95b 100644 --- a/WorldlineKeepers/Assets/Scripts/Battle/Metadata/StageMetadata.cs +++ b/WorldlineKeepers/Assets/Scripts/Battle/Metadata/StageMetadata.cs @@ -9,7 +9,7 @@ namespace WK.Data public class EntityTransform { public Vector3 localPosition; - public Quaternion localRotation; + public Vector3 localRotation; public Vector3 localScale; } @@ -19,6 +19,7 @@ namespace WK.Data public abstract class StageEntityMetadata { public string entityId; // 用来引用场景中的对象 + public string entityName; // public EntityTransform entityTransform; } @@ -27,17 +28,39 @@ namespace WK.Data public string fileKey; // 背景图的资源名 } + public class StageEntityMetadata_SingleCollider + { + public StageEntity_Collider.ColliderShape shape; + public ColliderType type; + public Vector2 offset; + public Vector2 size; + public float radius; + } + + public sealed class StageEntityMetadata_Collider : StageEntityMetadata + { + public List<StageEntityMetadata_SingleCollider> colliders; + } + /// <summary> /// 关卡元数据 /// </summary> public class StageMetadata { - public List<string> tests; - public Vector3 pos; - public int count; - - public List<StageEntityMetadata_Background> backgrounds; + public List<StageEntityMetadata_Background> backgrounds = new List<StageEntityMetadata_Background>(); + public List<StageEntityMetadata_Collider> colliders = new List<StageEntityMetadata_Collider>(); + public void Write(StageEntityMetadata meta) + { + if(meta is StageEntityMetadata_Background) + { + backgrounds.Add(meta as StageEntityMetadata_Background); + } + else if (meta is StageEntityMetadata_Collider) + { + colliders.Add(meta as StageEntityMetadata_Collider); + } + } } } diff --git a/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs b/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs new file mode 100644 index 0000000..3ce2663 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using System.IO; +using UnityEngine; + +public static class CommonFunction +{ + + public static void WriteFile(string content, string file) + { + if(File.Exists(file)) + { + File.Delete(file); + } + + File.WriteAllText(file, content); + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs.meta b/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs.meta new file mode 100644 index 0000000..d61d02b --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b9a3413ddfeae9d48b8e4f5983bf3484 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Func.cs b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Func.cs new file mode 100644 index 0000000..da84bad --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Func.cs @@ -0,0 +1,22 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK.Data +{ + + public partial class DataManager : Singleton<DataManager> + { + + public FileDescriptor GetFile(string filekey) + { + FileDescriptor descriptor; + if(m_Filelist.TryGetValue(filekey, out descriptor)) + { + return m_Filelist[filekey]; + } + return null; + } + + } +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Func.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Func.cs.meta new file mode 100644 index 0000000..b324431 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Func.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d3bd86dfb681bd544928fa409fe503a1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs index b7fb0b9..e5b78b4 100644 --- a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs +++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs @@ -17,10 +17,10 @@ namespace WK.Data /// <returns></returns> public CoroutineHandle AsyncLoadAll() { - return Timing.Instance.RunCoroutineOnInstance(AsyncLoadAllData()); + return Timing.Instance.RunCoroutineOnInstance(CoLoadAllData()); } - private IEnumerator<float> AsyncLoadAllData() + private IEnumerator<float> CoLoadAllData() { Load_Filelist(); yield return Timing.WaitForSeconds(StaticDefine.IntervalLoadFile); @@ -33,9 +33,7 @@ namespace WK.Data { TextAsset text = ResourceManager.Instance.LoadAsset<TextAsset>(StaticDefine.FileList); string content = text.text; - List<FileDescriptor> files = CSVReader.Read<FileDescriptor>(content); CSVReader.ReadDictionary<string, FileDescriptor>(m_Filelist, content, "key"); - Debug.Log(m_Filelist.Count); } diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs index 2fdff3f..51d4d20 100644 --- a/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs +++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs @@ -8,6 +8,7 @@ namespace WK.Data default_stats, default_buffs, default_items, + spr_milk_bg, all } diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs index c4ae257..a9f50b2 100644 --- a/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs +++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs @@ -13,6 +13,7 @@ namespace WK.Data CSV = 0, Json = 1, Txt = 2, + Png = 3, } /// <summary> diff --git a/WorldlineKeepers/Assets/Scripts/Managers/ResourceManager.cs b/WorldlineKeepers/Assets/Scripts/Managers/ResourceManager.cs index 4b318ca..0fd18df 100644 --- a/WorldlineKeepers/Assets/Scripts/Managers/ResourceManager.cs +++ b/WorldlineKeepers/Assets/Scripts/Managers/ResourceManager.cs @@ -1,9 +1,12 @@ +using LitJson; using System.Collections; using System.Collections.Generic; +using System.IO; #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; +using WK.Data; namespace WK { @@ -25,7 +28,36 @@ namespace WK #endif } + /// <summary> + /// 根据filekey读资源 + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="fileKey"></param> + /// <returns></returns> + public T LoadFile<T>(string fileKey) where T : UnityEngine.Object + { + FileDescriptor file = DataManager.Instance.GetFile(fileKey); + if (file == null) + return default(T); + if(file.root == FileRoot.Bundle) + { +#if UNITY_EDITOR + string tmp = kAssetRoot + file.path; + T obj = AssetDatabase.LoadAssetAtPath(tmp, typeof(T)) as T; + return obj; +#endif + } + return null; + //else if(file.root == FileRoot.Persistent) + //{ + // string tmp = Application.persistentDataPath + "/" + file.path; + //} + //else if(file.root == FileRoot.Streaming) + //{ + + //} + } } diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GamePhase_Dojo.cs b/WorldlineKeepers/Assets/Scripts/Phase/GamePhase_Dojo.cs index 10dd785..5ae681c 100644 --- a/WorldlineKeepers/Assets/Scripts/Phase/GamePhase_Dojo.cs +++ b/WorldlineKeepers/Assets/Scripts/Phase/GamePhase_Dojo.cs @@ -20,20 +20,6 @@ namespace WK { yield return 0f; } - //SceneMetadata stage = new SceneMetadata(); - //stage.tests = new List<string>() - //{ - // "asdas","asdasd","asdsd" - //}; - //stage.desc = new SceneDesc(); - //stage.desc.name = "namestage"; - //stage.desc.desc = "descddd"; - //stage.pos = new Vector3(1, 2, 3); - //stage.count = 233; - //string json = JsonMapper.ToJson(stage); - //LogHelper.Log(json); - //var s = JsonMapper.ToObject<SceneMetadata>(json); - //Debug.Log(s.pos); } public override IEnumerator<float> OnEnd() diff --git a/WorldlineKeepers/Assets/Scripts/Physics/FastBoxCollider.cs b/WorldlineKeepers/Assets/Scripts/Physics/FastBoxCollider.cs index a644b69..696aaa9 100644 --- a/WorldlineKeepers/Assets/Scripts/Physics/FastBoxCollider.cs +++ b/WorldlineKeepers/Assets/Scripts/Physics/FastBoxCollider.cs @@ -3,13 +3,15 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class FastBoxCollider : MonoBehaviour, IQuadTreeObject +public class FastBoxCollider : FastColliderBase, IQuadTreeObject { [SerializeField] private ColliderType m_Type; [SerializeField] private Vector2 m_Offset; [SerializeField] private Vector2 m_Size; + public ColliderType type { get { return m_Type; } set { m_Type = value; } } + public Vector2 center { get @@ -19,8 +21,8 @@ public class FastBoxCollider : MonoBehaviour, IQuadTreeObject } } - public Vector2 offset => m_Offset; - public Vector2 size => m_Size; + public Vector2 offset { get { return m_Offset; } set { m_Offset = value; } } + public Vector2 size { get { return m_Size; } set { m_Size = value; } } public Vector4 bound { diff --git a/WorldlineKeepers/Assets/Scripts/Physics/FastCircleCollider.cs b/WorldlineKeepers/Assets/Scripts/Physics/FastCircleCollider.cs index 5f04a9f..2e67e42 100644 --- a/WorldlineKeepers/Assets/Scripts/Physics/FastCircleCollider.cs +++ b/WorldlineKeepers/Assets/Scripts/Physics/FastCircleCollider.cs @@ -3,13 +3,15 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class FastCircleCollider : MonoBehaviour, IQuadTreeObject +public class FastCircleCollider : FastColliderBase, IQuadTreeObject { [SerializeField] private ColliderType m_Type; [SerializeField] private float m_Radius; [SerializeField] private Vector2 m_Offset; + public ColliderType type { get { return m_Type; } set { m_Type = value; } } + public Vector2 center { get @@ -19,7 +21,7 @@ public class FastCircleCollider : MonoBehaviour, IQuadTreeObject } } - public float radius => m_Radius; + public float radius { get { return m_Radius; } set { m_Radius = value; } } public Vector4 bound { @@ -48,7 +50,7 @@ public class FastCircleCollider : MonoBehaviour, IQuadTreeObject } } - public Vector2 offset => m_Offset; + public Vector2 offset { get { return m_Offset; } set { m_Offset = value; } } public void Awake() { diff --git a/WorldlineKeepers/Assets/Scripts/Physics/FastColliderBase.cs b/WorldlineKeepers/Assets/Scripts/Physics/FastColliderBase.cs new file mode 100644 index 0000000..a577b53 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Physics/FastColliderBase.cs @@ -0,0 +1,8 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FastColliderBase : MonoBehaviour +{ + +} diff --git a/WorldlineKeepers/Assets/Scripts/Physics/FastColliderBase.cs.meta b/WorldlineKeepers/Assets/Scripts/Physics/FastColliderBase.cs.meta new file mode 100644 index 0000000..d0cdcb5 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Physics/FastColliderBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b08f2a4c34f47e641baf8b930aa75c1d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntityBase.cs b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntityBase.cs index 43680f5..052fbfa 100644 --- a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntityBase.cs +++ b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntityBase.cs @@ -1,5 +1,7 @@ +using LitJson; using System.Collections; using System.Collections.Generic; +using UnityEditor.PackageManager.Requests; using UnityEditorInternal; using UnityEngine; using WK.Data; @@ -13,6 +15,16 @@ namespace WK public abstract class StageEntityBase : MonoBehaviour { + protected virtual void Reset() + { + LogHelper.Log("Reset"); + + StageEntityMetadata data = OnSerialize(); + string json = JsonMapper.ToJson(data); + LogHelper.Log(json); + + } + public abstract StageEntityMetadata OnSerialize(); public abstract void OnDeserialize(StageEntityMetadata metadata); @@ -21,9 +33,17 @@ namespace WK { entityTransform = new EntityTransform(); entityTransform.localPosition = transform.localPosition; - entityTransform.localRotation = transform.localRotation; + entityTransform.localRotation = transform.localRotation.eulerAngles; entityTransform.localScale = transform.localScale; - } + } + + protected void RestoreTransform(StageEntityMetadata metadata) + { + var trans = metadata.entityTransform; + transform.localPosition = trans.localPosition; + transform.localScale = trans.localScale; + transform.localRotation = Quaternion.Euler(trans.localRotation); + } } diff --git a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Background.cs b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Background.cs index 9eae6ab..08b0fa3 100644 --- a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Background.cs +++ b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Background.cs @@ -7,6 +7,7 @@ using WK.Data; [RequireComponent(typeof(SpriteRenderer))] public class StageEntity_Background : StageEntityBase { + public string fileKey; public override StageEntityMetadata OnSerialize() { @@ -14,11 +15,24 @@ public class StageEntity_Background : StageEntityBase SaveTransform(out bg.entityTransform); + bg.fileKey = fileKey; + return bg; } public override void OnDeserialize(StageEntityMetadata metadata) { + StageEntityMetadata_Background bg = metadata as StageEntityMetadata_Background; + if (bg == null) + return; + + fileKey = bg.fileKey; + + RestoreTransform(bg); + + SpriteRenderer renderer = this.gameObject.GetOrAddComponent<SpriteRenderer>(); + Sprite sprite = ResourceManager.Instance.LoadFile<Sprite>(bg.fileKey); + renderer.sprite = sprite; } } diff --git a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Collider.cs b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Collider.cs index 0065562..64c3fc6 100644 --- a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Collider.cs +++ b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Collider.cs @@ -1,39 +1,99 @@ +using mh; using System.Collections; using System.Collections.Generic; +using Unity.VisualScripting; using UnityEngine; using WK; using WK.Data; +/// <summary> +/// 鍦烘櫙纰版挒浣 +/// </summary> public class StageEntity_Collider : StageEntityBase { - public override void OnDeserialize(StageEntityMetadata metadata) + public enum ColliderShape { - throw new System.NotImplementedException(); + ColliderShape_Box = 1, + ColliderShape_Circle = 2, } - public override StageEntityMetadata OnSerialize() + public override void OnDeserialize(StageEntityMetadata arg) { - throw new System.NotImplementedException(); + StageEntityMetadata_Collider metadata = arg as StageEntityMetadata_Collider; + if (metadata == null) + return; + var colliders = metadata.colliders; + if (colliders == null || colliders.Count == 0) + return; + RestoreTransform(arg); + for(int i = 0; i < colliders.Count; i++) + { + var col = colliders[i]; + if (col == null) + continue; + if (col.shape == ColliderShape.ColliderShape_Box) + { + FastBoxCollider box = gameObject.AddComponent<FastBoxCollider>(); + box.type = col.type; + box.offset = col.offset; + box.size = col.size; + } + else if (col.shape == ColliderShape.ColliderShape_Circle) + { + FastCircleCollider circle = gameObject.AddComponent<FastCircleCollider>(); + circle.type = col.type; + circle.radius = col.radius; + circle.offset = col.offset; + } + else + { + LogHelper.LogError("Unkown collider type"); + } + } } - #region 搴忓垪鍖 - - #endregion - - #region 鍏叡瀛楁 - - #endregion - - #region 绉佹湁瀛楁 - #endregion - - private void Awake() - { - // 绉佹湁瀛楁璧嬪 - - // 鍏叡瀛楁璧嬪 - - // 鍒濆鍖 - } + public override StageEntityMetadata OnSerialize() + { + StageEntityMetadata_Collider metadata = new StageEntityMetadata_Collider(); + metadata.colliders = new List<StageEntityMetadata_SingleCollider>(); + SaveTransform(out metadata.entityTransform); + IQuadTreeObject[] cols = GetComponents<IQuadTreeObject>(); + if(cols != null && cols.Length > 0) + { + for(int i = 0; i < cols.Length; ++i) + { + IQuadTreeObject col = cols[i]; + if (col == null) + continue; + StageEntityMetadata_SingleCollider meta = new StageEntityMetadata_SingleCollider(); + if(col is FastBoxCollider) + { + meta.shape = ColliderShape.ColliderShape_Box; + FastBoxCollider box = col as FastBoxCollider; + meta.type = box.type; + meta.offset = box.offset; + meta.size = box.size; + } + else if(col is FastCircleCollider) + { + meta.shape = ColliderShape.ColliderShape_Circle; + FastCircleCollider circle = col as FastCircleCollider; + meta.type = circle.type; + meta.radius = circle.radius; + meta.offset = circle.offset; + } + else + { + LogHelper.LogError("Unkown collider type"); + } + metadata.colliders.Add(meta); + } + } + else + { + return null; + } + return metadata; + } } diff --git a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Trigger.cs b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Trigger.cs new file mode 100644 index 0000000..bdbbfd3 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Trigger.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using WK; +using WK.Data; + +public class StageEntity_Trigger : StageEntityBase +{ + public override void OnDeserialize(StageEntityMetadata metadata) + { + } + + public override StageEntityMetadata OnSerialize() + { + return null; + } +} diff --git a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Trigger.cs.meta b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Trigger.cs.meta new file mode 100644 index 0000000..6f5519c --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Trigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8aa58c79e14e11944bbf1ccbedf63041 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs b/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs new file mode 100644 index 0000000..d117779 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs @@ -0,0 +1,40 @@ +using JetBrains.Annotations; +using MovementEffects; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using WK; +using WK.Data; + +/// <summary> +/// 构建关卡 +/// </summary> +public class StageBuilder : Singleton<StageBuilder> +{ + + public CoroutineHandle AsyncBuildStage(StageMetadata metadata, Transform root = null) + { + return Timing.Instance.RunCoroutineOnInstance(CoBuildStage(metadata, root)); + } + + private void Build<TYPE_ENTITY, TYPE_META>(List<TYPE_META> metadatas, Transform root = null) where TYPE_ENTITY : StageEntityBase where TYPE_META : StageEntityMetadata + { + for(int i = 0; i < metadatas.Count; ++i) + { + TYPE_META meta = metadatas[i]; + GameObject go = new GameObject(); + if(root != null) + go.transform.SetParent(root); + var entity = go.AddComponent<TYPE_ENTITY>(); + entity.OnDeserialize(meta); + } + } + + private IEnumerator<float> CoBuildStage(StageMetadata metadata, Transform root = null) + { + Build<StageEntity_Background, StageEntityMetadata_Background>(metadata.backgrounds, root); + Build<StageEntity_Collider, StageEntityMetadata_Collider>(metadata.colliders, root); + yield return Timing.WaitForSeconds(StaticDefine.IntervalBuildStage); + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs.meta b/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs.meta new file mode 100644 index 0000000..5194c06 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e16177dd5b2b54f41baaa724016782e8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs index b772d86..f2a9156 100644 --- a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs +++ b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs @@ -11,6 +11,7 @@ namespace WK public class StaticDefine { public const float IntervalLoadFile = 0.1f; + public const float IntervalBuildStage = 0.1f; public static string StatsFilePath = "metadata/default_stats.csv"; public static string BuffFilePath = "metadata/default_buffs.csv"; diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Info.cs b/WorldlineKeepers/Assets/Scripts/Tools/Info.cs new file mode 100644 index 0000000..50e2d42 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/Info.cs @@ -0,0 +1,40 @@ + +public class Info<T0> +{ + public T0 arg0; + + public Info(T0 arg0) + { + this.arg0 = arg0; + } +} +public class Info<T0, T1> : Info<T0> +{ + public T1 arg1; + + public Info(T0 arg0, T1 arg1) + : base(arg0) + { + this.arg1 = arg1; + } +} +public class Info<T0, T1, T2> : Info<T0, T1> +{ + public T2 arg2; + + public Info(T0 arg0, T1 arg1, T2 arg2) + : base(arg0, arg1) + { + this.arg2 = arg2; + } +} +public class Info<T0, T1, T2, T3> : Info<T0, T1, T2> +{ + public T3 arg3; + + public Info(T0 arg0, T1 arg1, T2 arg2, T3 arg3) + : base(arg0, arg1, arg2) + { + this.arg3 = arg3; + } +} diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Info.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/Info.cs.meta new file mode 100644 index 0000000..4c72025 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/Info.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c5d784cbfaf251f4ba650732770efde9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs b/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs new file mode 100644 index 0000000..84ce560 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs @@ -0,0 +1,46 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public static class GameObjectExtensions +{ + public static void SetParent(this GameObject obj, Transform parent) + { + if (!(obj == null)) + { + obj.transform.SetParent(parent); + } + } + + public static GameObject Find(this GameObject obj, string name) + { + if (obj == null) + { + return null; + } + + Transform transform = obj.transform.Find(name); + if (!(transform != null)) + { + return null; + } + + return transform.gameObject; + } + + public static T GetOrAddComponent<T>(this GameObject go) where T : Component + { + if (go == null) + { + return null; + } + + T val = go.GetComponent<T>(); + if ((Object)val == (Object)null) + { + val = go.AddComponent<T>(); + } + + return val; + } +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs.meta b/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs.meta new file mode 100644 index 0000000..2dd16b6 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 460610b6a0fd5e14ba71f016385ca356 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |