자동화 툴 작업 중
This commit is contained in:
parent
4e1ccec596
commit
f1c8b49d52
@ -58,9 +58,13 @@ MonoBehaviour:
|
|||||||
- SingularityGroup.HotReload.Runtime.Public
|
- SingularityGroup.HotReload.Runtime.Public
|
||||||
- Sirenix.OdinInspector.Modules.Unity.Addressables
|
- Sirenix.OdinInspector.Modules.Unity.Addressables
|
||||||
- Sirenix.OdinInspector.Modules.UnityLocalization
|
- Sirenix.OdinInspector.Modules.UnityLocalization
|
||||||
|
- SLLogger
|
||||||
|
- SLSystem
|
||||||
|
- SLUnity
|
||||||
- spine-csharp
|
- spine-csharp
|
||||||
- spine-unity
|
- spine-unity
|
||||||
- spine-unity-examples
|
- spine-unity-examples
|
||||||
|
- UnitSystem
|
||||||
showAdvancedSettings: 0
|
showAdvancedSettings: 0
|
||||||
addMgrToSceneAutomatically: 0
|
addMgrToSceneAutomatically: 0
|
||||||
autoUpdateReferences: 1
|
autoUpdateReferences: 1
|
||||||
|
@ -231,7 +231,8 @@ private void RenderReflections(ScriptableRenderContext context, Camera camera)
|
|||||||
QualitySettings.lodBias = lodBiasBeforeReflections * 0.5f;
|
QualitySettings.lodBias = lodBiasBeforeReflections * 0.5f;
|
||||||
|
|
||||||
//render
|
//render
|
||||||
UniversalRenderPipeline.RenderSingleCamera(context, reflectionCamera);
|
//UniversalRenderPipeline.RenderSingleCamera(context, reflectionCamera);
|
||||||
|
RenderPipeline.SubmitRenderRequest(reflectionCamera, context);
|
||||||
|
|
||||||
//restore quality settings
|
//restore quality settings
|
||||||
GL.invertCulling = false;
|
GL.invertCulling = false;
|
||||||
|
8
Assets/_Datas/02.Scripts/AssetPostprocessor.meta
Normal file
8
Assets/_Datas/02.Scripts/AssetPostprocessor.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9907ae9e89d078f42b31833612011df5
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,77 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DDD
|
||||||
|
{
|
||||||
|
public class AssetPostProcessor : AssetPostprocessor
|
||||||
|
{
|
||||||
|
private void OnPreprocessTexture()
|
||||||
|
{
|
||||||
|
var importer = assetImporter as TextureImporter;
|
||||||
|
|
||||||
|
var upperPath = importer.assetPath.ToUpper();
|
||||||
|
|
||||||
|
// if (upperPath.Contains("ASSETS/RAW/Units/"))
|
||||||
|
// {
|
||||||
|
// AssetPostprocessorModel.OnPreprocessTexture(importer);
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (upperPath.Contains("ASSETS/_DATAS/RAW/SPRITES/"))
|
||||||
|
{
|
||||||
|
AssetPostprocessorSprite.OnPreprocessTexture(importer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnPostprocessAllAssets(string[] importedAssets, string[] deleteAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
||||||
|
{
|
||||||
|
foreach (var path in deleteAssets)
|
||||||
|
{
|
||||||
|
PostRemove(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
foreach (var path in movedFromAssetPaths)
|
||||||
|
{
|
||||||
|
PostRemove(path, movedAssets[index]);
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var path in movedAssets)
|
||||||
|
{
|
||||||
|
PostAdd(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var path in importedAssets)
|
||||||
|
{
|
||||||
|
PostAdd(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetPostprocessorSprite.BuildTarget();
|
||||||
|
AssetPostprocessorSprite.BuildTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PostRemove(string path, string movePath = "")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AssetPostprocessorSprite.OnRemove(path, movePath);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError("Can't remove " + path + "\n" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PostAdd(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AssetPostprocessorSprite.OnAdd(path);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError("Can't import " + path + "\n" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0027aa4e810904745aab9cda1a5e11be
|
@ -0,0 +1,290 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Superlazy;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.U2D;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.U2D;
|
||||||
|
|
||||||
|
namespace DDD
|
||||||
|
{
|
||||||
|
public static class AssetPostprocessorSprite
|
||||||
|
{
|
||||||
|
private static readonly HashSet<string> TargetPaths = new HashSet<string>();
|
||||||
|
|
||||||
|
public static void OnPreprocessTexture(TextureImporter importer)
|
||||||
|
{
|
||||||
|
importer.textureType = TextureImporterType.Sprite;
|
||||||
|
importer.spriteImportMode = SpriteImportMode.Single;
|
||||||
|
|
||||||
|
importer.GetSourceTextureWidthAndHeight(out var width, out var height);
|
||||||
|
importer.spritePixelsPerUnit = width <= height ? width : height;
|
||||||
|
|
||||||
|
importer.sRGBTexture = true;
|
||||||
|
importer.isReadable = false;
|
||||||
|
importer.mipmapEnabled = false;
|
||||||
|
importer.streamingMipmaps = false;
|
||||||
|
importer.wrapMode = TextureWrapMode.Clamp;
|
||||||
|
importer.filterMode = FilterMode.Bilinear;
|
||||||
|
|
||||||
|
importer.textureCompression = TextureImporterCompression.Uncompressed;
|
||||||
|
importer.crunchedCompression = false;
|
||||||
|
|
||||||
|
var textureSettings = new TextureImporterSettings();
|
||||||
|
importer.ReadTextureSettings(textureSettings);
|
||||||
|
textureSettings.spriteMeshType = SpriteMeshType.FullRect;
|
||||||
|
textureSettings.spriteExtrude = 2;
|
||||||
|
importer.SetTextureSettings(textureSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnRemove(string path, string movePath)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (upperPath.Contains("ASSETS/_DATAS/RAW/SPRITES/") == false ||
|
||||||
|
upperPath.Contains(".PNG") == false) return;
|
||||||
|
|
||||||
|
if (TargetPaths.Contains(path) == false)
|
||||||
|
{
|
||||||
|
TargetPaths.Add(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnAdd(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (upperPath.Contains("ASSETS/_DATAS/RAW/SPRITES/") == false ||
|
||||||
|
upperPath.Contains(".PNG") == false) return;
|
||||||
|
|
||||||
|
if (TargetPaths.Contains(path) == false)
|
||||||
|
{
|
||||||
|
TargetPaths.Add(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateAtlas(string path, string destPath)
|
||||||
|
{
|
||||||
|
var oldAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(destPath);
|
||||||
|
|
||||||
|
if (oldAtlas != null)
|
||||||
|
{
|
||||||
|
AssetDatabase.DeleteAsset(destPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var di = new DirectoryInfo(path);
|
||||||
|
if (di.Exists == false) return;
|
||||||
|
|
||||||
|
var objects = new List<Object>();
|
||||||
|
foreach (var file in di.GetFiles())
|
||||||
|
{
|
||||||
|
if (file.Name.ToUpper().IsRight(".PNG") == false) continue;
|
||||||
|
var filePath = path + "/" + file.Name;
|
||||||
|
var fileName = file.Name.Substring(0, file.Name.Length - ".png".Length);
|
||||||
|
var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(filePath);
|
||||||
|
|
||||||
|
var maxSize = sprite.rect.size.x > sprite.rect.size.y ? sprite.rect.size.x : sprite.rect.size.y;
|
||||||
|
if (maxSize > 1024)
|
||||||
|
{
|
||||||
|
CreateSingleAtlas(filePath, path.Replace("/Raw/", "/Addressables/") + $"_{fileName}.spriteatlasv2");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
objects.Add(sprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objects.Count == 0) return;
|
||||||
|
|
||||||
|
Utils.MakeFolderFromFilePath(destPath);
|
||||||
|
var atlas = new SpriteAtlasAsset();
|
||||||
|
|
||||||
|
var spriteAtlasComponents = new List<IPostProcessorSpriteAtlas>();
|
||||||
|
spriteAtlasComponents.CreateInstanceList();
|
||||||
|
foreach (var component in spriteAtlasComponents)
|
||||||
|
{
|
||||||
|
component.OnAddSprite(atlas);
|
||||||
|
}
|
||||||
|
|
||||||
|
atlas.Add(objects.ToArray());
|
||||||
|
|
||||||
|
SpriteAtlasAsset.Save(atlas, destPath);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
|
||||||
|
var sai = (SpriteAtlasImporter)AssetImporter.GetAtPath(destPath);
|
||||||
|
sai.packingSettings = new SpriteAtlasPackingSettings
|
||||||
|
{
|
||||||
|
enableRotation = false,
|
||||||
|
enableTightPacking = false,
|
||||||
|
enableAlphaDilation = false,
|
||||||
|
padding = 4,
|
||||||
|
blockOffset = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
sai.textureSettings = new SpriteAtlasTextureSettings
|
||||||
|
{
|
||||||
|
filterMode = FilterMode.Bilinear,
|
||||||
|
sRGB = true,
|
||||||
|
generateMipMaps = false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateSingleAtlas(string path, string destPath)
|
||||||
|
{
|
||||||
|
var oldAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(destPath);
|
||||||
|
|
||||||
|
if (oldAtlas != null)
|
||||||
|
{
|
||||||
|
AssetDatabase.DeleteAsset(destPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.MakeFolderFromFilePath(destPath);
|
||||||
|
var atlas = new SpriteAtlasAsset();
|
||||||
|
|
||||||
|
var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
||||||
|
atlas.Add(new Object[] { sprite });
|
||||||
|
|
||||||
|
var spriteAtlasComponents = new List<IPostProcessorSpriteAtlas>();
|
||||||
|
spriteAtlasComponents.CreateInstanceList();
|
||||||
|
foreach (var component in spriteAtlasComponents)
|
||||||
|
{
|
||||||
|
component.OnAddSprite(atlas);
|
||||||
|
}
|
||||||
|
|
||||||
|
SpriteAtlasAsset.Save(atlas, destPath);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
|
||||||
|
var sai = (SpriteAtlasImporter)AssetImporter.GetAtPath(destPath);
|
||||||
|
sai.packingSettings = new SpriteAtlasPackingSettings
|
||||||
|
{
|
||||||
|
enableRotation = false,
|
||||||
|
enableTightPacking = false,
|
||||||
|
enableAlphaDilation = false,
|
||||||
|
padding = 4,
|
||||||
|
blockOffset = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
sai.textureSettings = new SpriteAtlasTextureSettings
|
||||||
|
{
|
||||||
|
filterMode = FilterMode.Bilinear,
|
||||||
|
sRGB = true,
|
||||||
|
generateMipMaps = false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreatePrefab(string path, string destPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var spriteCreateComponents = new List<IPostProcessorSpriteAtlas>();
|
||||||
|
spriteCreateComponents.CreateInstanceList();
|
||||||
|
var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
||||||
|
|
||||||
|
if (sprite == null) return;
|
||||||
|
|
||||||
|
GameObject prefab = new GameObject(sprite.name);
|
||||||
|
prefab.transform.localPosition = Vector3.zero;
|
||||||
|
prefab.transform.localRotation = Quaternion.identity;
|
||||||
|
prefab.name = sprite.name;
|
||||||
|
|
||||||
|
GameObject visualLook = new GameObject("VisualLook");
|
||||||
|
|
||||||
|
visualLook.transform.SetParent(prefab.transform);
|
||||||
|
visualLook.transform.localPosition = Vector3.zero;
|
||||||
|
visualLook.transform.localRotation = Quaternion.Euler(new Vector3(40f, 0f, 0f));
|
||||||
|
|
||||||
|
SpriteRenderer spriteRenderer = visualLook.AddComponent<SpriteRenderer>();
|
||||||
|
spriteRenderer.sprite = sprite;
|
||||||
|
spriteRenderer.sortingOrder = 5;
|
||||||
|
|
||||||
|
// var guids = AssetDatabase.FindAssets("t:Material", new string[] { Utils.FolderPath(path) });
|
||||||
|
// var materials = guids
|
||||||
|
// .Select(guid => AssetDatabase.LoadAssetAtPath<Material>(AssetDatabase.GUIDToAssetPath(guid)))
|
||||||
|
// .ToDictionary(m => m.name);
|
||||||
|
//
|
||||||
|
// foreach (var renderer in model.GetComponentsInChildren<Renderer>())
|
||||||
|
// {
|
||||||
|
// var sharedMaterials =
|
||||||
|
// new Material[renderer.sharedMaterials.Length]; // Material을 직접 엘리먼트로 대입하면 안되고 배열을 통으로 넣어야함
|
||||||
|
// for (var i = 0; i < renderer.sharedMaterials.Length; ++i)
|
||||||
|
// {
|
||||||
|
// if (materials.TryGetValue($"{renderer.name}_{i + 1}", out var numMat))
|
||||||
|
// {
|
||||||
|
// sharedMaterials[i] = numMat;
|
||||||
|
// }
|
||||||
|
// else if (materials.TryGetValue(renderer.name, out var mat))
|
||||||
|
// {
|
||||||
|
// sharedMaterials[i] = mat;
|
||||||
|
// }
|
||||||
|
// else if (materials.TryGetValue(go.name, out var defaultMat))
|
||||||
|
// {
|
||||||
|
// sharedMaterials[i] = defaultMat;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// sharedMaterials[i] = renderer.sharedMaterials[i];
|
||||||
|
// // 에러인가? 잠깐 파일 안갖다놨을뿐인가?
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// renderer.sharedMaterials = sharedMaterials;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var res = prefab.AddComponent<SLResourceObject>();
|
||||||
|
|
||||||
|
//res.Init();
|
||||||
|
|
||||||
|
Utils.MakeFolderFromFilePath(destPath);
|
||||||
|
|
||||||
|
// {
|
||||||
|
// // Make Duumy(for test)
|
||||||
|
// var dummyObj = Object.Instantiate(model);
|
||||||
|
// var anim = dummyObj.GetComponentInChildren<Animator>();
|
||||||
|
// var controller =
|
||||||
|
// AnimatorController.CreateAnimatorControllerAtPath(GetPrefabPath(path)
|
||||||
|
// .Replace(".prefab", ".controller"));
|
||||||
|
//
|
||||||
|
// anim.runtimeAnimatorController = controller;
|
||||||
|
// var rootStateMachine = controller.layers[0].stateMachine;
|
||||||
|
//
|
||||||
|
// var clipids = AssetDatabase.FindAssets("t:AnimationClip",
|
||||||
|
// new string[] { SLFileUtility.FolderPath(path) });
|
||||||
|
// foreach (var guid in clipids)
|
||||||
|
// {
|
||||||
|
// var clip = AssetDatabase.LoadAssetAtPath<AnimationClip>(AssetDatabase.GUIDToAssetPath(guid));
|
||||||
|
// if (clip != null)
|
||||||
|
// {
|
||||||
|
// var state = rootStateMachine.AddState(clip.name);
|
||||||
|
// state.motion = clip;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var dummy = PrefabUtility.SaveAsPrefabAssetAndConnect(dummyObj, GetPrefabPath(path),
|
||||||
|
// InteractionMode.AutomatedAction);
|
||||||
|
//
|
||||||
|
// Object.DestroyImmediate(dummyObj, false);
|
||||||
|
// }
|
||||||
|
|
||||||
|
AssetDatabase.DeleteAsset(destPath);
|
||||||
|
var newPrefab =
|
||||||
|
PrefabUtility.SaveAsPrefabAssetAndConnect(prefab, destPath, InteractionMode.AutomatedAction);
|
||||||
|
|
||||||
|
Object.DestroyImmediate(prefab, false);
|
||||||
|
Debug.Log("Build : " + destPath, newPrefab);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError("Cant build " + destPath + "\n" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BuildTarget()
|
||||||
|
{
|
||||||
|
foreach (var path in TargetPaths)
|
||||||
|
{
|
||||||
|
CreateAtlas(Utils.FolderPath(path), Utils.FolderPath(path).Replace("/Raw/", "/Addressables/") + ".spriteatlasv2");
|
||||||
|
CreatePrefab(path, (path.Replace("/Raw/Sprites/", "/Addressables/") + ".prefab").Replace(".png", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetPaths.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 076707aa8e0f8464b86a7927d71b98bf
|
45
Assets/_Datas/02.Scripts/Utils.cs
Normal file
45
Assets/_Datas/02.Scripts/Utils.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System.IO;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace DDD
|
||||||
|
{
|
||||||
|
public static class Utils
|
||||||
|
{
|
||||||
|
public static string FixPath(string path)
|
||||||
|
{
|
||||||
|
path = path.Replace('\\', '/');
|
||||||
|
path = path.Replace("//", "/");
|
||||||
|
while (path.Length > 0 && path[0] == '/')
|
||||||
|
{
|
||||||
|
path = path.Remove(0, 1);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FileName(string path)
|
||||||
|
{
|
||||||
|
return Path.GetFileNameWithoutExtension(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FolderPath(string path)
|
||||||
|
{
|
||||||
|
return FixPath(Path.GetDirectoryName(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MakeFolderFromFilePath(string filePath)
|
||||||
|
{
|
||||||
|
var paths = FixPath(filePath).Split('/');
|
||||||
|
var path = "";
|
||||||
|
|
||||||
|
for (var i = 0; i < paths.Length - 1; ++i)
|
||||||
|
{
|
||||||
|
path += paths[i] + "/";
|
||||||
|
if (Directory.Exists(path) == false)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
Assets/_Datas/02.Scripts/Utils.cs.meta
Normal file
2
Assets/_Datas/02.Scripts/Utils.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 854af13e3da02544a8778a7e8bebf2c0
|
8
Assets/_Datas/Addressables.meta
Normal file
8
Assets/_Datas/Addressables.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0a4e564e0ed0fc547963a94ea07f86e6
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
121
Assets/_Datas/Addressables/Barrel.prefab
Normal file
121
Assets/_Datas/Addressables/Barrel.prefab
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &5969173919338450677
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 8764769398795247692}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Barrel
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &8764769398795247692
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5969173919338450677}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 2842124097711829421}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &9076417642579187436
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 2842124097711829421}
|
||||||
|
- component: {fileID: 5861905487478007050}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: VisualLook
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &2842124097711829421
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 9076417642579187436}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0.34202015, y: 0, z: 0, w: 0.9396927}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 8764769398795247692}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!212 &5861905487478007050
|
||||||
|
SpriteRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 9076417642579187436}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 0
|
||||||
|
m_ReceiveShadows: 0
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 0
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||||
|
m_RayTracingAccelStructBuildFlags: 1
|
||||||
|
m_SmallMeshCulling: 1
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 0
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 5
|
||||||
|
m_Sprite: {fileID: 21300000, guid: eb70d7085c7b27d4a939289414a09cef, type: 3}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_FlipX: 0
|
||||||
|
m_FlipY: 0
|
||||||
|
m_DrawMode: 0
|
||||||
|
m_Size: {x: 1, y: 1}
|
||||||
|
m_AdaptiveModeThreshold: 0.5
|
||||||
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
|
m_MaskInteraction: 0
|
||||||
|
m_SpriteSortPoint: 0
|
7
Assets/_Datas/Addressables/Barrel.prefab.meta
Normal file
7
Assets/_Datas/Addressables/Barrel.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6ade463886ca5294685e2c4997a976b7
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
16
Assets/_Datas/Addressables/Sprites.spriteatlasv2
Normal file
16
Assets/_Datas/Addressables/Sprites.spriteatlasv2
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!612988286 &1
|
||||||
|
SpriteAtlasAsset:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_MasterAtlas: {fileID: 0}
|
||||||
|
m_ImporterData:
|
||||||
|
packables:
|
||||||
|
- {fileID: 21300000, guid: eb70d7085c7b27d4a939289414a09cef, type: 3}
|
||||||
|
m_IsVariant: 0
|
||||||
|
m_ScriptablePacker: {fileID: 0}
|
30
Assets/_Datas/Addressables/Sprites.spriteatlasv2.meta
Normal file
30
Assets/_Datas/Addressables/Sprites.spriteatlasv2.meta
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1f850df0adb104f4ba2a6c097152f6fa
|
||||||
|
SpriteAtlasImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
anisoLevel: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureCompression: 0
|
||||||
|
filterMode: 1
|
||||||
|
generateMipMaps: 0
|
||||||
|
readable: 0
|
||||||
|
crunchedCompression: 0
|
||||||
|
sRGB: 1
|
||||||
|
platformSettings: []
|
||||||
|
packingSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
padding: 4
|
||||||
|
blockOffset: 1
|
||||||
|
allowAlphaSplitting: 0
|
||||||
|
enableRotation: 1
|
||||||
|
enableTightPacking: 1
|
||||||
|
enableAlphaDilation: 0
|
||||||
|
secondaryTextureSettings: {}
|
||||||
|
variantMultiplier: 1
|
||||||
|
bindAsDefault: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/Raw.meta
Normal file
8
Assets/_Datas/Raw.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e332838ddcbf84743875b13dd197a48e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/Raw/Sprites.meta
Normal file
8
Assets/_Datas/Raw/Sprites.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7bc2bc9148f83834780431aee504cf69
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/_Datas/Raw/Sprites/Barrel.png
Normal file
BIN
Assets/_Datas/Raw/Sprites/Barrel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
143
Assets/_Datas/Raw/Sprites/Barrel.png.meta
Normal file
143
Assets/_Datas/Raw/Sprites/Barrel.png.meta
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eb70d7085c7b27d4a939289414a09cef
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 13
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
flipGreenChannel: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
ignoreMipmapLimit: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: 1
|
||||||
|
wrapW: 1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 2
|
||||||
|
spriteMeshType: 0
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 512
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
swizzle: 50462976
|
||||||
|
cookieLightType: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Android
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: WindowsStoreApps
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
customData:
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID: 5e97eb03825dee720800000000000000
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spriteCustomMetadata:
|
||||||
|
entries: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
mipmapLimitGroupName:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/SLShared.meta
Normal file
8
Assets/_Datas/SLShared.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 711a98d8afbbc1a4d8698262c2463ad2
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/_Datas/SLShared/Directory.Build.props
Normal file
9
Assets/_Datas/SLShared/Directory.Build.props
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<BaseIntermediateOutputPath>../obj/</BaseIntermediateOutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="$(MSBuildProjectName) == 'SLUnity'">
|
||||||
|
<UnityVersion>6000.1.5f1</UnityVersion>
|
||||||
|
<UnityProjectPath>../../ProjectIM/IMUnity/</UnityProjectPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
7
Assets/_Datas/SLShared/Directory.Build.props.meta
Normal file
7
Assets/_Datas/SLShared/Directory.Build.props.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dcd0ead37234ae04e8e8a382d49789c3
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/SLShared/SLLogger.meta
Normal file
8
Assets/_Datas/SLShared/SLLogger.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ef9524ee33df2ff4b96d774d118222a9
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
11
Assets/_Datas/SLShared/SLLogger/ISLLogger.cs
Normal file
11
Assets/_Datas/SLShared/SLLogger/ISLLogger.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public interface ISLLogger
|
||||||
|
{
|
||||||
|
void Info(string format, params object[] args);
|
||||||
|
|
||||||
|
void Warn(string format, params object[] args);
|
||||||
|
|
||||||
|
void Error(string format, params object[] args);
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLLogger/ISLLogger.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLLogger/ISLLogger.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f93bf8f3ffea29c4db3a7eabd0119ae6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
49
Assets/_Datas/SLShared/SLLogger/SLLog.cs
Normal file
49
Assets/_Datas/SLShared/SLLogger/SLLog.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public static class SLLog
|
||||||
|
{
|
||||||
|
public static ISLLogger Logger
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Loggers ??= new List<ISLLogger>();
|
||||||
|
Loggers.Add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<ISLLogger> Loggers { get; set; }
|
||||||
|
|
||||||
|
[Conditional("SLLOG"), Conditional("UNITY_EDITOR")]
|
||||||
|
public static void Error(string format, params object[] args)
|
||||||
|
{
|
||||||
|
if (Loggers == null) return;
|
||||||
|
foreach (var logger in Loggers)
|
||||||
|
{
|
||||||
|
logger.Error(format, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Conditional("SLLOG"), Conditional("UNITY_EDITOR")]
|
||||||
|
public static void Info(string format, params object[] args)
|
||||||
|
{
|
||||||
|
if (Loggers == null) return;
|
||||||
|
foreach (var logger in Loggers)
|
||||||
|
{
|
||||||
|
logger.Info(format, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Conditional("SLLOG"), Conditional("UNITY_EDITOR")]
|
||||||
|
public static void Warn(string format, params object[] args)
|
||||||
|
{
|
||||||
|
if (Loggers == null) return;
|
||||||
|
foreach (var logger in Loggers)
|
||||||
|
{
|
||||||
|
logger.Warn(format, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLLogger/SLLog.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLLogger/SLLog.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bea77d7b448102e49bfeebe6a3d23eaa
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
3
Assets/_Datas/SLShared/SLLogger/SLLogger.asmdef
Normal file
3
Assets/_Datas/SLShared/SLLogger/SLLogger.asmdef
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"name": "SLLogger"
|
||||||
|
}
|
7
Assets/_Datas/SLShared/SLLogger/SLLogger.asmdef.meta
Normal file
7
Assets/_Datas/SLShared/SLLogger/SLLogger.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f0e91edf4495c2045b34f001325cddb3
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
7
Assets/_Datas/SLShared/SLLogger/SLLogger.csproj.meta
Normal file
7
Assets/_Datas/SLShared/SLLogger/SLLogger.csproj.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a18b99084fc30604b9de617a181246f0
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/_Datas/SLShared/SLLogger/package.json
Normal file
9
Assets/_Datas/SLShared/SLLogger/package.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "com.superlazy.sllogger",
|
||||||
|
"displayName": "SL Logger",
|
||||||
|
"description": "SL Logger",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"unity": "2018.2",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
7
Assets/_Datas/SLShared/SLLogger/package.json.meta
Normal file
7
Assets/_Datas/SLShared/SLLogger/package.json.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2a5b4383d891a734aa2cbfaf1f4c1d4c
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/SLShared/SLSystem.meta
Normal file
8
Assets/_Datas/SLShared/SLSystem.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 76a47edf5a3c36a4fb5d877cd7d024e3
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
19
Assets/_Datas/SLShared/SLSystem/ComponentOrderAttribute.cs
Normal file
19
Assets/_Datas/SLShared/SLSystem/ComponentOrderAttribute.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||||
|
public class ComponentOrderAttribute : Attribute
|
||||||
|
{
|
||||||
|
public int order;
|
||||||
|
public string methodOverride;
|
||||||
|
|
||||||
|
public ComponentOrderAttribute(int order)
|
||||||
|
{
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentOrderAttribute(string methodOverride, int order)
|
||||||
|
{
|
||||||
|
this.order = order;
|
||||||
|
this.methodOverride = methodOverride;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 730f3af4df651064da4cd6a28965353e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
135
Assets/_Datas/SLShared/SLSystem/Evaluator.cs
Normal file
135
Assets/_Datas/SLShared/SLSystem/Evaluator.cs
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Superlazy;
|
||||||
|
|
||||||
|
public class Evaluator
|
||||||
|
{
|
||||||
|
public static string Evaluate(SLEntity player, string desc)
|
||||||
|
{
|
||||||
|
if (desc.StartsWith('$') == false) return desc;
|
||||||
|
|
||||||
|
// 변수 대체: {name} 패턴을 찾아 Global.Get으로 변환
|
||||||
|
var replacedDesc = Regex.Replace(desc.Substring(1), @"\{(\w+)\}", match =>
|
||||||
|
{
|
||||||
|
var varName = match.Groups[1].Value;
|
||||||
|
var ret = player["EventValues"].Get(varName); // 그냥 글로벌로 하면 변수 길어질듯해서
|
||||||
|
if (ret.IsValue && ret.IsNumeric == false) return $"\"{ret}\"";
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
});
|
||||||
|
|
||||||
|
return EvaluateExpression(replacedDesc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SLEntity EvaluateExpression(string expression)
|
||||||
|
{
|
||||||
|
var values = new Stack<SLEntity>(); // 값을 저장하는 스택 (숫자 또는 문자열)
|
||||||
|
var operators = new Stack<char>(); // 연산자를 저장하는 스택
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
while (i < expression.Length)
|
||||||
|
{
|
||||||
|
if (char.IsDigit(expression[i])) // 숫자 처리
|
||||||
|
{
|
||||||
|
var number = "";
|
||||||
|
while (i < expression.Length && (char.IsDigit(expression[i]) || expression[i] == '.'))
|
||||||
|
{
|
||||||
|
number += expression[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
values.Push(float.Parse(number));
|
||||||
|
}
|
||||||
|
else if (expression[i] == '"') // 문자열 처리
|
||||||
|
{
|
||||||
|
// 문자열 리터럴 처리 (큰 따옴표로 감싸진 문자열)
|
||||||
|
i++;
|
||||||
|
var str = "";
|
||||||
|
while (i < expression.Length && expression[i] != '"')
|
||||||
|
{
|
||||||
|
str += expression[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++; // 닫는 따옴표 넘기기
|
||||||
|
values.Push(str);
|
||||||
|
}
|
||||||
|
else if (expression[i] == '(')
|
||||||
|
{
|
||||||
|
operators.Push('(');
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else if (expression[i] == ')')
|
||||||
|
{
|
||||||
|
while (operators.Peek() != '(')
|
||||||
|
{
|
||||||
|
values.Push(ApplyOperator(values.Pop(), values.Pop(), operators.Pop()));
|
||||||
|
}
|
||||||
|
operators.Pop(); // '(' 제거
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else if (IsOperator(expression[i]))
|
||||||
|
{
|
||||||
|
// 연산자 처리
|
||||||
|
while (operators.Count > 0 && GetPrecedence(operators.Peek()) >= GetPrecedence(expression[i]))
|
||||||
|
{
|
||||||
|
values.Push(ApplyOperator(values.Pop(), values.Pop(), operators.Pop()));
|
||||||
|
}
|
||||||
|
operators.Push(expression[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 공백 등 기타 문자는 그냥 넘김
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (operators.Count > 0)
|
||||||
|
{
|
||||||
|
values.Push(ApplyOperator(values.Pop(), values.Pop(), operators.Pop()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return values.Pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 연산자 우선순위
|
||||||
|
private static int GetPrecedence(char op)
|
||||||
|
{
|
||||||
|
if (op == '+' || op == '-') return 1;
|
||||||
|
if (op == '*' || op == '/') return 2;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 연산자 확인
|
||||||
|
private static bool IsOperator(char c)
|
||||||
|
{
|
||||||
|
return c == '+' || c == '-' || c == '*' || c == '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 연산자 적용
|
||||||
|
private static SLEntity ApplyOperator(SLEntity right, SLEntity left, char op)
|
||||||
|
{
|
||||||
|
return op switch
|
||||||
|
{
|
||||||
|
'+' => left + right,
|
||||||
|
'-' => left - right,
|
||||||
|
'*' => left * right,
|
||||||
|
'/' => left / right,
|
||||||
|
_ => SLEntity.Empty,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ApplyEvaluate(SLEntity player, SLEntity current)
|
||||||
|
{
|
||||||
|
foreach (var c in current)
|
||||||
|
{
|
||||||
|
if (c.IsValue && c.IsNumeric == false)
|
||||||
|
{
|
||||||
|
current[c.ID] = Evaluate(player, c);
|
||||||
|
}
|
||||||
|
else if (c.IsValue == false)
|
||||||
|
{
|
||||||
|
ApplyEvaluate(player, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
Assets/_Datas/SLShared/SLSystem/Evaluator.cs.meta
Normal file
2
Assets/_Datas/SLShared/SLSystem/Evaluator.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5cad9ae5f1395af4187eb9369a165695
|
209
Assets/_Datas/SLShared/SLSystem/SLDateTimeUtil.cs
Normal file
209
Assets/_Datas/SLShared/SLSystem/SLDateTimeUtil.cs
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
using System;
|
||||||
|
using Superlazy;
|
||||||
|
|
||||||
|
public static class SLDateTimeUtil
|
||||||
|
{
|
||||||
|
private const double oADateMaxAsDouble = 2958466.0;
|
||||||
|
private const double oADateMinAsDouble = -657435.0;
|
||||||
|
private const int millisPerSecond = 1000;
|
||||||
|
private const int millisPerMinute = millisPerSecond * 60;
|
||||||
|
private const int millisPerHour = millisPerMinute * 60;
|
||||||
|
private const int millisPerDay = millisPerHour * 24;
|
||||||
|
|
||||||
|
// Number of 100ns ticks per time unit
|
||||||
|
private const long ticksPerMillisecond = 10000;
|
||||||
|
|
||||||
|
private const long ticksPerSecond = ticksPerMillisecond * 1000;
|
||||||
|
private const long ticksPerMinute = ticksPerSecond * 60;
|
||||||
|
private const long ticksPerHour = ticksPerMinute * 60;
|
||||||
|
private const long ticksPerDay = ticksPerHour * 24;
|
||||||
|
|
||||||
|
// Number of days in a non-leap year
|
||||||
|
private const int daysPerYear = 365;
|
||||||
|
|
||||||
|
// Number of days in 4 years
|
||||||
|
private const int daysPer4Years = daysPerYear * 4 + 1; // 1461
|
||||||
|
|
||||||
|
// Number of days in 100 years
|
||||||
|
private const int daysPer100Years = daysPer4Years * 25 - 1; // 36524
|
||||||
|
|
||||||
|
// Number of days in 400 years
|
||||||
|
private const int daysPer400Years = daysPer100Years * 4 + 1; // 146097
|
||||||
|
|
||||||
|
// Number of days from 1/1/0001 to 12/31/1600
|
||||||
|
|
||||||
|
// Number of days from 1/1/0001 to 12/30/1899
|
||||||
|
private const int daysTo1899 = daysPer400Years * 4 + daysPer100Years * 3 - 367;
|
||||||
|
|
||||||
|
// Number of days from 1/1/0001 to 12/31/1969
|
||||||
|
|
||||||
|
// Number of days from 1/1/0001 to 12/31/9999
|
||||||
|
private const int daysTo10000 = daysPer400Years * 25 - 366; // 3652059
|
||||||
|
|
||||||
|
private const long doubleDateOffset = daysTo1899 * ticksPerDay;
|
||||||
|
private const long maxMillis = (long)daysTo10000 * millisPerDay;
|
||||||
|
|
||||||
|
private const long oADateMinAsTicks = (daysPer100Years - daysPerYear) * ticksPerDay;
|
||||||
|
|
||||||
|
private static long DoubleDateToTicks(double value)
|
||||||
|
{
|
||||||
|
// The check done this way will take care of NaN
|
||||||
|
if (!(value < oADateMaxAsDouble) || !(value > oADateMinAsDouble))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conversion to long will not cause an overflow here, as at this point the "value" is in between OADateMinAsDouble and OADateMaxAsDouble
|
||||||
|
var millis = (long)(value * millisPerDay + (value >= 0 ? 0.5 : -0.5));
|
||||||
|
// The interesting thing here is when you have a value like 12.5 it all positive 12 days and 12 hours from 01/01/1899
|
||||||
|
// However if you a value of -12.25 it is minus 12 days but still positive 6 hours, almost as though you meant -11.75 all negative
|
||||||
|
// This line below fixes up the millis in the negative case
|
||||||
|
if (millis < 0)
|
||||||
|
{
|
||||||
|
millis -= (millis % millisPerDay) * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
millis += doubleDateOffset / ticksPerMillisecond;
|
||||||
|
|
||||||
|
if (millis < 0 || millis >= maxMillis)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return millis * ticksPerMillisecond;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double TicksToOADate(long value)
|
||||||
|
{
|
||||||
|
if (value == 0)
|
||||||
|
return 0.0; // Returns OleAut's zero'ed date value.
|
||||||
|
if (value < ticksPerDay) // This is a fix for VB. They want the default day to be 1/1/0001 rathar then 12/30/1899.
|
||||||
|
value += doubleDateOffset; // We could have moved this fix down but we would like to keep the bounds check.
|
||||||
|
if (value < oADateMinAsTicks)
|
||||||
|
throw new OverflowException();
|
||||||
|
// Currently, our max date == OA's max date (12/31/9999), so we don't
|
||||||
|
// need an overflow check in that direction.
|
||||||
|
var millis = (value - doubleDateOffset) / ticksPerMillisecond;
|
||||||
|
if (millis < 0)
|
||||||
|
{
|
||||||
|
var frac = millis % millisPerDay;
|
||||||
|
if (frac != 0) millis -= (millisPerDay + frac) * 2;
|
||||||
|
}
|
||||||
|
return Math.Round((double)millis / millisPerDay, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime FromSLDate(double d)
|
||||||
|
{
|
||||||
|
return new DateTime(DoubleDateToTicks(d), DateTimeKind.Unspecified);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime FromSLDateToKRDate(double d)
|
||||||
|
{
|
||||||
|
return (new DateTime(DoubleDateToTicks(d), DateTimeKind.Unspecified)).AddHours(9);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime ToDateTime(this SLEntity value)
|
||||||
|
{
|
||||||
|
return new DateTime(DoubleDateToTicks(value), DateTimeKind.Unspecified);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime ToLocalDateTime(this SLEntity value)
|
||||||
|
{
|
||||||
|
return new DateTime(DoubleDateToTicks(value), DateTimeKind.Unspecified).ToLocalTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime ToDayStart(this DateTime dt)
|
||||||
|
{
|
||||||
|
return new DateTime(dt.Year, dt.Month, dt.Day);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime ToKRInitTime(this DateTime dt)
|
||||||
|
{
|
||||||
|
return dt.AddDays(1).AddHours(3).ToDayStart().AddHours(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime ToRankingEndTime(this DateTime dt)
|
||||||
|
{
|
||||||
|
return dt.AddDays(1).AddHours(3).AddMinutes(15).ToDayStart().AddHours(-3).AddMinutes(-15);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime ToWeekliyInitTime(this DateTime dt)
|
||||||
|
{
|
||||||
|
if (dt < dt.ToKRInitTime().AddDays(-1))
|
||||||
|
{
|
||||||
|
return dt.ToKRInitTime().AddDays(-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var delta = 7 + DayOfWeek.Monday - dt.DayOfWeek;
|
||||||
|
return dt.AddDays(delta).AddHours(3).ToDayStart().AddHours(-3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double ToSLDate(this DateTime dt)
|
||||||
|
{
|
||||||
|
return TicksToOADate(dt.Ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double FromKRDateToSLDate(this DateTime dt)
|
||||||
|
{
|
||||||
|
return TicksToOADate(dt.AddHours(-9).Ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ToSLDateString(this DateTime dt)
|
||||||
|
{
|
||||||
|
return dt.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ToSLDateTimeString(this DateTime dt)
|
||||||
|
{
|
||||||
|
return dt.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ToSLDateTimeString(this DateTimeOffset dt)
|
||||||
|
{
|
||||||
|
return dt.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsDateIn(DateTime date, SLEntity checkDate)
|
||||||
|
{
|
||||||
|
var start = new DateTime(checkDate["YStart"], checkDate["MStart"], checkDate["DStart"], checkDate["HStart"], 0, 0);
|
||||||
|
|
||||||
|
if (checkDate["YEnd"] == false) checkDate["YEnd"] = checkDate["YStart"];
|
||||||
|
if (checkDate["MEnd"] == false) checkDate["MEnd"] = checkDate["MStart"];
|
||||||
|
if (checkDate["DEnd"] == false) checkDate["DEnd"] = checkDate["DStart"];
|
||||||
|
if (checkDate["HEnd"] == false) checkDate["HEnd"] = checkDate["HStart"];
|
||||||
|
|
||||||
|
var end = new DateTime(checkDate["YEnd"], checkDate["MEnd"], checkDate["DEnd"], checkDate["HEnd"], 0, 0);
|
||||||
|
return date >= start && date < end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class SLDateTime
|
||||||
|
{
|
||||||
|
private static SLDateTime instance;
|
||||||
|
|
||||||
|
public static void Init(SLDateTime inst)
|
||||||
|
{
|
||||||
|
instance = inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime Now
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (instance == null) return DateTime.UtcNow;
|
||||||
|
|
||||||
|
return instance.GetNow();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (instance == null) return;
|
||||||
|
|
||||||
|
instance.SetNow(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract DateTime GetNow();
|
||||||
|
|
||||||
|
protected abstract void SetNow(DateTime now);
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLSystem/SLDateTimeUtil.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLSystem/SLDateTimeUtil.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 39c2b8bb3f8be6144a6fad50799fa543
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/SLShared/SLSystem/SLEntity.meta
Normal file
8
Assets/_Datas/SLShared/SLSystem/SLEntity.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ca529b11f40987640bad27af13b9e13a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
670
Assets/_Datas/SLShared/SLSystem/SLEntity/Container.cs
Normal file
670
Assets/_Datas/SLShared/SLSystem/SLEntity/Container.cs
Normal file
@ -0,0 +1,670 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
internal abstract class SLContainerBase : SLEntity
|
||||||
|
{
|
||||||
|
public override string ID => id;
|
||||||
|
|
||||||
|
protected SLContainerBase parent;
|
||||||
|
protected string id;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SLContainer : SLContainerBase
|
||||||
|
{
|
||||||
|
private SLEntity original;
|
||||||
|
private Dictionary<string, SLEntity> attributes;
|
||||||
|
private HashSet<string> removed;
|
||||||
|
private List<SLContainerLink> links;
|
||||||
|
private bool dangled;
|
||||||
|
|
||||||
|
public SLContainer(SLContainerBase original, SLContainerBase parent, string id)
|
||||||
|
{
|
||||||
|
this.original = original;
|
||||||
|
this.parent = parent;
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (original.IsNullOrFalse() && this.parent is null == false)
|
||||||
|
{
|
||||||
|
dangled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override SLEntity ToChild(SLContainerBase parent, string id)
|
||||||
|
{
|
||||||
|
if (id == null && parent is null) // 삭제시
|
||||||
|
{
|
||||||
|
dangled = true;
|
||||||
|
|
||||||
|
attributes?.Clear();
|
||||||
|
removed?.Clear();
|
||||||
|
original = null;
|
||||||
|
|
||||||
|
if (links != null)
|
||||||
|
{
|
||||||
|
foreach (var link in links)
|
||||||
|
{
|
||||||
|
link.DestroyLink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dangled == false && this.parent is null == false)
|
||||||
|
{
|
||||||
|
return Clone().ToChild(parent, id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dangled = false;
|
||||||
|
this.parent = parent;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsNumeric
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsExist())
|
||||||
|
{
|
||||||
|
SLLog.Error($"this is not value : {id}");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsValue => false;
|
||||||
|
|
||||||
|
internal override bool IsExist()
|
||||||
|
{
|
||||||
|
if (dangled && (parent?.HasChild(id) ?? false)) return true;
|
||||||
|
|
||||||
|
if ((attributes?.Count ?? 0) != 0) return true;
|
||||||
|
|
||||||
|
if (original.IsNullOrFalse()) return false;
|
||||||
|
|
||||||
|
if ((removed?.Count ?? 0) == 0) return true;
|
||||||
|
if (original.Any(e => removed.Contains(e.ID) == false)) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool HasChild(string attributeKey)
|
||||||
|
{
|
||||||
|
if (attributeKey == "ID") return true;
|
||||||
|
if (dangled && (parent?.HasChild(id) ?? false)) return parent[id].HasChild(attributeKey);
|
||||||
|
|
||||||
|
if (removed?.Contains(attributeKey) ?? false) return false;
|
||||||
|
if (attributes?.ContainsKey(attributeKey) ?? false) return true;
|
||||||
|
|
||||||
|
if (original.IsNullOrFalse() == false)
|
||||||
|
{
|
||||||
|
return original.HasChild(attributeKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerator<SLEntity> GetEnumerator()
|
||||||
|
{
|
||||||
|
if (dangled && (parent?.HasChild(id) ?? false))
|
||||||
|
{
|
||||||
|
foreach (var value in parent[id])
|
||||||
|
{
|
||||||
|
yield return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attributes?.Count > 0)
|
||||||
|
{
|
||||||
|
var keys = new List<string>(attributes.Keys);
|
||||||
|
|
||||||
|
foreach (var key in keys)
|
||||||
|
{
|
||||||
|
yield return attributes[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (original)
|
||||||
|
{
|
||||||
|
foreach (var child in original.Where(e => (removed?.Contains(e.ID) ?? false) == false && (attributes?.ContainsKey(e.ID) ?? false) == false).ToList())
|
||||||
|
{
|
||||||
|
yield return this[child.ID];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override double GetDouble()
|
||||||
|
{
|
||||||
|
if (dangled && (parent?.HasChild(id) ?? false))
|
||||||
|
{
|
||||||
|
return parent[id].GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsExist())
|
||||||
|
{
|
||||||
|
SLLog.Error($"this is not value : {id}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override int GetInt()
|
||||||
|
{
|
||||||
|
if (dangled && (parent?.HasChild(id) ?? false))
|
||||||
|
{
|
||||||
|
return parent[id].GetInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsExist())
|
||||||
|
{
|
||||||
|
SLLog.Error($"this is not value : {id}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override string GetString()
|
||||||
|
{
|
||||||
|
if (dangled && (parent?.HasChild(id) ?? false))
|
||||||
|
{
|
||||||
|
return parent[id].GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsExist() == false)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"{id}[{attributes?.Count ?? 0}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override object GetObj()
|
||||||
|
{
|
||||||
|
if (dangled && (parent?.HasChild(id) ?? false))
|
||||||
|
{
|
||||||
|
return parent[id].GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
SLLog.Error($"this is not value : {id}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override int GetEntityHashCode()
|
||||||
|
{
|
||||||
|
if (dangled && (parent?.HasChild(id) ?? false)) return parent[id].GetHashCode();
|
||||||
|
if (attributes != null && removed != null) return attributes.GetHashCode() & removed.GetHashCode(); // TODO: 딕셔너리 대신 정밀한 해시코드를 만들어야함(성능이슈 체크)
|
||||||
|
if (attributes != null) return attributes.GetHashCode(); // TODO: 딕셔너리 대신 정밀한 해시코드를 만들어야함(성능이슈 체크)
|
||||||
|
if (removed != null) return removed.GetHashCode(); // TODO: 딕셔너리 대신 정밀한 해시코드를 만들어야함(성능이슈 체크)
|
||||||
|
if (original.IsNullOrFalse() == false) return original.GetHashCode();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Link()
|
||||||
|
{
|
||||||
|
if (dangled)
|
||||||
|
{
|
||||||
|
if (parent?.HasChild(id) ?? false) return parent[id].Link();
|
||||||
|
|
||||||
|
SLLog.Error("Can't make empty link");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (links == null)
|
||||||
|
{
|
||||||
|
links = new List<SLContainerLink>();
|
||||||
|
}
|
||||||
|
|
||||||
|
var unusedLink = links.Find(l => l.Unused);
|
||||||
|
if (unusedLink is null == false)
|
||||||
|
{
|
||||||
|
return unusedLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newLink = new SLContainerLink(this);
|
||||||
|
links.Add(newLink);
|
||||||
|
return newLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Override()
|
||||||
|
{
|
||||||
|
if (dangled)
|
||||||
|
{
|
||||||
|
if (parent?.HasChild(id) ?? false) return parent[id].Override();
|
||||||
|
|
||||||
|
SLLog.Error("Can't make empty override");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SLContainer(this, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity this[string attributeKey]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (attributeKey == "ID") return ID;
|
||||||
|
|
||||||
|
if (dangled)
|
||||||
|
{
|
||||||
|
if (parent?.HasChild(id) ?? false) return parent[id][attributeKey];
|
||||||
|
return new SLContainer(null, this, attributeKey); // 댕글
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removed?.Contains(attributeKey) ?? false)
|
||||||
|
{
|
||||||
|
return new SLContainer(null, this, attributeKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attributes?.ContainsKey(attributeKey) ?? false)
|
||||||
|
{
|
||||||
|
return attributes[attributeKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (original?.HasChild(attributeKey) ?? false)
|
||||||
|
{
|
||||||
|
var originalValue = original[attributeKey];
|
||||||
|
if (originalValue.IsValue)
|
||||||
|
{
|
||||||
|
return originalValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (attributes == null) attributes = new Dictionary<string, SLEntity>();
|
||||||
|
attributes[attributeKey] = originalValue.Override().ToChild(this, attributeKey);
|
||||||
|
return attributes[attributeKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SLContainer(null, this, attributeKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// 댕글인경우
|
||||||
|
if (dangled)
|
||||||
|
{
|
||||||
|
if (parent?.HasChild(id) ?? false) // 다른개체로 교체된 댕글
|
||||||
|
{
|
||||||
|
parent[id][attributeKey] = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.IsNullOrFalse()) // 삭제
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 새로 등록
|
||||||
|
attributes = new Dictionary<string, SLEntity>();
|
||||||
|
|
||||||
|
Modified(attributeKey);
|
||||||
|
attributes[attributeKey] = value.ToChild(this, attributeKey);
|
||||||
|
|
||||||
|
if (parent is null) return;
|
||||||
|
|
||||||
|
parent[id] = this;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (attributes?.ContainsKey(attributeKey) ?? false) // 키가 있는 경우
|
||||||
|
{
|
||||||
|
if (value.IsNullOrFalse()) // 삭제
|
||||||
|
{
|
||||||
|
{
|
||||||
|
Modified(attributeKey);
|
||||||
|
var v = attributes[attributeKey];
|
||||||
|
attributes.Remove(attributeKey);
|
||||||
|
v.ToChild(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removed == null) removed = new HashSet<string>();
|
||||||
|
removed.Add(attributeKey);
|
||||||
|
|
||||||
|
if (IsExist() == false)
|
||||||
|
{
|
||||||
|
if (parent is null == false)
|
||||||
|
{
|
||||||
|
parent[id] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // 변경
|
||||||
|
{
|
||||||
|
if (value == attributes[attributeKey]) return;
|
||||||
|
|
||||||
|
{
|
||||||
|
Modified(attributeKey);
|
||||||
|
var v = attributes[attributeKey];
|
||||||
|
attributes.Remove(attributeKey);
|
||||||
|
v.ToChild(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes[attributeKey] = value.ToChild(this, attributeKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // 키가 없는경우
|
||||||
|
{
|
||||||
|
if (original?.HasChild(attributeKey) ?? false) // 덮어쓰기
|
||||||
|
{
|
||||||
|
if (value.IsNullOrFalse()) // 삭제추가
|
||||||
|
{
|
||||||
|
if (removed == null) removed = new HashSet<string>();
|
||||||
|
Modified(attributeKey);
|
||||||
|
removed.Add(attributeKey);
|
||||||
|
|
||||||
|
if (IsExist() == false)
|
||||||
|
{
|
||||||
|
if (parent is null == false)
|
||||||
|
{
|
||||||
|
parent[id] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // 추가
|
||||||
|
{
|
||||||
|
if (attributes == null) attributes = new Dictionary<string, SLEntity>();
|
||||||
|
|
||||||
|
if (removed?.Contains(attributeKey) ?? false)
|
||||||
|
{
|
||||||
|
removed.Remove(attributeKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Modified(attributeKey);
|
||||||
|
attributes[attributeKey] = value.ToChild(this, attributeKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 추가
|
||||||
|
if (value.IsNullOrFalse()) return;
|
||||||
|
|
||||||
|
if (attributes == null) attributes = new Dictionary<string, SLEntity>();
|
||||||
|
|
||||||
|
Modified(attributeKey);
|
||||||
|
attributes[attributeKey] = value.ToChild(this, attributeKey);
|
||||||
|
if (removed != null && removed.Contains(attributeKey))
|
||||||
|
{
|
||||||
|
removed.Remove(attributeKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Clone()
|
||||||
|
{
|
||||||
|
if (dangled)
|
||||||
|
{
|
||||||
|
if (parent?.HasChild(id) ?? false) return parent[id].Clone();
|
||||||
|
SLLog.Error($"Can't clone dangle object: {id}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ret = new SLContainer(null, null, null);
|
||||||
|
|
||||||
|
foreach (var child in this)
|
||||||
|
{
|
||||||
|
ret[child.ID] = child.Clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Move(SLEntity parent, string newID)
|
||||||
|
{
|
||||||
|
if (dangled)
|
||||||
|
{
|
||||||
|
if (parent?.HasChild(id) ?? false) this.parent[id].Move(parent, newID);
|
||||||
|
SLLog.Error($"Can't move dangle object : {id} -> {newID}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id != null) // 이미 루트가 없다면
|
||||||
|
{
|
||||||
|
var attrTemp = attributes;
|
||||||
|
this.parent[id] = false;
|
||||||
|
|
||||||
|
attributes = attrTemp;
|
||||||
|
id = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent[id] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashSet<string> modified;
|
||||||
|
|
||||||
|
public override bool IsModified(string child)
|
||||||
|
{
|
||||||
|
var ret = false;
|
||||||
|
ret |= original?.IsModified(child) ?? false;
|
||||||
|
if (child == null) ret |= (modified?.Count ?? 0) != 0;
|
||||||
|
else ret |= modified?.Contains(child) ?? false;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void EndModified()
|
||||||
|
{
|
||||||
|
modified?.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Modified(string child)
|
||||||
|
{
|
||||||
|
if (modified == null) modified = new HashSet<string>();
|
||||||
|
modified.Add(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SLContainerLink : SLContainerBase
|
||||||
|
{
|
||||||
|
public bool Unused => id == null;
|
||||||
|
private SLContainer original;
|
||||||
|
|
||||||
|
public SLContainerLink(SLContainer original)
|
||||||
|
{
|
||||||
|
this.original = original;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override SLEntity ToChild(SLContainerBase parent, string id)
|
||||||
|
{
|
||||||
|
if (id == null && parent is null) // 삭제시
|
||||||
|
{
|
||||||
|
this.parent = null;
|
||||||
|
this.id = null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.parent) return Clone().ToChild(parent, id);
|
||||||
|
|
||||||
|
this.parent = parent;
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void DestroyLink()
|
||||||
|
{
|
||||||
|
if (Unused) return;
|
||||||
|
parent[id] = false;
|
||||||
|
original = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsNumeric
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
SLLog.Error($"this is not value : {id}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse()) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override bool IsExist()
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse()) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool HasChild(string attributeKey)
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse()) return false;
|
||||||
|
return original.HasChild(attributeKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerator<SLEntity> GetEnumerator()
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse()) return Enumerable.Empty<SLEntity>().GetEnumerator();
|
||||||
|
return original.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override double GetDouble()
|
||||||
|
{
|
||||||
|
SLLog.Error($"this is not value : {id}");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override int GetInt()
|
||||||
|
{
|
||||||
|
SLLog.Error($"this is not value : {id}");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override object GetObj()
|
||||||
|
{
|
||||||
|
SLLog.Error($"this is not value : {id}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Link()
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Error($"Destroyed Link, {id}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return original.Link();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Override()
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Error($"Destroyed Link, {id}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return original.Override();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override string GetString()
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse()) return string.Empty;
|
||||||
|
return $"{id} - {original}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity this[string attributeKey]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (attributeKey == "ID") return ID;
|
||||||
|
|
||||||
|
if (original.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
if (parent?.HasChild(id) ?? false) return parent[id][attributeKey];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return original[attributeKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
if (parent?.HasChild(id) ?? false) parent[id][attributeKey] = value;
|
||||||
|
|
||||||
|
// 빈객체에 값을 넣어도 이값을 다시참조할 방법이 없음
|
||||||
|
SLLog.Error($"Dangle Link. Can't set new Value : {attributeKey}-{value}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
original[attributeKey] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Clone()
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Error($"Destroyed Link, {id}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return original.Clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Move(SLEntity parent, string id)
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Error($"Destroyed Link, {id}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.parent[id] = null;
|
||||||
|
parent[id] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override int GetEntityHashCode()
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Error($"Destroyed Link, {id}");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return original.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsModified(string child)
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return original.IsModified(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void EndModified()
|
||||||
|
{
|
||||||
|
if (original.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
original.EndModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLSystem/SLEntity/Container.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLSystem/SLEntity/Container.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dae3057243a613a4b901c956ca43e60e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
941
Assets/_Datas/SLShared/SLSystem/SLEntity/SLEntity.cs
Normal file
941
Assets/_Datas/SLShared/SLSystem/SLEntity/SLEntity.cs
Normal file
@ -0,0 +1,941 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public abstract class SLEntity : IEnumerable<SLEntity>, IComparable<SLEntity>
|
||||||
|
{
|
||||||
|
public abstract bool IsNumeric { get; }
|
||||||
|
public abstract bool IsValue { get; }
|
||||||
|
public abstract string ID { get; }
|
||||||
|
|
||||||
|
public abstract bool IsModified(string child);
|
||||||
|
|
||||||
|
public abstract void EndModified();
|
||||||
|
|
||||||
|
public abstract bool HasChild(string attributeKey);
|
||||||
|
|
||||||
|
internal abstract object GetObj();
|
||||||
|
|
||||||
|
internal abstract int GetInt();
|
||||||
|
|
||||||
|
internal abstract double GetDouble();
|
||||||
|
|
||||||
|
internal abstract string GetString();
|
||||||
|
|
||||||
|
internal abstract bool IsExist();
|
||||||
|
|
||||||
|
protected abstract int GetEntityHashCode();
|
||||||
|
|
||||||
|
internal static IEnumerable<SLEntity> emptyEnumerable = Enumerable.Empty<SLEntity>();
|
||||||
|
|
||||||
|
public abstract IEnumerator<SLEntity> GetEnumerator();
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SLEntity this[SLEntity attributeKey]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (attributeKey.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Warn($"attributeKey shouldn't null obj {ToString()}, {ID}");
|
||||||
|
#if SERVER && LOCALTEST
|
||||||
|
throw new Exception();
|
||||||
|
#endif
|
||||||
|
return Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this[attributeKey.ToString()];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (attributeKey.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Warn($"attributeKey shouldn't null obj {ToString()}, {ID}");
|
||||||
|
#if SERVER && LOCALTEST
|
||||||
|
throw new Exception();
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this[attributeKey.ToString()] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract SLEntity this[string attributeKey]
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract SLEntity Clone();
|
||||||
|
|
||||||
|
public abstract SLEntity Link();
|
||||||
|
|
||||||
|
public abstract SLEntity Override();
|
||||||
|
|
||||||
|
public static SLEntity Empty => new SLContainer(null, null, null);
|
||||||
|
|
||||||
|
public static implicit operator double(SLEntity v)
|
||||||
|
{
|
||||||
|
return v.GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator float(SLEntity v)
|
||||||
|
{
|
||||||
|
return (float)v.GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator int(SLEntity v)
|
||||||
|
{
|
||||||
|
return v.GetInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator string(SLEntity v)
|
||||||
|
{
|
||||||
|
return v.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator bool(SLEntity v)
|
||||||
|
{
|
||||||
|
return v != default(SLEntity) && v.IsExist();
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static implicit operator Vector2(SLEntity v)
|
||||||
|
//{
|
||||||
|
// return new Vector2(v["X"], v["Y"]);
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static bool operator <(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs == null && rhs == null)
|
||||||
|
{
|
||||||
|
return 0 < 0;
|
||||||
|
}
|
||||||
|
else if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0 < rhs.GetDouble();
|
||||||
|
}
|
||||||
|
else if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() < 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() < rhs.GetDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator >(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs == null && rhs == null)
|
||||||
|
{
|
||||||
|
return 0 > 0;
|
||||||
|
}
|
||||||
|
else if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0 > rhs.GetDouble();
|
||||||
|
}
|
||||||
|
else if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs.GetDouble() > rhs.GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator <=(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs == null && rhs == null)
|
||||||
|
{
|
||||||
|
return 0 <= 0;
|
||||||
|
}
|
||||||
|
else if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0 <= rhs.GetDouble();
|
||||||
|
}
|
||||||
|
else if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() <= 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() <= rhs.GetDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator >=(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs == null && rhs == null)
|
||||||
|
{
|
||||||
|
return 0 >= 0;
|
||||||
|
}
|
||||||
|
else if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0 >= rhs.GetDouble();
|
||||||
|
}
|
||||||
|
else if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() >= 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() >= rhs.GetDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity operator +(SLEntity single)
|
||||||
|
{
|
||||||
|
return single;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity operator -(SLEntity single)
|
||||||
|
{
|
||||||
|
if (single.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -single.GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity operator +(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric && rhs.IsNumeric)
|
||||||
|
return lhs.GetDouble() + rhs.GetDouble();
|
||||||
|
|
||||||
|
return lhs.ToString() + rhs.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double operator +(double lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric)
|
||||||
|
return lhs + rhs.GetDouble();
|
||||||
|
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double operator +(SLEntity lhs, double rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric)
|
||||||
|
return lhs.GetDouble() + rhs;
|
||||||
|
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float operator +(float lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric)
|
||||||
|
return lhs + (float)rhs.GetDouble();
|
||||||
|
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float operator +(SLEntity lhs, float rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric)
|
||||||
|
return (float)lhs.GetDouble() + rhs;
|
||||||
|
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator +(SLEntity lhs, int rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric)
|
||||||
|
return lhs.GetInt() + rhs;
|
||||||
|
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator +(int lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric)
|
||||||
|
return lhs + rhs.GetInt();
|
||||||
|
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity operator -(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
if (rhs == default(SLEntity)) return 0;
|
||||||
|
return -rhs.GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs.GetDouble() - rhs.GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double operator -(double lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric)
|
||||||
|
return lhs - rhs.GetDouble();
|
||||||
|
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double operator -(SLEntity lhs, double rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return -rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric)
|
||||||
|
return lhs.GetDouble() - rhs;
|
||||||
|
|
||||||
|
return -rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float operator -(float lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric)
|
||||||
|
return lhs - (float)rhs.GetDouble();
|
||||||
|
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float operator -(SLEntity lhs, float rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return -rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric)
|
||||||
|
return (float)lhs.GetDouble() - rhs;
|
||||||
|
|
||||||
|
return -rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator -(SLEntity lhs, int rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return -rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric)
|
||||||
|
return lhs.GetInt() - rhs;
|
||||||
|
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator -(int lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric)
|
||||||
|
return lhs - rhs.GetInt();
|
||||||
|
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity operator *(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric && rhs.IsNumeric)
|
||||||
|
return lhs.GetDouble() * rhs.GetDouble();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double operator *(double lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric)
|
||||||
|
return lhs * rhs.GetDouble();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double operator *(SLEntity lhs, double rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric)
|
||||||
|
return lhs.GetDouble() * rhs;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float operator *(float lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric)
|
||||||
|
return lhs * (float)rhs.GetDouble();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float operator *(SLEntity lhs, float rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric)
|
||||||
|
return (float)lhs.GetDouble() * rhs;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator *(SLEntity lhs, int rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNumeric)
|
||||||
|
return lhs.GetInt() * rhs;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator *(int lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric)
|
||||||
|
return lhs * rhs.GetInt();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity operator /(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs?.GetDouble() ?? 0} / 0");
|
||||||
|
|
||||||
|
if (lhs.IsNullOrFalse()) return 0;
|
||||||
|
else return Math.Sign(lhs.GetDouble()) * double.PositiveInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric == false || rhs == 0.0)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs.GetDouble()} / 0");
|
||||||
|
return Math.Sign(lhs.GetDouble()) * double.PositiveInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs.GetDouble() / rhs.GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double operator /(double lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs} / 0");
|
||||||
|
return Math.Sign(lhs) * double.PositiveInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric == false || rhs == 0.0)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs} / 0");
|
||||||
|
return Math.Sign(lhs) * double.PositiveInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs / rhs.GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double operator /(SLEntity lhs, double rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs == 0.0)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs.GetDouble()} / 0");
|
||||||
|
return Math.Sign(lhs.GetDouble()) * double.PositiveInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs.GetDouble() / rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float operator /(float lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs} / 0");
|
||||||
|
return Math.Sign(lhs) * float.PositiveInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric == false || rhs == 0.0)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs} / 0");
|
||||||
|
return Math.Sign(lhs) * float.PositiveInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs / (float)rhs.GetDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float operator /(SLEntity lhs, float rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs == 0.0)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs.GetDouble()} / 0");
|
||||||
|
return Math.Sign(lhs.GetDouble()) * float.PositiveInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float)lhs.GetDouble() / rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator /(int lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs} / 0");
|
||||||
|
return lhs > 0 ? int.MaxValue : int.MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNumeric == false || rhs == 0.0)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs} / 0");
|
||||||
|
return lhs > 0 ? int.MaxValue : int.MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs / rhs.GetInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator /(SLEntity lhs, int rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs == 0)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs.GetInt()} / 0");
|
||||||
|
return lhs.GetInt() > 0 ? int.MaxValue : int.MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs.GetInt() / rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator %(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs} / 0");
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs.GetInt() % rhs.GetInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator %(SLEntity lhs, int rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs == 0)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs} / 0");
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs.GetInt() % rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int operator %(int lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rhs.IsNullOrFalse() || rhs.GetInt() == 0)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Divide by 0 {lhs} / 0");
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs % rhs.GetInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(SLEntity lhs, bool rhs)
|
||||||
|
{
|
||||||
|
if (lhs.IsNullOrFalse()) return !rhs;
|
||||||
|
else return lhs.IsExist() == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(SLEntity lhs, bool rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(bool lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (rhs.IsNullOrFalse()) return !lhs;
|
||||||
|
else return rhs.IsExist() == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(bool lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
return !(rhs == lhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static bool operator ==(SLEntity lhs, string rhs)
|
||||||
|
//{
|
||||||
|
// return (string)lhs == rhs;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static bool operator !=(SLEntity lhs, string rhs)
|
||||||
|
//{
|
||||||
|
// return !(lhs == rhs);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static bool operator ==(string lhs, SLEntity rhs)
|
||||||
|
//{
|
||||||
|
// return rhs == lhs;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static bool operator !=(string lhs, SLEntity rhs)
|
||||||
|
//{
|
||||||
|
// return !(rhs == lhs);
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static bool operator ==(SLEntity lhs, int rhs)
|
||||||
|
{
|
||||||
|
return lhs.GetInt() == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(SLEntity lhs, int rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(int lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
return rhs == lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(int lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
return !(rhs == lhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(SLEntity lhs, double rhs)
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(SLEntity lhs, double rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(double lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
return rhs == lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(double lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
return !(rhs == lhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(SLEntity lhs, float rhs)
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(SLEntity lhs, float rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(float lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
return rhs == lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(float lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
return !(rhs == lhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static bool operator ==(SLEntity lhs, SLVector2 rhs)
|
||||||
|
//{
|
||||||
|
// return lhs["X"] == rhs.X && lhs["Y"] == rhs.Y;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static bool operator !=(SLEntity lhs, SLVector2 rhs)
|
||||||
|
//{
|
||||||
|
// return lhs["X"] != rhs.X || lhs["Y"] != rhs.Y;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static bool operator ==(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(lhs, rhs))// 동일 객체
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (lhs is null || lhs.IsExist() == false) // 빈객체
|
||||||
|
{
|
||||||
|
return rhs is null || rhs.IsExist() == false;
|
||||||
|
}
|
||||||
|
else if (rhs is null || rhs.IsExist() == false)
|
||||||
|
{
|
||||||
|
return lhs is null || lhs.IsExist() == false;
|
||||||
|
}
|
||||||
|
else if (lhs.IsValue && rhs.IsValue) // 값비교
|
||||||
|
{
|
||||||
|
if (lhs.IsNumeric == false || rhs.IsNumeric == false)
|
||||||
|
{
|
||||||
|
return lhs.GetString().Equals(rhs.GetString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return lhs.GetDouble() == rhs.GetDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (lhs.IsValue == false && rhs.IsValue == false) // 리스트
|
||||||
|
{
|
||||||
|
var lhsCount = lhs.Count();
|
||||||
|
var rhsCount = rhs.Count();
|
||||||
|
|
||||||
|
if (lhsCount != rhsCount)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var l in lhs)
|
||||||
|
{
|
||||||
|
if (rhs.HasChild(l.ID) == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (l != rhs[l.ID])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((obj is SLEntity) == false)
|
||||||
|
{
|
||||||
|
return obj.Equals(GetObj());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (obj as SLEntity) == this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return GetEntityHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator SLEntity(string v)
|
||||||
|
{
|
||||||
|
if (v == null || v == string.Empty) return Empty;
|
||||||
|
else return new SLValueString(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator SLEntity(int v)
|
||||||
|
{
|
||||||
|
return new SLValueInt(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator SLEntity(double v)
|
||||||
|
{
|
||||||
|
return new SLValueDouble(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SLEntity boolTrue = new SLValueString("True");
|
||||||
|
//private static SLEntity boolFalse = new SLContainer(null, null, null);
|
||||||
|
|
||||||
|
public static implicit operator SLEntity(bool v)
|
||||||
|
{
|
||||||
|
if (v)
|
||||||
|
{
|
||||||
|
if (boolTrue.ID != null) boolTrue = new SLValueString("True");
|
||||||
|
return boolTrue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new SLContainer(null, null, null); // TODO: 성능상 수정 필요
|
||||||
|
//if (boolFalse || boolFalse.ID != null) boolFalse = new SLContainer(null, null, null);
|
||||||
|
//boolFalse.test = true;
|
||||||
|
//return boolFalse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static implicit operator SLEntity(SLVector2 v)
|
||||||
|
//{
|
||||||
|
// var ret = new SLContainer(null);
|
||||||
|
// ret["X"] = v.X;
|
||||||
|
// ret["Y"] = v.Y;
|
||||||
|
// return ret;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(SLEntity other)
|
||||||
|
{
|
||||||
|
if (IsValue == false || other.IsValue == false)
|
||||||
|
{
|
||||||
|
// TODO: 리스트 비교 필요
|
||||||
|
return GetHashCode().CompareTo(other.GetHashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsNumeric && other.IsNumeric)
|
||||||
|
{
|
||||||
|
return GetDouble().CompareTo(other.GetDouble());
|
||||||
|
}
|
||||||
|
|
||||||
|
var thisSTR = GetString();
|
||||||
|
var otherSTR = other.GetString();
|
||||||
|
return thisSTR.CompareTo(otherSTR);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal abstract SLEntity ToChild(SLContainerBase parent, string id);
|
||||||
|
|
||||||
|
internal abstract void Move(SLEntity parent, string id);
|
||||||
|
|
||||||
|
public static bool Changed(SLEntity lhs, SLEntity rhs)
|
||||||
|
{
|
||||||
|
if (lhs is null && rhs is null) return false;
|
||||||
|
|
||||||
|
if (lhs.IsNullOrFalse()) return rhs;
|
||||||
|
if (rhs.IsNullOrFalse()) return lhs;
|
||||||
|
|
||||||
|
if (lhs.IsValue && rhs.IsValue)
|
||||||
|
{
|
||||||
|
return lhs != rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLSystem/SLEntity/SLEntity.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLSystem/SLEntity/SLEntity.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5bdef6b90662bde4696cc01d0ac24899
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
174
Assets/_Datas/SLShared/SLSystem/SLEntity/Utility.cs
Normal file
174
Assets/_Datas/SLShared/SLSystem/SLEntity/Utility.cs
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public static class Utility
|
||||||
|
{
|
||||||
|
public static bool IsNullOrFalse(this SLEntity entity)
|
||||||
|
{
|
||||||
|
return entity == null || entity.IsExist() == false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string CombinePath(this string first, string add)
|
||||||
|
{
|
||||||
|
if (first == null || first == string.Empty)
|
||||||
|
{
|
||||||
|
return add;
|
||||||
|
}
|
||||||
|
else if (add == null || add == string.Empty)
|
||||||
|
{
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new StringBuilder().Append(first).Append('.').Append(add).ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveIf(this SLEntity entity, Func<SLEntity, bool> onRemove)
|
||||||
|
{
|
||||||
|
var removes = new List<string>();
|
||||||
|
foreach (var e in entity)
|
||||||
|
{
|
||||||
|
if (onRemove(e)) removes.Add(e.ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var r in removes)
|
||||||
|
{
|
||||||
|
entity[r] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Contains(this SLEntity entity, string value)
|
||||||
|
{
|
||||||
|
return entity.ToString().Contains(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity Get(this SLEntity entity, string path)
|
||||||
|
{
|
||||||
|
if (entity == null) return false;
|
||||||
|
var list = entity;
|
||||||
|
|
||||||
|
var oldIdx = 0;
|
||||||
|
var idx = path.IndexOf('.');
|
||||||
|
var len = path.Length;
|
||||||
|
while (idx != -1 && oldIdx < len)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
var sub = path.Substring(oldIdx, idx - oldIdx);
|
||||||
|
if (string.IsNullOrEmpty(sub) == false)
|
||||||
|
list = list[sub];
|
||||||
|
}
|
||||||
|
|
||||||
|
oldIdx = idx + 1;
|
||||||
|
if (idx + 1 >= path.Length)
|
||||||
|
{
|
||||||
|
idx = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
idx = path.IndexOf('.', idx + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldIdx < len)
|
||||||
|
{
|
||||||
|
var sub = path.Substring(oldIdx);
|
||||||
|
if (string.IsNullOrEmpty(sub) == false)
|
||||||
|
list = list[sub];
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Set(this SLEntity entity, string path, SLEntity value)
|
||||||
|
{
|
||||||
|
var list = entity;
|
||||||
|
var oldIdx = 0;
|
||||||
|
var idx = path.IndexOf('.');
|
||||||
|
var len = path.Length;
|
||||||
|
|
||||||
|
if (idx == -1)
|
||||||
|
{
|
||||||
|
list[path] = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (idx != -1 && oldIdx < len)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
var sub = path.Substring(oldIdx, idx - oldIdx);
|
||||||
|
if (string.IsNullOrEmpty(sub) == false)
|
||||||
|
list = list[sub];
|
||||||
|
}
|
||||||
|
|
||||||
|
oldIdx = idx + 1;
|
||||||
|
if (idx + 1 >= path.Length)
|
||||||
|
{
|
||||||
|
idx = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
idx = path.IndexOf('.', idx + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldIdx < len)
|
||||||
|
{
|
||||||
|
var sub = path.Substring(oldIdx);
|
||||||
|
if (string.IsNullOrEmpty(sub) == false)
|
||||||
|
{
|
||||||
|
list[sub] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SLLog.Error($"Set Can't end with . : {path}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsLeft(this SLEntity entity, string value)
|
||||||
|
{
|
||||||
|
return entity.ToString().IsLeft(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsLeft(this string str, string value)
|
||||||
|
{
|
||||||
|
if (str.Length >= value.Length)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < value.Length; i++)
|
||||||
|
{
|
||||||
|
if (str[i] != value[i])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsRight(this SLEntity entity, string value)
|
||||||
|
{
|
||||||
|
return entity.ToString().IsRight(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsRight(this string str, string value)
|
||||||
|
{
|
||||||
|
if (str.Length >= value.Length)
|
||||||
|
{
|
||||||
|
for (var i = 1; i <= value.Length; ++i)
|
||||||
|
{
|
||||||
|
if (str[str.Length - i] != value[value.Length - i])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLSystem/SLEntity/Utility.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLSystem/SLEntity/Utility.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4f3af70c1c51ef34aaca98e9b7dd64ab
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
214
Assets/_Datas/SLShared/SLSystem/SLEntity/Values.cs
Normal file
214
Assets/_Datas/SLShared/SLSystem/SLEntity/Values.cs
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
internal abstract class SLValue : SLEntity
|
||||||
|
{
|
||||||
|
public override bool IsValue => true;
|
||||||
|
protected string id;
|
||||||
|
public override string ID => id;
|
||||||
|
|
||||||
|
public override SLEntity Link()
|
||||||
|
{
|
||||||
|
SLLog.Error($"Value can't be link {id}: {GetString()}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Override()
|
||||||
|
{
|
||||||
|
SLLog.Error($"Value can't be override {id}: {GetString()}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override bool IsExist()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool HasChild(string attributeKey)
|
||||||
|
{
|
||||||
|
if (attributeKey == "ID") return true;
|
||||||
|
|
||||||
|
SLLog.Error($"Can't get Child in Value {id}: {GetObj()}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerator<SLEntity> GetEnumerator()
|
||||||
|
{
|
||||||
|
SLLog.Error($"Can't get Enumerator in Value {id}: {GetObj()}");
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity this[string attributeKey]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (attributeKey == "ID") return ID;
|
||||||
|
|
||||||
|
SLLog.Error($"Can't get attribute in Value {id}: {GetObj()}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
set => SLLog.Error($"Can't set attribute in Value : {GetObj()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override SLEntity ToChild(SLContainerBase parent, string id)
|
||||||
|
{
|
||||||
|
if (this.id != null)
|
||||||
|
{
|
||||||
|
return Clone().ToChild(parent, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Move(SLEntity parent, string id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
parent[id] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public override SLEntity Clone()
|
||||||
|
//{
|
||||||
|
// return this;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public override bool IsModified(string child)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void EndModified()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SLValueDouble : SLValue
|
||||||
|
{
|
||||||
|
private readonly double value;
|
||||||
|
|
||||||
|
public SLValueDouble(double value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsNumeric => true;
|
||||||
|
|
||||||
|
internal override double GetDouble()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override int GetInt()
|
||||||
|
{
|
||||||
|
return (int)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override object GetObj()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override int GetEntityHashCode()
|
||||||
|
{
|
||||||
|
return value.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override string GetString()
|
||||||
|
{
|
||||||
|
return value.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Clone()
|
||||||
|
{
|
||||||
|
return new SLValueDouble(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SLValueInt : SLValue
|
||||||
|
{
|
||||||
|
private readonly int value;
|
||||||
|
|
||||||
|
public SLValueInt(int value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsNumeric => true;
|
||||||
|
|
||||||
|
internal override double GetDouble()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override int GetInt()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override object GetObj()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override int GetEntityHashCode()
|
||||||
|
{
|
||||||
|
return value.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override string GetString()
|
||||||
|
{
|
||||||
|
return value.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Clone()
|
||||||
|
{
|
||||||
|
return new SLValueInt(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SLValueString : SLValue
|
||||||
|
{
|
||||||
|
private readonly string value;
|
||||||
|
|
||||||
|
public SLValueString(string value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsNumeric => false;
|
||||||
|
|
||||||
|
internal override double GetDouble()
|
||||||
|
{
|
||||||
|
SLLog.Warn($"String is not number {ID}:{GetString()}");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override int GetInt()
|
||||||
|
{
|
||||||
|
SLLog.Warn($"String is not number {ID}:{GetString()}");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override object GetObj()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override int GetEntityHashCode()
|
||||||
|
{
|
||||||
|
return value.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override string GetString()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SLEntity Clone()
|
||||||
|
{
|
||||||
|
return new SLValueString(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLSystem/SLEntity/Values.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLSystem/SLEntity/Values.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7693ce3a928c5f34e91b146b25143394
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/SLShared/SLSystem/SLEntitySpace.meta
Normal file
8
Assets/_Datas/SLShared/SLSystem/SLEntitySpace.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5ff8197c3c3246f40aac024382d634fe
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 62e4bd6c3eb89044f82f7ecdb26d960f
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,476 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Superlazy.Loader
|
||||||
|
{
|
||||||
|
public static class JsonLoader
|
||||||
|
{
|
||||||
|
private static void ParseElement(SLEntity context, string token, string tokenName, bool quoted)
|
||||||
|
{
|
||||||
|
if (context.HasChild(tokenName))
|
||||||
|
{
|
||||||
|
throw new Exception($"{tokenName} Already has child");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quoted)
|
||||||
|
{
|
||||||
|
context[tokenName] = token;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
if (double.TryParse(token, out var val))
|
||||||
|
{
|
||||||
|
if (val < 1 || val > int.MaxValue || (token.IsRight(".0") == false && token.Contains('.')))
|
||||||
|
{
|
||||||
|
context[tokenName] = val;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context[tokenName] = (int)val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context[tokenName] = token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity Parse(SLEntity root, string aJSON)
|
||||||
|
{
|
||||||
|
var stack = new Stack<SLEntity>();
|
||||||
|
SLEntity context = null;
|
||||||
|
var i = 0;
|
||||||
|
var Token = new StringBuilder();
|
||||||
|
var TokenName = "";
|
||||||
|
var QuoteMode = false;
|
||||||
|
var TokenIsQuoted = false;
|
||||||
|
while (i < aJSON.Length)
|
||||||
|
{
|
||||||
|
switch (aJSON[i])
|
||||||
|
{
|
||||||
|
case '{':
|
||||||
|
if (QuoteMode)
|
||||||
|
{
|
||||||
|
Token.Append(aJSON[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context is null)
|
||||||
|
{
|
||||||
|
stack.Push(root);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack.Push(context[TokenName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
TokenName = "";
|
||||||
|
Token.Length = 0;
|
||||||
|
context = stack.Peek();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '[':
|
||||||
|
if (QuoteMode)
|
||||||
|
{
|
||||||
|
Token.Append(aJSON[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.Push(SLEntity.Empty);
|
||||||
|
if (context != null)
|
||||||
|
{
|
||||||
|
context[TokenName] = stack.Peek();
|
||||||
|
}
|
||||||
|
|
||||||
|
TokenName = "";
|
||||||
|
Token.Length = 0;
|
||||||
|
context = stack.Peek();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '}':
|
||||||
|
case ']':
|
||||||
|
if (QuoteMode)
|
||||||
|
{
|
||||||
|
Token.Append(aJSON[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.Count == 0)
|
||||||
|
throw new Exception("JSON Parse: Too many closing brackets\n" + aJSON);
|
||||||
|
|
||||||
|
stack.Peek().EndModified();
|
||||||
|
stack.Pop();
|
||||||
|
if (Token.Length > 0 || TokenIsQuoted)
|
||||||
|
{
|
||||||
|
ParseElement(context, Token.ToString(), TokenName, TokenIsQuoted);
|
||||||
|
TokenIsQuoted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TokenName = "";
|
||||||
|
Token.Length = 0;
|
||||||
|
if (stack.Count > 0)
|
||||||
|
context = stack.Peek();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ':':
|
||||||
|
if (QuoteMode)
|
||||||
|
{
|
||||||
|
Token.Append(aJSON[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
TokenName = Token.ToString();
|
||||||
|
Token.Length = 0;
|
||||||
|
TokenIsQuoted = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '"':
|
||||||
|
QuoteMode ^= true;
|
||||||
|
TokenIsQuoted |= QuoteMode;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ',':
|
||||||
|
if (QuoteMode)
|
||||||
|
{
|
||||||
|
Token.Append(aJSON[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Token.Length > 0 || TokenIsQuoted)
|
||||||
|
{
|
||||||
|
ParseElement(context, Token.ToString(), TokenName, TokenIsQuoted);
|
||||||
|
}
|
||||||
|
|
||||||
|
TokenName = "";
|
||||||
|
Token.Length = 0;
|
||||||
|
TokenIsQuoted = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '\r':
|
||||||
|
case '\n':
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ' ':
|
||||||
|
case '\t':
|
||||||
|
if (QuoteMode)
|
||||||
|
Token.Append(aJSON[i]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '\\':
|
||||||
|
++i;
|
||||||
|
if (QuoteMode)
|
||||||
|
{
|
||||||
|
var C = aJSON[i];
|
||||||
|
switch (C)
|
||||||
|
{
|
||||||
|
case 't':
|
||||||
|
Token.Append('\t');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'r':
|
||||||
|
Token.Append('\r');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'n':
|
||||||
|
Token.Append('\n');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'b':
|
||||||
|
Token.Append('\b');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'f':
|
||||||
|
Token.Append('\f');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'u':
|
||||||
|
{
|
||||||
|
var s = aJSON.Substring(i + 1, 4);
|
||||||
|
Token.Append((char)int.Parse(
|
||||||
|
s,
|
||||||
|
System.Globalization.NumberStyles.AllowHexSpecifier));
|
||||||
|
i += 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
Token.Append(C);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Token.Append(aJSON[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QuoteMode)
|
||||||
|
{
|
||||||
|
throw new Exception("JSON Parse: Quotation marks seems to be messed up.\n" + aJSON);
|
||||||
|
}
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity LoadJson(string v)
|
||||||
|
{
|
||||||
|
var obj = Parse(SLEntity.Empty, v);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity LoadJson(SLEntity root, string v)
|
||||||
|
{
|
||||||
|
var obj = Parse(root, v);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string SaveToJson(SLEntity entity, int sortDepth = -1, bool indent = false)
|
||||||
|
{
|
||||||
|
if (indent)
|
||||||
|
{
|
||||||
|
var collection = SaveObj(null, entity, new StringBuilder(1024 * 1024 * 5), 0, sortDepth);
|
||||||
|
return collection.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var collection = SaveObjNoIndent(null, entity, new StringBuilder(1024 * 1024 * 5), 0, sortDepth);
|
||||||
|
return collection.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static StringBuilder SaveObj(string id, SLEntity entity, StringBuilder builder, int depth, int sortDepth = -1)
|
||||||
|
{
|
||||||
|
if (depth > 0) builder.Append(' ', depth);
|
||||||
|
|
||||||
|
if (entity.IsValue)
|
||||||
|
{
|
||||||
|
if (entity.IsNumeric)
|
||||||
|
{
|
||||||
|
builder.Append('\"').Append(id).Append("\": ").Append(RoundAndFormat(entity));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append('\"').Append(id).Append("\": \"");
|
||||||
|
foreach (var ch in entity.ToString())
|
||||||
|
{
|
||||||
|
if (ch == '"')
|
||||||
|
{
|
||||||
|
builder.Append("\\\"");
|
||||||
|
}
|
||||||
|
else if (ch == '\n')
|
||||||
|
{
|
||||||
|
builder.Append("\\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Append("\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (depth != 0)
|
||||||
|
{
|
||||||
|
builder.Append('\"').Append(id).Append("\": {\r\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append("{\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sortDepth != -1 && depth > sortDepth)
|
||||||
|
{
|
||||||
|
var count = entity.Count();
|
||||||
|
foreach (var child in entity.OrderBy(u =>
|
||||||
|
{
|
||||||
|
if (int.TryParse(u.ID, out var numberID))
|
||||||
|
{
|
||||||
|
return string.Format("{0}{1:0000}", u.IsValue ? 0 : 1, numberID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format("{0}{1}", u.IsValue ? 0 : 1, u.ID);
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
SaveObj(child.ID, child, builder, depth + 2, sortDepth);
|
||||||
|
count -= 1;
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
builder.Append(",\r\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append("\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var count = entity.Count();
|
||||||
|
foreach (var child in entity)
|
||||||
|
{
|
||||||
|
SaveObj(child.ID, child, builder, depth + 2, sortDepth);
|
||||||
|
count -= 1;
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
builder.Append(",\r\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append("\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (depth > 0) builder.Append(' ', depth);
|
||||||
|
builder.Append('}');
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static StringBuilder SaveObjNoIndent(string id, SLEntity entity, StringBuilder builder, int depth, int sortDepth = -1)
|
||||||
|
{
|
||||||
|
if (entity.IsValue)
|
||||||
|
{
|
||||||
|
if (entity.IsNumeric)
|
||||||
|
{
|
||||||
|
//builder.Append('\"').Append(id).Append("\":").Append(RoundAndFormat(entity)); // 인덴트가 없다는건 데이터 전송용이므로 빠르게 진행
|
||||||
|
builder.Append('\"').Append(id).Append("\":").Append(entity.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append('\"').Append(id).Append("\":\"");
|
||||||
|
foreach (var ch in entity.ToString())
|
||||||
|
{
|
||||||
|
if (ch == '"')
|
||||||
|
{
|
||||||
|
builder.Append("\\\"");
|
||||||
|
}
|
||||||
|
else if (ch == '\n')
|
||||||
|
{
|
||||||
|
builder.Append("\\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Append("\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (depth != 0)
|
||||||
|
{
|
||||||
|
builder.Append('\"').Append(id).Append("\":{");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append("{");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sortDepth != -1 && depth > sortDepth)
|
||||||
|
{
|
||||||
|
var count = entity.Count();
|
||||||
|
foreach (var child in entity.OrderBy(u =>
|
||||||
|
{
|
||||||
|
if (int.TryParse(u.ID, out var numberID))
|
||||||
|
{
|
||||||
|
return string.Format("{0}{1:0000}", u.IsValue ? 0 : 1, numberID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format("{0}{1}", u.IsValue ? 0 : 1, u.ID);
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
SaveObjNoIndent(child.ID, child, builder, depth + 2, sortDepth);
|
||||||
|
count -= 1;
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
builder.Append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var count = entity.Count();
|
||||||
|
foreach (var child in entity)
|
||||||
|
{
|
||||||
|
SaveObjNoIndent(child.ID, child, builder, depth + 2, sortDepth);
|
||||||
|
count -= 1;
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
builder.Append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Append('}');
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string RoundAndFormat(SLEntity num)
|
||||||
|
{
|
||||||
|
var str = num.ToString();
|
||||||
|
var decimalIndex = str.IndexOf('.');
|
||||||
|
if (decimalIndex >= 0)
|
||||||
|
{
|
||||||
|
// 2자리까지 반올림 대상으로 한다
|
||||||
|
var roundIndex = str.Length - 2;
|
||||||
|
if (str[roundIndex] != '9' && str[roundIndex] != '0')
|
||||||
|
{
|
||||||
|
roundIndex = str.Length - 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nine = false;
|
||||||
|
if (str[roundIndex] == '9') nine = true;
|
||||||
|
while (roundIndex > decimalIndex && ((nine && str[roundIndex] == '9') || (nine == false && str[roundIndex] == '0')))
|
||||||
|
{
|
||||||
|
roundIndex--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str.Length > decimalIndex + 6 && roundIndex <= decimalIndex)
|
||||||
|
{
|
||||||
|
// 반올림정수
|
||||||
|
return ((int)Math.Round((double)num)).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str.Length < decimalIndex + 6)
|
||||||
|
{
|
||||||
|
return str; // 단순한 소수
|
||||||
|
}
|
||||||
|
|
||||||
|
if (roundIndex < str.Length - 6) // 3~4자리 이상 반복
|
||||||
|
{
|
||||||
|
return string.Format("{0:f" + (roundIndex - decimalIndex) + "}", (double)num);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return str; // 복잡한 소수
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return str; // 정수
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8dd9a7675f6c7a74b946b262207c0d18
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using Superlazy;
|
||||||
|
|
||||||
|
namespace SLShared.Entity.Loader
|
||||||
|
{
|
||||||
|
public static class XMLLoader
|
||||||
|
{
|
||||||
|
internal static SLEntity LoadFile(string v)
|
||||||
|
{
|
||||||
|
//XmlDocument xmldoc = new XmlDocument();
|
||||||
|
//xmldoc.LoadXml(xml.text);
|
||||||
|
//XmlDocument doc = new XmlDocument();
|
||||||
|
//doc.Load(dataFolder + fileName);
|
||||||
|
//string type = doc.DocumentElement.GetAttribute("Name");
|
||||||
|
|
||||||
|
//if (xmls.ContainsKey(type) == false)
|
||||||
|
//{
|
||||||
|
// xmls[type] = new List<XMLSet>();
|
||||||
|
//}
|
||||||
|
//var set = new XMLSet();
|
||||||
|
//int dirIdx = doc.BaseURI.IndexOf(dataFolderName) + dataFolderName.Length;
|
||||||
|
//var file = doc.BaseURI.Substring(dirIdx, doc.BaseURI.Length - dirIdx - ".xml".Length);
|
||||||
|
|
||||||
|
//set.doc = doc;
|
||||||
|
//set.filePath = file;
|
||||||
|
//xmls[type].Add(set);
|
||||||
|
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 787bd37fed2046c4b8983331d51a8eeb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,207 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Superlazy.Loader
|
||||||
|
{
|
||||||
|
public static class YamlLoader
|
||||||
|
{
|
||||||
|
public static SLEntity LoadYaml(string yamlString)
|
||||||
|
{
|
||||||
|
var root = SLEntity.Empty;
|
||||||
|
LoadYaml(root, yamlString);
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadYaml(SLEntity root, string yamlString)
|
||||||
|
{
|
||||||
|
var currentEntity = root;
|
||||||
|
var stack = new Stack<Tuple<SLEntity, int>>();
|
||||||
|
|
||||||
|
using var reader = new StringReader(yamlString);
|
||||||
|
string line;
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
var lineBegin = 0;
|
||||||
|
while (lineBegin < line.Length && line[lineBegin] == ' ') lineBegin++;
|
||||||
|
|
||||||
|
if (line.Length <= lineBegin) continue;
|
||||||
|
|
||||||
|
var separatorIndex = line.IndexOf(':');
|
||||||
|
string key;
|
||||||
|
var isArray = false;
|
||||||
|
if (separatorIndex == -1)
|
||||||
|
{
|
||||||
|
if (line[lineBegin] == '#')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (line[lineBegin] == '-')
|
||||||
|
{
|
||||||
|
isArray = true;// 배열 전용 처리
|
||||||
|
key = null;
|
||||||
|
separatorIndex = lineBegin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var commentIndex = line.IndexOf('#');
|
||||||
|
if (commentIndex >= 0 && commentIndex <= separatorIndex) // 키에는 주석을 넣을수 없기 때문에 구분자 이전은 주석
|
||||||
|
{
|
||||||
|
continue; // 전체 주석
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
key = line.Substring(lineBegin, separatorIndex - lineBegin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var valueBegin = separatorIndex + 2;
|
||||||
|
var valueEnd = line.Length;
|
||||||
|
|
||||||
|
if (valueBegin + 1 < valueEnd)
|
||||||
|
{
|
||||||
|
var commentIndex = line.IndexOf('#', valueBegin, valueEnd - valueBegin);
|
||||||
|
// TODO: 문자열 내의 #은 인식 못하도록 현재가 문자열 내부인지 체크가 필요
|
||||||
|
if (commentIndex >= 0 && (commentIndex == 0 || line[commentIndex - 1] == ' ')) // 빈칸이 하나 있어야 주석임
|
||||||
|
{
|
||||||
|
valueEnd = commentIndex - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (valueEnd > valueBegin && line[valueBegin] == ' ')
|
||||||
|
{
|
||||||
|
valueBegin++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (valueEnd >= valueBegin && line[valueEnd - 1] == ' ')
|
||||||
|
{
|
||||||
|
valueEnd--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (stack.Count > 0 && lineBegin <= stack.Peek().Item2)
|
||||||
|
{
|
||||||
|
currentEntity.EndModified();
|
||||||
|
currentEntity = stack.Pop().Item1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isArray)
|
||||||
|
{
|
||||||
|
key = (currentEntity.Count() + 1).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueBegin >= valueEnd)
|
||||||
|
{
|
||||||
|
stack.Push(new Tuple<SLEntity, int>(currentEntity, lineBegin));
|
||||||
|
currentEntity = currentEntity[key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var forceString = false;
|
||||||
|
|
||||||
|
if (line[valueBegin] == '"' && line[valueEnd - 1] == '"' || line[valueBegin] == '\'' && line[valueEnd - 1] == '\'')
|
||||||
|
{
|
||||||
|
valueBegin += 1;
|
||||||
|
valueEnd -= 1;
|
||||||
|
forceString = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = line.Substring(valueBegin, valueEnd - valueBegin);
|
||||||
|
|
||||||
|
if (forceString)
|
||||||
|
{
|
||||||
|
currentEntity[key] = value;
|
||||||
|
}
|
||||||
|
else if (int.TryParse(value, out var intValue))
|
||||||
|
{
|
||||||
|
currentEntity[key] = intValue;
|
||||||
|
}
|
||||||
|
else if (double.TryParse(value, out var doubleValue))
|
||||||
|
{
|
||||||
|
currentEntity[key] = doubleValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentEntity[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (stack.Count > 0)
|
||||||
|
{
|
||||||
|
currentEntity.EndModified();
|
||||||
|
currentEntity = stack.Pop().Item1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string SaveToYaml(SLEntity entity, int indentation = 0, bool useArray = false)
|
||||||
|
{
|
||||||
|
var yamlString = new StringBuilder();
|
||||||
|
|
||||||
|
var index = 1;
|
||||||
|
|
||||||
|
IEnumerable<SLEntity> childs = entity;
|
||||||
|
if (useArray && entity.All(x => int.TryParse(x.ID, out _)))
|
||||||
|
{
|
||||||
|
childs = entity.OrderBy(x => int.Parse(x.ID));
|
||||||
|
}
|
||||||
|
else // 전부 int로 파싱 못하면, 배열로 처리하지 않음
|
||||||
|
{
|
||||||
|
useArray = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var child in childs)
|
||||||
|
{
|
||||||
|
var key = child.ID;
|
||||||
|
var value = child;
|
||||||
|
|
||||||
|
if (useArray && index > 0 && key == index.ToString())
|
||||||
|
{
|
||||||
|
key = "-";
|
||||||
|
++index;
|
||||||
|
yamlString.Append(' ', indentation).Append(key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index = -1;
|
||||||
|
yamlString.Append(' ', indentation).Append(key).Append(':');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.IsValue)
|
||||||
|
{
|
||||||
|
var valueString = value.ToString();
|
||||||
|
var needsQuotes =
|
||||||
|
value.IsNumeric == false && (int.TryParse(valueString, out _) || double.TryParse(valueString, out _)) // 숫자인데 강제로 문자화 한거거나
|
||||||
|
|| valueString.Contains('#') || valueString.StartsWith('[') || valueString.StartsWith('{') // 특수문자가 포함되어 있거나, 배열이나 객체로 시작하는 경우 {Value}
|
||||||
|
|| valueString.Contains(':') // "남은 시간: {Value}" 꼴
|
||||||
|
|| (value.IsNumeric == false && valueString.StartsWith('-')); // "- 어쩌고" 꼴, 배열인것으로 이해
|
||||||
|
|
||||||
|
yamlString.Append(' ');
|
||||||
|
|
||||||
|
if (needsQuotes)
|
||||||
|
{
|
||||||
|
yamlString.Append('"').Append(valueString.Replace("\"", "\\\"")).Append('"');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yamlString.Append(valueString);
|
||||||
|
}
|
||||||
|
|
||||||
|
yamlString.Append(Environment.NewLine);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yamlString.Append(Environment.NewLine).Append(SaveToYaml(value, indentation + 2, useArray));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return yamlString.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 033bc7e19fe121846bba30e7d4c83c37
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,21 @@
|
|||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public abstract class SLDataLoader
|
||||||
|
{
|
||||||
|
public delegate void LoadEvent(string fileExt, string data);
|
||||||
|
|
||||||
|
protected event LoadEvent OnLoad;
|
||||||
|
|
||||||
|
public void Register(LoadEvent loadAction)
|
||||||
|
{
|
||||||
|
OnLoad += loadAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void Load();
|
||||||
|
|
||||||
|
protected void Load(string fileExt, string data)
|
||||||
|
{
|
||||||
|
OnLoad?.Invoke(fileExt, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d36c4befee0ebe540b42adb2d3a165df
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,83 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public class SLWindowsLoader : SLDataLoader
|
||||||
|
{
|
||||||
|
public string DataPath { get; set; } = "../Data/";
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
|
{
|
||||||
|
if (Directory.Exists(DataPath) == false)
|
||||||
|
{
|
||||||
|
SLLog.Warn($"Cant Find Data Path {Directory.GetCurrentDirectory()}{DataPath}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//{
|
||||||
|
// string[] files = Directory.GetFiles(dataPath, "*.xml", SearchOption.AllDirectories);
|
||||||
|
// foreach (string fileName in files)
|
||||||
|
// {
|
||||||
|
// var fileRoot = Loader.XMLLoader.LoadFile(fileName);
|
||||||
|
// MergeToRoot(fileName.Replace(dataPath, string.Empty), root, fileRoot);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
{
|
||||||
|
var files = Directory.GetFiles(DataPath, "*.json", SearchOption.AllDirectories);
|
||||||
|
foreach (var fileName in files)
|
||||||
|
{
|
||||||
|
using var file = File.OpenText(fileName);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var json = file.ReadToEnd();
|
||||||
|
Load("json", json);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
SLLog.Error($"Cannot Parse {fileName}. \n{e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
files = Directory.GetFiles(DataPath, "*.yaml", SearchOption.AllDirectories);
|
||||||
|
|
||||||
|
var generatedEvents = new List<string>();
|
||||||
|
|
||||||
|
foreach (var fileName in files)
|
||||||
|
{
|
||||||
|
if (fileName.Contains("Generated")) // 생성된 파일들
|
||||||
|
{
|
||||||
|
generatedEvents.Add(fileName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
using var file = File.OpenText(fileName);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var json = file.ReadToEnd();
|
||||||
|
Load("yaml", json);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
SLLog.Error($"Cannot Parse {fileName}. \n{e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var fileName in generatedEvents)
|
||||||
|
{
|
||||||
|
using var file = File.OpenText(fileName);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var json = file.ReadToEnd();
|
||||||
|
Load("yaml", json);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
SLLog.Error($"Cannot Parse {fileName}. \n{e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 07385c4442bbc7944a0a44d2d249ce22
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
74
Assets/_Datas/SLShared/SLSystem/SLLinqUtil.cs
Normal file
74
Assets/_Datas/SLShared/SLSystem/SLLinqUtil.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public static class SLLinqUtil
|
||||||
|
{
|
||||||
|
public static TSource MinBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector)
|
||||||
|
{
|
||||||
|
return source.MinBy(selector, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TSource MinBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector, IComparer<TKey> comparer)
|
||||||
|
{
|
||||||
|
if (source == null) throw new ArgumentNullException("source");
|
||||||
|
if (selector == null) throw new ArgumentNullException("selector");
|
||||||
|
if (comparer == null) comparer = Comparer<TKey>.Default;
|
||||||
|
|
||||||
|
using var sourceIterator = source.GetEnumerator();
|
||||||
|
if (!sourceIterator.MoveNext())
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Sequence contains no elements");
|
||||||
|
}
|
||||||
|
|
||||||
|
var min = sourceIterator.Current;
|
||||||
|
var minKey = selector(min);
|
||||||
|
while (sourceIterator.MoveNext())
|
||||||
|
{
|
||||||
|
var candidate = sourceIterator.Current;
|
||||||
|
var candidateProjected = selector(candidate);
|
||||||
|
if (comparer.Compare(candidateProjected, minKey) < 0)
|
||||||
|
{
|
||||||
|
min = candidate;
|
||||||
|
minKey = candidateProjected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TSource MaxBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector)
|
||||||
|
{
|
||||||
|
return source.MaxBy(selector, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TSource MaxBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector, IComparer<TKey> comparer)
|
||||||
|
{
|
||||||
|
if (source == null) throw new ArgumentNullException("source");
|
||||||
|
if (selector == null) throw new ArgumentNullException("selector");
|
||||||
|
if (comparer == null) comparer = Comparer<TKey>.Default;
|
||||||
|
|
||||||
|
using var sourceIterator = source.GetEnumerator();
|
||||||
|
if (!sourceIterator.MoveNext())
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Sequence contains no elements");
|
||||||
|
}
|
||||||
|
|
||||||
|
var max = sourceIterator.Current;
|
||||||
|
var maxKey = selector(max);
|
||||||
|
while (sourceIterator.MoveNext())
|
||||||
|
{
|
||||||
|
var candidate = sourceIterator.Current;
|
||||||
|
var candidateProjected = selector(candidate);
|
||||||
|
if (comparer.Compare(candidateProjected, maxKey) > 0)
|
||||||
|
{
|
||||||
|
max = candidate;
|
||||||
|
maxKey = candidateProjected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLSystem/SLLinqUtil.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLSystem/SLLinqUtil.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 57b616d93fdce604b9a2ec4e0624e0c8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
38
Assets/_Datas/SLShared/SLSystem/SLRandom.cs
Normal file
38
Assets/_Datas/SLShared/SLSystem/SLRandom.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public class SLRandom
|
||||||
|
{
|
||||||
|
private readonly SLEntity root;
|
||||||
|
private readonly string key;
|
||||||
|
|
||||||
|
public SLRandom(SLEntity root, string key)
|
||||||
|
{
|
||||||
|
this.root = root;
|
||||||
|
this.key = key;
|
||||||
|
if (this.root[key] == false)
|
||||||
|
{
|
||||||
|
this.root[key] = new Random().Next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Next(int min, int max)
|
||||||
|
{
|
||||||
|
int seed = root[key];
|
||||||
|
root[key] = new Random(seed).Next();
|
||||||
|
|
||||||
|
return new Random(seed).Next(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double NextDouble()
|
||||||
|
{
|
||||||
|
int seed = root[key];
|
||||||
|
root[key] = new Random(seed).Next();
|
||||||
|
|
||||||
|
return new Random(seed).NextDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLSystem/SLRandom.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLSystem/SLRandom.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 182fb08274d05ac488182eaea27ed2fd
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
16
Assets/_Datas/SLShared/SLSystem/SLSystem.asmdef
Normal file
16
Assets/_Datas/SLShared/SLSystem/SLSystem.asmdef
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "SLSystem",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"GUID:f0e91edf4495c2045b34f001325cddb3"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
7
Assets/_Datas/SLShared/SLSystem/SLSystem.asmdef.meta
Normal file
7
Assets/_Datas/SLShared/SLSystem/SLSystem.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 873a4b43aaa8c8440bf2b49356e666ff
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
41
Assets/_Datas/SLShared/SLSystem/SLSystem.cs
Normal file
41
Assets/_Datas/SLShared/SLSystem/SLSystem.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using Superlazy.Loader;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public class SLSystem
|
||||||
|
{
|
||||||
|
public void Init(SLDataLoader loader, DateTime now)
|
||||||
|
{
|
||||||
|
Load(loader);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Load(SLDataLoader loader)
|
||||||
|
{
|
||||||
|
Data = SLEntity.Empty;
|
||||||
|
loader.Register(LoadJson);
|
||||||
|
SLLog.Info("Data Loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void LoadJson(string fileExt, string json)
|
||||||
|
{
|
||||||
|
if (fileExt == "json")
|
||||||
|
{
|
||||||
|
JsonLoader.LoadJson(Data, json);
|
||||||
|
}
|
||||||
|
else if (fileExt == "yaml")
|
||||||
|
{
|
||||||
|
YamlLoader.LoadYaml(Data, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLEntity Data { get; private set; }
|
||||||
|
public static DateTime Now => DateTime.UtcNow;
|
||||||
|
|
||||||
|
//public static DateTime Now
|
||||||
|
//{
|
||||||
|
// get => SLDateTime.Now;
|
||||||
|
// private set => SLDateTime.Now = value;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLSystem/SLSystem.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLSystem/SLSystem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1f601fedd9e1c0548826ac041c8f37ea
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
7
Assets/_Datas/SLShared/SLSystem/SLSystem.csproj.meta
Normal file
7
Assets/_Datas/SLShared/SLSystem/SLSystem.csproj.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b2f8a18eb8f672b4fae8e545a0e287af
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
197
Assets/_Datas/SLShared/SLSystem/SLSystemUtility.cs
Normal file
197
Assets/_Datas/SLShared/SLSystem/SLSystemUtility.cs
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
public static class SLSystemUtility
|
||||||
|
{
|
||||||
|
public static void CreateTypeList<T>(this List<Type> ret) where T : class
|
||||||
|
{
|
||||||
|
ForeachTypeof(typeof(T), (a, t) =>
|
||||||
|
{
|
||||||
|
ret.Add(t);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateInstanceList<T>(this List<T> ret) where T : class
|
||||||
|
{
|
||||||
|
ForeachTypeof(typeof(T), (a, t) =>
|
||||||
|
{
|
||||||
|
var obj = a.CreateInstance(t.FullName);
|
||||||
|
ret.Add(obj as T);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateInstanceList<T>(this List<T> ret, string[] typeNames) where T : class
|
||||||
|
{
|
||||||
|
ForeachTypeof(typeof(T), (a, t) =>
|
||||||
|
{
|
||||||
|
if (typeNames.FirstOrDefault(n => n == t.FullName) == null) return;
|
||||||
|
|
||||||
|
var obj = a.CreateInstance(t.FullName);
|
||||||
|
ret.Add(obj as T);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateInstanceDictionary<T>(this Dictionary<string, T> ret) where T : class
|
||||||
|
{
|
||||||
|
ForeachTypeof(typeof(T), (a, t) =>
|
||||||
|
{
|
||||||
|
var obj = a.CreateInstance(t.FullName);
|
||||||
|
ret.Add(t.Name, obj as T);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateInstanceDictionary<T>(this Dictionary<string, T> ret, string[] typeNames) where T : class
|
||||||
|
{
|
||||||
|
ForeachTypeof(typeof(T), (a, t) =>
|
||||||
|
{
|
||||||
|
if (typeNames.FirstOrDefault(n => n == t.FullName) == null) return;
|
||||||
|
|
||||||
|
var obj = a.CreateInstance(t.FullName);
|
||||||
|
ret.Add(t.Name, obj as T);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateMethodInfoDictionary<T>(this Dictionary<string, Dictionary<string, MethodInfo>> ret, bool useReturn, params Type[] argTypes) where T : class
|
||||||
|
{
|
||||||
|
ForeachTypeof(typeof(T), (a, t) =>
|
||||||
|
{
|
||||||
|
var methodArr = t.GetMethods();
|
||||||
|
var methodDic = new Dictionary<string, MethodInfo>();
|
||||||
|
for (var i = 0; i < methodArr.Length; i++)
|
||||||
|
{
|
||||||
|
var method = methodArr[i];
|
||||||
|
var parameters = method.GetParameters();
|
||||||
|
if (parameters.CompareLengthAndTypes(argTypes.Skip(useReturn ? 1 : 0).ToArray()) && (useReturn ? method.ReturnType == argTypes[0] : method.ReturnType == typeof(void)))
|
||||||
|
methodDic.Add(method.Name, method);
|
||||||
|
}
|
||||||
|
ret.Add(t.Name, methodDic);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateCommandInfoToBaseType<T>(this Dictionary<string, (T instance, MethodInfo method)> ret, T instance, params Type[] argTypes) where T : class
|
||||||
|
{
|
||||||
|
var methodArr = instance.GetType().GetMethods();
|
||||||
|
for (var i = 0; i < methodArr.Length; i++)
|
||||||
|
{
|
||||||
|
var method = methodArr[i];
|
||||||
|
var parameters = method.GetParameters();
|
||||||
|
if (parameters.CompareLengthAndTypes(typeof(SLEntity)))
|
||||||
|
{
|
||||||
|
ret.Add(string.Format("{0}/{1}", instance.GetType().Name, method.Name), (instance, method));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<MethodInfo> GetMethods<T>() where T : class
|
||||||
|
{
|
||||||
|
var methods = new List<MethodInfo>();
|
||||||
|
var rootType = typeof(T);
|
||||||
|
|
||||||
|
ForeachTypeof(typeof(T), (a, t) =>
|
||||||
|
{
|
||||||
|
foreach (var m in t.GetMethods())
|
||||||
|
{
|
||||||
|
methods.Add(m);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return methods;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsInherited(this Type t, Type inherited)
|
||||||
|
{
|
||||||
|
if (t.BaseType == null || t.BaseType == typeof(object))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (t.BaseType == inherited)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return t.BaseType.IsInherited(inherited);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Type GetRootBaseType(Type t)
|
||||||
|
{
|
||||||
|
if (t.BaseType == null || t.BaseType == typeof(object))
|
||||||
|
return t;
|
||||||
|
else
|
||||||
|
return GetRootBaseType(t.BaseType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CompareLengthAndTypes(this ParameterInfo[] parameters, params Type[] types)
|
||||||
|
{
|
||||||
|
if (parameters.Length != types.Length)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (var i = 0; i < parameters.Length; i++)
|
||||||
|
{
|
||||||
|
if (parameters[i].ParameterType != types[i])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T CreateInstance<T>(string typeName) where T : class
|
||||||
|
{
|
||||||
|
var type = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
.Select(a => a.GetTypes().FirstOrDefault(t => t.Name == typeName))
|
||||||
|
.FirstOrDefault(t => t != null);
|
||||||
|
if (type == null) return null;
|
||||||
|
|
||||||
|
return type.Assembly.CreateInstance(type.FullName) as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ForeachTypeof(Type rootType, Action<Assembly, Type> action)
|
||||||
|
{
|
||||||
|
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
if (a.FullName.IsLeft("Mono.")) continue;
|
||||||
|
if (a.FullName.IsLeft("SyntaxTree.")) continue;
|
||||||
|
if (a.FullName.IsLeft("nunit.")) continue;
|
||||||
|
if (a.FullName.IsLeft("Unity.")) continue;
|
||||||
|
if (a.FullName.IsLeft("ICSharpCode.")) continue;
|
||||||
|
if (a.FullName.IsLeft("Newtonsoft.")) continue;
|
||||||
|
if (a.FullName.IsLeft("Facebook")) continue;
|
||||||
|
if (a.FullName.IsLeft("winrt")) continue;
|
||||||
|
if (a.FullName.IsLeft("Tizen")) continue;
|
||||||
|
if (a.FullName.IsLeft("Apple")) continue;
|
||||||
|
if (a.FullName.IsLeft("Security")) continue;
|
||||||
|
if (a.FullName.IsLeft("Stores")) continue;
|
||||||
|
if (a.FullName.IsLeft("Purchasing.")) continue;
|
||||||
|
if (a.FullName.IsLeft("UnityStore")) continue;
|
||||||
|
if (a.FullName.IsLeft("Editor")) continue;
|
||||||
|
if (a.FullName.IsLeft("ChannelPurchase")) continue;
|
||||||
|
if (a.FullName.IsLeft("Google.")) continue;
|
||||||
|
if (a.FullName.IsLeft("UnityScript")) continue;
|
||||||
|
if (a.FullName.IsLeft("Boo.Lan")) continue;
|
||||||
|
if (a.FullName.IsLeft("System")) continue;
|
||||||
|
if (a.FullName.IsLeft("I18N")) continue;
|
||||||
|
if (a.FullName.IsLeft("UnityEngine")) continue;
|
||||||
|
if (a.FullName.IsLeft("UnityEditor")) continue;
|
||||||
|
if (a.FullName.IsLeft("mscorlib")) continue;
|
||||||
|
if (a.FullName.IsLeft("NiceIO")) continue;
|
||||||
|
if (a.FullName.IsLeft("PP")) continue;
|
||||||
|
if (a.FullName.IsLeft("PlayerBuild")) continue;
|
||||||
|
if (a.FullName.IsLeft("AndroidPlayerBuild")) continue;
|
||||||
|
if (a.FullName.IsLeft("Ex")) continue;
|
||||||
|
if (a.FullName.IsLeft("ScriptCompilation")) continue;
|
||||||
|
if (a.FullName.IsLeft("Anonymously")) continue;
|
||||||
|
|
||||||
|
foreach (var t in a.GetTypes())
|
||||||
|
{
|
||||||
|
if (t.IsAbstract) continue;
|
||||||
|
if (t.IsClass == false) continue;
|
||||||
|
if (rootType.IsAssignableFrom(t) == false) continue;
|
||||||
|
|
||||||
|
action(a, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLSystem/SLSystemUtility.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLSystem/SLSystemUtility.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 47baa16888b22b848b00adbfe04cf1e6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/SLShared/SLSystem/UnitComponent.meta
Normal file
8
Assets/_Datas/SLShared/SLSystem/UnitComponent.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5a0a9b72590e6ba4eb531b8cabebcf20
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
11
Assets/_Datas/SLShared/SLSystem/package.json
Normal file
11
Assets/_Datas/SLShared/SLSystem/package.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "com.superlazy.slsystem",
|
||||||
|
"displayName": "SL System",
|
||||||
|
"description": "SL System",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"unity": "2018.2",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"com.superlazy.sllogger": "latest"
|
||||||
|
}
|
||||||
|
}
|
7
Assets/_Datas/SLShared/SLSystem/package.json.meta
Normal file
7
Assets/_Datas/SLShared/SLSystem/package.json.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d32afcdffb5cbad43a530a5f7ce853bb
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/SLShared/SLUnity.meta
Normal file
8
Assets/_Datas/SLShared/SLUnity.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 499cd1f0654e08446927bf1f137e8c19
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
20
Assets/_Datas/SLShared/SLUnity/CustomSceneCamera.cs
Normal file
20
Assets/_Datas/SLShared/SLUnity/CustomSceneCamera.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(Camera))]
|
||||||
|
public class CustomSceneCamera : MonoBehaviour
|
||||||
|
{
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
// add stack to camera
|
||||||
|
var cam = GetComponent<Camera>();
|
||||||
|
SLGame.Camera.GetUniversalAdditionalCameraData().cameraStack.Insert(0, cam);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
// remove stack to camera
|
||||||
|
var cam = GetComponent<Camera>();
|
||||||
|
SLGame.Camera.GetUniversalAdditionalCameraData().cameraStack.Remove(cam);
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLUnity/CustomSceneCamera.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLUnity/CustomSceneCamera.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 097f62a8d87588f498dcbf5c614e2cb4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/SLShared/SLUnity/Editor.meta
Normal file
8
Assets/_Datas/SLShared/SLUnity/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b528e8b40736de4408eb6b9f053c6571
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,39 @@
|
|||||||
|
//using UnityEngine;
|
||||||
|
//using UnityEditor;
|
||||||
|
//using Unity.EditorCoroutines.Editor;
|
||||||
|
|
||||||
|
//using System.Collections;
|
||||||
|
//using System.IO;
|
||||||
|
//using System.Text;
|
||||||
|
|
||||||
|
//public class FixTexturePlatformSettings : AssetPostprocessor
|
||||||
|
//{
|
||||||
|
// private void OnPostprocessTexture(Texture2D texture)
|
||||||
|
// {
|
||||||
|
// EditorCoroutineUtility.StartCoroutine(Fix($"{assetPath}.meta"), this);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// private IEnumerator Fix(string metafile)
|
||||||
|
// {
|
||||||
|
// // Wait for .meta to be created
|
||||||
|
// while (!File.ReadAllText(metafile).Contains("platformSettings:"))
|
||||||
|
// yield return null;
|
||||||
|
|
||||||
|
// // Read .meta file
|
||||||
|
// var original = File.ReadAllText(metafile);
|
||||||
|
// var meta = new StringBuilder(original);
|
||||||
|
|
||||||
|
// if (meta.ToString().Contains("iPhone"))
|
||||||
|
// {
|
||||||
|
// meta.Replace("iPhone", "iOS");
|
||||||
|
// Debug.Log("Replaced iPhone to iOS");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Save .meta file
|
||||||
|
// if (meta.ToString() != original)
|
||||||
|
// {
|
||||||
|
// File.WriteAllText(metafile, meta.ToString());
|
||||||
|
// AssetDatabase.Refresh();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1840d074593b59249bc7f1035d9c6259
|
124
Assets/_Datas/SLShared/SLUnity/Editor/SLAssetPostprocessor.cs
Normal file
124
Assets/_Datas/SLShared/SLUnity/Editor/SLAssetPostprocessor.cs
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
public class SLAssetPostprocessor : AssetPostprocessor
|
||||||
|
{
|
||||||
|
private void OnPreprocessModel()
|
||||||
|
{
|
||||||
|
var importer = assetImporter as ModelImporter;
|
||||||
|
var upperPath = importer.assetPath.ToUpper();
|
||||||
|
|
||||||
|
if (upperPath.Contains("ASSETS/RAW/"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (upperPath.Contains("ASSETS/RAW/UNITS/") && upperPath.Contains("_") == false && upperPath.Contains(".FBX"))
|
||||||
|
{
|
||||||
|
var fileName = SLFileUtility.FileName(upperPath);
|
||||||
|
var folderName = SLFileUtility.FolderName(upperPath);
|
||||||
|
if (fileName == folderName)
|
||||||
|
{
|
||||||
|
SLAssetPostprocessorModel.OnPreprocessModel(importer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (upperPath.Contains("ASSETS/RAW/UNITS/") && upperPath.Contains("_") && upperPath.Contains(".FBX"))
|
||||||
|
{
|
||||||
|
SLAssetPostprocessorAnim.OnPreprocessModel(importer);
|
||||||
|
}
|
||||||
|
else if (upperPath.Contains("ASSETS/RAW/UNITS/") && upperPath.Contains("_PREFAB.PREFAB"))
|
||||||
|
{
|
||||||
|
SLAssetPostprocessorModel.OnPreprocessModel(importer);
|
||||||
|
}
|
||||||
|
else if (upperPath.Contains("ASSETS/RAW/EFFECTS/"))
|
||||||
|
{
|
||||||
|
SLAssetPostprocessorEffect.OnPreprocessModel(importer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPreprocessAnimation()
|
||||||
|
{
|
||||||
|
var importer = assetImporter as ModelImporter;
|
||||||
|
var upperPath = importer.assetPath.ToUpper();
|
||||||
|
if (upperPath.Contains("ASSETS/RAW/UNITS/") && upperPath.Contains("_") && upperPath.Contains(".FBX"))
|
||||||
|
{
|
||||||
|
SLAssetPostprocessorAnim.OnPreprocessAnim(importer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPreprocessTexture()
|
||||||
|
{
|
||||||
|
var importer = assetImporter as TextureImporter;
|
||||||
|
|
||||||
|
var upperPath = importer.assetPath.ToUpper();
|
||||||
|
|
||||||
|
if (upperPath.Contains("ASSETS/RAW/Units/"))
|
||||||
|
{
|
||||||
|
SLAssetPostprocessorModel.OnPreprocessTexture(importer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (upperPath.Contains("ASSETS/RAW/SPRITES/"))
|
||||||
|
{
|
||||||
|
SLAssetPostprocessorSprite.OnPreprocessTexture(importer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnPostprocessAllAssets(string[] importedAssets, string[] deleteAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
||||||
|
{
|
||||||
|
foreach (var path in deleteAssets)
|
||||||
|
{
|
||||||
|
PostRem(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
foreach (var path in movedFromAssetPaths)
|
||||||
|
{
|
||||||
|
PostRem(path, movedAssets[index]);
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var path in movedAssets)
|
||||||
|
{
|
||||||
|
PostAdd(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var path in importedAssets)
|
||||||
|
{
|
||||||
|
PostAdd(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
SLAssetPostprocessorModel.BuildTarget();
|
||||||
|
SLAssetPostprocessorSprite.BuildTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PostRem(string path, string movePath = "")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SLAssetPostprocessorModel.OnRemove(path);
|
||||||
|
SLAssetPostprocessorAnim.OnRemove(path);
|
||||||
|
SLAssetPostprocessorEffect.OnRemove(path);
|
||||||
|
SLAssetPostprocessorSprite.OnRemove(path, movePath);
|
||||||
|
SLAssetPostprocessorScene.OnRemove(path);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError("Can't remove " + path + "\n" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PostAdd(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SLAssetPostprocessorModel.OnAdd(path);
|
||||||
|
SLAssetPostprocessorAnim.OnAdd(path);
|
||||||
|
SLAssetPostprocessorEffect.OnAdd(path);
|
||||||
|
SLAssetPostprocessorSprite.OnAdd(path);
|
||||||
|
SLAssetPostprocessorScene.OnAdd(path);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError("Can't import " + path + "\n" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d0e900ab5eb37a3469e1c230f61f28f4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,79 @@
|
|||||||
|
using Superlazy;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public static class SLAssetPostprocessorAnim
|
||||||
|
{
|
||||||
|
private static string GetDestPath(string path)
|
||||||
|
{
|
||||||
|
return SLFileUtility.FolderPath(SLFileUtility.FolderPath(path)).Replace("/Raw/", "/Addressables/") + "/" + SLFileUtility.FileName(path) + ".anim";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnPreprocessModel(ModelImporter importer)
|
||||||
|
{
|
||||||
|
importer.materialImportMode = ModelImporterMaterialImportMode.None;
|
||||||
|
importer.importAnimation = true;
|
||||||
|
importer.generateSecondaryUV = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void OnPreprocessAnim(ModelImporter importer)
|
||||||
|
{
|
||||||
|
var clips = new ModelImporterClipAnimation[importer.defaultClipAnimations.Length];
|
||||||
|
var i = 0;
|
||||||
|
foreach (var clip in importer.defaultClipAnimations)
|
||||||
|
{
|
||||||
|
clips[i] = clip;
|
||||||
|
clips[i].name = SLFileUtility.FileName(importer.assetPath);
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
importer.clipAnimations = clips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnRemove(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (upperPath.IsLeft("ASSETS/RAW/UNITS/") && SLFileUtility.FileName(path).Contains("_") && upperPath.Contains(".FBX"))
|
||||||
|
{
|
||||||
|
var newPath = GetDestPath(path);
|
||||||
|
AssetDatabase.DeleteAsset(newPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (upperPath.IsLeft("ASSETS/RAW/UNITS/") && SLFileUtility.FileName(path).Contains("_") && upperPath.Contains(".ANIM"))
|
||||||
|
{
|
||||||
|
var newPath = GetDestPath(path);
|
||||||
|
AssetDatabase.DeleteAsset(newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnAdd(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (upperPath.IsLeft("ASSETS/RAW/UNITS/") && SLFileUtility.FileName(path).Contains("_") && upperPath.Contains(".FBX"))
|
||||||
|
{
|
||||||
|
CreateAnimation(path, GetDestPath(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (upperPath.IsLeft("ASSETS/RAW/UNITS/") && SLFileUtility.FileName(path).Contains("_") && upperPath.Contains(".ANIM"))
|
||||||
|
{
|
||||||
|
AssetDatabase.CopyAsset(path, GetDestPath(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateAnimation(string path, string destPath)
|
||||||
|
{
|
||||||
|
SLFileUtility.MakeFolderFromFilePath(destPath);
|
||||||
|
|
||||||
|
var motion = AssetDatabase.LoadAssetAtPath<Motion>(path);
|
||||||
|
|
||||||
|
if (motion == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("Cant load motion: " + path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newMotion = Object.Instantiate(motion);
|
||||||
|
AssetDatabase.CreateAsset(newMotion, destPath);
|
||||||
|
|
||||||
|
Debug.Log("Animation Build : " + destPath, newMotion);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2467d52cdb48ded4fb37d3ace7c45b16
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,79 @@
|
|||||||
|
using Superlazy;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.U2D;
|
||||||
|
using UnityEngine;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
|
public interface IPostProcessorEffect
|
||||||
|
{
|
||||||
|
void OnCreateEffectPrefab(GameObject root);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SLAssetPostprocessorEffect
|
||||||
|
{
|
||||||
|
public static void OnPreprocessModel(ModelImporter importer)
|
||||||
|
{
|
||||||
|
importer.materialImportMode = ModelImporterMaterialImportMode.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateEffect(string path, string destPath)
|
||||||
|
{
|
||||||
|
var effectCreateComponents = new List<IPostProcessorEffect>();
|
||||||
|
effectCreateComponents.CreateInstanceList();
|
||||||
|
|
||||||
|
var originalPrefab = AssetDatabase.LoadMainAssetAtPath(path) as GameObject;
|
||||||
|
var obj = Object.Instantiate(originalPrefab);
|
||||||
|
|
||||||
|
if (obj == null) return;
|
||||||
|
|
||||||
|
var root = new GameObject();
|
||||||
|
root.SetActive(false);
|
||||||
|
obj.transform.localPosition = Vector3.zero;
|
||||||
|
obj.transform.localRotation = Quaternion.identity;
|
||||||
|
obj.transform.SetParent(root.transform);
|
||||||
|
obj.name = originalPrefab.name;
|
||||||
|
|
||||||
|
var res = root.AddComponent<SLResourceObject>();
|
||||||
|
|
||||||
|
foreach (var comp in effectCreateComponents)
|
||||||
|
{
|
||||||
|
comp.OnCreateEffectPrefab(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.Init();
|
||||||
|
|
||||||
|
SLFileUtility.MakeFolderFromFilePath(destPath);
|
||||||
|
var prefab = PrefabUtility.SaveAsPrefabAsset(root, destPath);
|
||||||
|
prefab.SetActive(true);
|
||||||
|
Object.DestroyImmediate(root);
|
||||||
|
|
||||||
|
Debug.Log("Build : " + destPath, prefab);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnRemove(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (upperPath.IsLeft("ASSETS/RAW/EFFECTS") && upperPath.Contains(".PREFAB"))
|
||||||
|
{
|
||||||
|
var newPath = GetDestPath(path);
|
||||||
|
AssetDatabase.DeleteAsset(newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetDestPath(string path)
|
||||||
|
{
|
||||||
|
var name = SLFileUtility.FileName(path);
|
||||||
|
return SLFileUtility.FolderPath(path).Replace("/Raw/", "/Addressables/") + "/" + name + ".prefab";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnAdd(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (SLFileUtility.FolderPath(path).IsLeft("Assets/Raw/Effects") && upperPath.Contains(".PREFAB"))
|
||||||
|
{
|
||||||
|
var newPath = GetDestPath(path);
|
||||||
|
CreateEffect(path, newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 124d528fadb06c1429ff11803a503baa
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,200 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Superlazy;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.Animations;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public interface IPostProcessorModel
|
||||||
|
{
|
||||||
|
void OnCreatePrefab(string path, GameObject model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SLAssetPostprocessorModel
|
||||||
|
{
|
||||||
|
private static readonly HashSet<string> targetPaths = new HashSet<string>();
|
||||||
|
|
||||||
|
private static string GetDestPath(string path)
|
||||||
|
{
|
||||||
|
return SLFileUtility.FolderPath(path).Replace("/Raw/", "/Addressables/") + ".prefab";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetPrefabPath(string path)
|
||||||
|
{
|
||||||
|
var targetName = SLFileUtility.FolderName(path);
|
||||||
|
var targetPath = SLFileUtility.FolderPath(path);
|
||||||
|
|
||||||
|
if (SLFileUtility.FolderName(path) == "Materials")
|
||||||
|
{
|
||||||
|
targetName = SLFileUtility.FolderName(targetPath);
|
||||||
|
targetPath = SLFileUtility.FolderPath(targetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetPath + "/" + targetName + ".prefab";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetTargetFBX(string path)
|
||||||
|
{
|
||||||
|
var targetName = SLFileUtility.FolderName(path);
|
||||||
|
var targetPath = SLFileUtility.FolderPath(path);
|
||||||
|
|
||||||
|
if (SLFileUtility.FolderName(path) == "Materials")
|
||||||
|
{
|
||||||
|
targetName = SLFileUtility.FolderName(targetPath);
|
||||||
|
targetPath = SLFileUtility.FolderPath(targetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetPath + "/" + targetName + ".FBX";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnPreprocessModel(ModelImporter importer)
|
||||||
|
{
|
||||||
|
importer.materialImportMode = ModelImporterMaterialImportMode.None;
|
||||||
|
importer.generateSecondaryUV = false;
|
||||||
|
importer.importAnimation = false;
|
||||||
|
importer.animationType = ModelImporterAnimationType.Generic;
|
||||||
|
importer.avatarSetup = ModelImporterAvatarSetup.CreateFromThisModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnRemove(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (upperPath.IsLeft("ASSETS/RAW/UNITS/") && (upperPath.Contains(".FBX") || upperPath.Contains(".MAT")))
|
||||||
|
{
|
||||||
|
if (SLFileUtility.FolderName(path) != SLFileUtility.FileName(path)) return;
|
||||||
|
var newPath = GetDestPath(path);
|
||||||
|
AssetDatabase.DeleteAsset(newPath);
|
||||||
|
|
||||||
|
var prefabPath = GetPrefabPath(path);
|
||||||
|
AssetDatabase.DeleteAsset(prefabPath);
|
||||||
|
|
||||||
|
targetPaths.Add(GetTargetFBX(path)); // 삭제되어도 리빌드
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnAdd(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (upperPath.IsLeft("ASSETS/RAW/UNITS/") && (upperPath.Contains(".FBX") || upperPath.Contains(".MAT")))
|
||||||
|
{
|
||||||
|
if (SLFileUtility.FolderName(path) != SLFileUtility.FileName(path)) return;
|
||||||
|
targetPaths.Add(GetTargetFBX(path));
|
||||||
|
}
|
||||||
|
else if (upperPath.IsLeft("ASSETS/RAW/UNITS/") && upperPath.Contains("_PREFAB.PREFAB"))
|
||||||
|
{
|
||||||
|
targetPaths.Add(GetPrefabPath(path).Replace(".prefab", "_Prefab.prefab"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreatePrefab(string path, string destPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var modelCreateComponents = new List<IPostProcessorModel>();
|
||||||
|
modelCreateComponents.CreateInstanceList();
|
||||||
|
var go = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
||||||
|
|
||||||
|
if (go == null) return;
|
||||||
|
|
||||||
|
var prefab = new GameObject(go.name);
|
||||||
|
var model = Object.Instantiate(go);
|
||||||
|
model.name = "Model";
|
||||||
|
model.transform.SetParent(prefab.transform);
|
||||||
|
model.AddComponent<UnitAnimatorController>();
|
||||||
|
|
||||||
|
var guids = AssetDatabase.FindAssets("t:Material", new string[] { SLFileUtility.FolderPath(path) });
|
||||||
|
var materials = guids.Select(guid => AssetDatabase.LoadAssetAtPath<Material>(AssetDatabase.GUIDToAssetPath(guid))).ToDictionary(m => m.name);
|
||||||
|
|
||||||
|
foreach (var renderer in model.GetComponentsInChildren<Renderer>())
|
||||||
|
{
|
||||||
|
var sharedMaterials = new Material[renderer.sharedMaterials.Length]; // Material을 직접 엘리먼트로 대입하면 안되고 배열을 통으로 넣어야함
|
||||||
|
for (var i = 0; i < renderer.sharedMaterials.Length; ++i)
|
||||||
|
{
|
||||||
|
if (materials.TryGetValue($"{renderer.name}_{i + 1}", out var numMat))
|
||||||
|
{
|
||||||
|
sharedMaterials[i] = numMat;
|
||||||
|
}
|
||||||
|
else if (materials.TryGetValue(renderer.name, out var mat))
|
||||||
|
{
|
||||||
|
sharedMaterials[i] = mat;
|
||||||
|
}
|
||||||
|
else if (materials.TryGetValue(go.name, out var defaultMat))
|
||||||
|
{
|
||||||
|
sharedMaterials[i] = defaultMat;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sharedMaterials[i] = renderer.sharedMaterials[i];
|
||||||
|
// 에러인가? 잠깐 파일 안갖다놨을뿐인가?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
renderer.sharedMaterials = sharedMaterials;
|
||||||
|
}
|
||||||
|
|
||||||
|
var res = prefab.AddComponent<SLResourceObject>();
|
||||||
|
|
||||||
|
foreach (var comp in modelCreateComponents)
|
||||||
|
{
|
||||||
|
comp.OnCreatePrefab(destPath, model);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.Init();
|
||||||
|
|
||||||
|
SLFileUtility.MakeFolderFromFilePath(destPath);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Make Duumy(for test)
|
||||||
|
var dummyObj = Object.Instantiate(model);
|
||||||
|
var anim = dummyObj.GetComponentInChildren<Animator>();
|
||||||
|
var controller = AnimatorController.CreateAnimatorControllerAtPath(GetPrefabPath(path).Replace(".prefab", ".controller"));
|
||||||
|
|
||||||
|
anim.runtimeAnimatorController = controller;
|
||||||
|
var rootStateMachine = controller.layers[0].stateMachine;
|
||||||
|
|
||||||
|
var clipids = AssetDatabase.FindAssets("t:AnimationClip", new string[] { SLFileUtility.FolderPath(path) });
|
||||||
|
foreach (var guid in clipids)
|
||||||
|
{
|
||||||
|
var clip = AssetDatabase.LoadAssetAtPath<AnimationClip>(AssetDatabase.GUIDToAssetPath(guid));
|
||||||
|
if (clip != null)
|
||||||
|
{
|
||||||
|
var state = rootStateMachine.AddState(clip.name);
|
||||||
|
state.motion = clip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dummy = PrefabUtility.SaveAsPrefabAssetAndConnect(dummyObj, GetPrefabPath(path), InteractionMode.AutomatedAction);
|
||||||
|
|
||||||
|
Object.DestroyImmediate(dummyObj, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetDatabase.DeleteAsset(destPath);
|
||||||
|
var newPreafb = PrefabUtility.SaveAsPrefabAssetAndConnect(prefab, destPath, InteractionMode.AutomatedAction);
|
||||||
|
|
||||||
|
Object.DestroyImmediate(prefab, false);
|
||||||
|
Debug.Log("Build : " + destPath, newPreafb);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError("Cant build " + destPath + "\n" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BuildTarget()
|
||||||
|
{
|
||||||
|
foreach (var path in targetPaths)
|
||||||
|
{
|
||||||
|
CreatePrefab(path, GetDestPath(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
targetPaths.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void OnPreprocessTexture(TextureImporter importer)
|
||||||
|
{
|
||||||
|
importer.sRGBTexture = true;
|
||||||
|
importer.mipmapEnabled = false;
|
||||||
|
importer.streamingMipmaps = false;
|
||||||
|
importer.wrapMode = TextureWrapMode.Clamp;
|
||||||
|
importer.filterMode = FilterMode.Bilinear;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 68886d6dc8c664d4599d806c35f64197
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,36 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
public static class SLAssetPostprocessorScene
|
||||||
|
{
|
||||||
|
private static string GetDestPath(string path)
|
||||||
|
{
|
||||||
|
return path.Replace("/Raw/", "/Addressables/");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnRemove(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
|
||||||
|
if (upperPath.Contains("ASSETS/RAW/SCENES/") == false || upperPath.Contains(".UNITY") == false) return;
|
||||||
|
|
||||||
|
var destPath = GetDestPath(path);
|
||||||
|
AssetDatabase.DeleteAsset(destPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnAdd(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
|
||||||
|
if (upperPath.Contains("ASSETS/RAW/SCENES/") == false || upperPath.Contains(".UNITY") == false) return;
|
||||||
|
|
||||||
|
var destPath = GetDestPath(path);
|
||||||
|
AssetDatabase.DeleteAsset(destPath);
|
||||||
|
|
||||||
|
SLFileUtility.MakeFolderFromFilePath(destPath);
|
||||||
|
|
||||||
|
AssetDatabase.CopyAsset(path, destPath);
|
||||||
|
//var scene = AssetDatabase.LoadAssetAtPath<SceneAsset>(destPath);
|
||||||
|
|
||||||
|
// TODO: 추가 처리
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a74e129d4cb7fb545a1bdf52599ce887
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,180 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using Superlazy;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.U2D;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.U2D;
|
||||||
|
|
||||||
|
public interface IPostProcessorSpriteAtlas
|
||||||
|
{
|
||||||
|
void OnAddSprite(SpriteAtlasAsset atlas);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SLAssetPostprocessorSprite
|
||||||
|
{
|
||||||
|
private static readonly HashSet<string> targetPaths = new HashSet<string>();
|
||||||
|
|
||||||
|
public static void OnPreprocessTexture(TextureImporter importer)
|
||||||
|
{
|
||||||
|
importer.textureType = TextureImporterType.Sprite;
|
||||||
|
importer.spriteImportMode = SpriteImportMode.Single;
|
||||||
|
|
||||||
|
importer.sRGBTexture = true;
|
||||||
|
importer.isReadable = false;
|
||||||
|
importer.mipmapEnabled = false;
|
||||||
|
importer.streamingMipmaps = false;
|
||||||
|
importer.wrapMode = TextureWrapMode.Clamp;
|
||||||
|
importer.filterMode = FilterMode.Bilinear;
|
||||||
|
|
||||||
|
importer.textureCompression = TextureImporterCompression.Uncompressed;
|
||||||
|
importer.crunchedCompression = false;
|
||||||
|
importer.spritePixelsPerUnit = 100;
|
||||||
|
|
||||||
|
var textureSettings = new TextureImporterSettings();
|
||||||
|
importer.ReadTextureSettings(textureSettings);
|
||||||
|
textureSettings.spriteMeshType = SpriteMeshType.FullRect;
|
||||||
|
textureSettings.spriteExtrude = 2;
|
||||||
|
importer.SetTextureSettings(textureSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnRemove(string path, string movePath)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (upperPath.Contains("ASSETS/RAW/SPRITES/") == false || upperPath.Contains(".PNG") == false) return;
|
||||||
|
|
||||||
|
if (targetPaths.Contains(SLFileUtility.FolderPath(path)) == false)
|
||||||
|
{
|
||||||
|
targetPaths.Add(SLFileUtility.FolderPath(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnAdd(string path)
|
||||||
|
{
|
||||||
|
var upperPath = path.ToUpper();
|
||||||
|
if (upperPath.Contains("ASSETS/RAW/SPRITES/") == false || upperPath.Contains(".PNG") == false) return;
|
||||||
|
|
||||||
|
if (targetPaths.Contains(SLFileUtility.FolderPath(path)) == false)
|
||||||
|
{
|
||||||
|
targetPaths.Add(SLFileUtility.FolderPath(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateAtlas(string path, string destPath)
|
||||||
|
{
|
||||||
|
var oldAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(destPath);
|
||||||
|
|
||||||
|
if (oldAtlas != null)
|
||||||
|
{
|
||||||
|
AssetDatabase.DeleteAsset(destPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var di = new DirectoryInfo(path);
|
||||||
|
if (di.Exists == false) return;
|
||||||
|
|
||||||
|
var objects = new List<Object>();
|
||||||
|
foreach (var file in di.GetFiles())
|
||||||
|
{
|
||||||
|
if (file.Name.ToUpper().IsRight(".PNG") == false) continue;
|
||||||
|
var filePath = path + "/" + file.Name;
|
||||||
|
var fileName = file.Name.Substring(0, file.Name.Length - ".png".Length);
|
||||||
|
|
||||||
|
var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(filePath);
|
||||||
|
var maxSize = sprite.rect.size.x > sprite.rect.size.y ? sprite.rect.size.x : sprite.rect.size.y;
|
||||||
|
if (maxSize > 1024)
|
||||||
|
{
|
||||||
|
CreateSingleAtlas(filePath, path.Replace("/Raw/", "/Addressables/") + $"_{fileName}.spriteatlasv2");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
objects.Add(sprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objects.Count == 0) return;
|
||||||
|
|
||||||
|
SLFileUtility.MakeFolderFromFilePath(destPath);
|
||||||
|
var atlas = new SpriteAtlasAsset();
|
||||||
|
|
||||||
|
var spriteAtlasComponents = new List<IPostProcessorSpriteAtlas>();
|
||||||
|
spriteAtlasComponents.CreateInstanceList();
|
||||||
|
foreach (var component in spriteAtlasComponents)
|
||||||
|
{
|
||||||
|
component.OnAddSprite(atlas);
|
||||||
|
}
|
||||||
|
|
||||||
|
atlas.Add(objects.ToArray());
|
||||||
|
|
||||||
|
SpriteAtlasAsset.Save(atlas, destPath);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
|
||||||
|
var sai = (SpriteAtlasImporter)AssetImporter.GetAtPath(destPath);
|
||||||
|
sai.packingSettings = new SpriteAtlasPackingSettings
|
||||||
|
{
|
||||||
|
enableRotation = false,
|
||||||
|
enableTightPacking = false,
|
||||||
|
enableAlphaDilation = false,
|
||||||
|
padding = 4,
|
||||||
|
blockOffset = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
sai.textureSettings = new SpriteAtlasTextureSettings
|
||||||
|
{
|
||||||
|
filterMode = FilterMode.Bilinear,
|
||||||
|
sRGB = true,
|
||||||
|
generateMipMaps = false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateSingleAtlas(string path, string destPath)
|
||||||
|
{
|
||||||
|
var oldAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(destPath);
|
||||||
|
|
||||||
|
if (oldAtlas != null)
|
||||||
|
{
|
||||||
|
AssetDatabase.DeleteAsset(destPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
SLFileUtility.MakeFolderFromFilePath(destPath);
|
||||||
|
var atlas = new SpriteAtlasAsset();
|
||||||
|
|
||||||
|
var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
||||||
|
atlas.Add(new Object[] { sprite });
|
||||||
|
|
||||||
|
var spriteAtlasComponents = new List<IPostProcessorSpriteAtlas>();
|
||||||
|
spriteAtlasComponents.CreateInstanceList();
|
||||||
|
foreach (var component in spriteAtlasComponents)
|
||||||
|
{
|
||||||
|
component.OnAddSprite(atlas);
|
||||||
|
}
|
||||||
|
|
||||||
|
SpriteAtlasAsset.Save(atlas, destPath);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
|
||||||
|
var sai = (SpriteAtlasImporter)AssetImporter.GetAtPath(destPath);
|
||||||
|
sai.packingSettings = new SpriteAtlasPackingSettings
|
||||||
|
{
|
||||||
|
enableRotation = false,
|
||||||
|
enableTightPacking = false,
|
||||||
|
enableAlphaDilation = false,
|
||||||
|
padding = 4,
|
||||||
|
blockOffset = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
sai.textureSettings = new SpriteAtlasTextureSettings
|
||||||
|
{
|
||||||
|
filterMode = FilterMode.Bilinear,
|
||||||
|
sRGB = true,
|
||||||
|
generateMipMaps = false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BuildTarget()
|
||||||
|
{
|
||||||
|
foreach (var path in targetPaths)
|
||||||
|
{
|
||||||
|
CreateAtlas(path, path.Replace("/Raw/", "/Addressables/") + ".spriteatlasv2");
|
||||||
|
}
|
||||||
|
|
||||||
|
targetPaths.Clear();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 578d2e49b250ea0409205fc26da997bb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/_Datas/SLShared/SLUnity/Editor/SLBuild.meta
Normal file
8
Assets/_Datas/SLShared/SLUnity/Editor/SLBuild.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 61b06882e13c02a4dae1dfa10a72848a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
345
Assets/_Datas/SLShared/SLUnity/Editor/SLBuild/SLAppBuild.cs
Normal file
345
Assets/_Datas/SLShared/SLUnity/Editor/SLBuild/SLAppBuild.cs
Normal file
@ -0,0 +1,345 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Superlazy;
|
||||||
|
using Superlazy.Loader;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.AddressableAssets;
|
||||||
|
using UnityEditor.AddressableAssets.Build;
|
||||||
|
using UnityEditor.AddressableAssets.Settings;
|
||||||
|
using UnityEditor.Callbacks;
|
||||||
|
using UnityEditor.SceneManagement;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
#if UNITY_IOS
|
||||||
|
using UnityEditor.iOS.Xcode;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public class SLAppBuild
|
||||||
|
{
|
||||||
|
public static string dataAssetPath = "Addressables/Data";
|
||||||
|
private static readonly SLEntity options = SLEntity.Empty;
|
||||||
|
|
||||||
|
private enum SLAppBuildTarget
|
||||||
|
{
|
||||||
|
NONE = -1,
|
||||||
|
iOS = 0,
|
||||||
|
Android = 4,
|
||||||
|
Android_x86 = 5,
|
||||||
|
iOS_Cheat = 8,
|
||||||
|
Android_Cheat = 9
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ParseCommandLine()
|
||||||
|
{
|
||||||
|
var args = Environment.GetCommandLineArgs();
|
||||||
|
|
||||||
|
for (var i = 0; i < args.Length; ++i)
|
||||||
|
{
|
||||||
|
if (args[i].IsLeft("-"))
|
||||||
|
{
|
||||||
|
if (args[i + 1].Contains(","))
|
||||||
|
{
|
||||||
|
var splits = args[i + 1].Split(',');
|
||||||
|
|
||||||
|
for (var j = 0; j < splits.Count(); ++j)
|
||||||
|
{
|
||||||
|
options[args[i].Replace("-", "")][j.ToString()] = splits[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options[args[i].Replace("-", "")] = args[i + 1];
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BuildAndroidAPK()
|
||||||
|
{
|
||||||
|
PreBuild();
|
||||||
|
|
||||||
|
PlayerSettings.Android.bundleVersionCode = options["BuildSettings"]["BuildVersion"];
|
||||||
|
|
||||||
|
PlayerSettings.Android.keystorePass = options["BuildSettings"]["Android"]["KeystorePass"];
|
||||||
|
PlayerSettings.Android.keyaliasName = options["BuildSettings"]["Android"]["KeyaliasName"];
|
||||||
|
PlayerSettings.Android.keyaliasPass = options["BuildSettings"]["Android"]["KeyaliasPass"];
|
||||||
|
|
||||||
|
EditorUserBuildSettings.buildAppBundle = false;
|
||||||
|
var outputName = Application.productName + ".apk";
|
||||||
|
|
||||||
|
GenericBuild(outputName, BuildTargetGroup.Android, BuildTarget.Android, BuildOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BuildiOSIPA()
|
||||||
|
{
|
||||||
|
PreBuild();
|
||||||
|
|
||||||
|
var targetDir = "./build";
|
||||||
|
|
||||||
|
PlayerSettings.iOS.buildNumber = options["BuildSettings"]["BuildVersion"];
|
||||||
|
|
||||||
|
var opt = BuildOptions.None;
|
||||||
|
|
||||||
|
PlayerSettings.statusBarHidden = true;
|
||||||
|
|
||||||
|
if (Directory.Exists(targetDir))
|
||||||
|
{
|
||||||
|
Directory.Delete(targetDir, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(targetDir) == false)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(targetDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
GenericBuild(targetDir, BuildTargetGroup.iOS, BuildTarget.iOS, opt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PreBuild()
|
||||||
|
{
|
||||||
|
LoadBuildSettings();
|
||||||
|
ParseCommandLine();
|
||||||
|
|
||||||
|
UpdateDataScript();
|
||||||
|
UpdateAddressable();
|
||||||
|
|
||||||
|
UpdateLoaderID();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GenericBuild(string target_path, BuildTargetGroup buildTargetGroup, BuildTarget build_target, BuildOptions build_options)
|
||||||
|
{
|
||||||
|
var levels = GetLevelsFromBuildSettings();
|
||||||
|
EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup, build_target);
|
||||||
|
|
||||||
|
// TODO: NamedBuildTarget으로 개선
|
||||||
|
if (options["Def"])
|
||||||
|
{
|
||||||
|
// 기존 심볼들
|
||||||
|
var existingDefs = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup)
|
||||||
|
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Select(d => d.Trim())
|
||||||
|
.ToHashSet();
|
||||||
|
|
||||||
|
// 새로 추가할 심볼들
|
||||||
|
var newDefs = options["Def"].ToString()
|
||||||
|
.Split(";", StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Select(d => d.Trim());
|
||||||
|
|
||||||
|
// 병합 후 중복 제거
|
||||||
|
foreach (var def in newDefs)
|
||||||
|
existingDefs.Add(def);
|
||||||
|
|
||||||
|
// 최종 적용
|
||||||
|
var mergedDefs = string.Join(";", existingDefs);
|
||||||
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, mergedDefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
var res = BuildPipeline.BuildPlayer(levels, target_path, build_target, build_options);
|
||||||
|
|
||||||
|
if (res.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
||||||
|
{
|
||||||
|
throw new Exception("BuildPlayer failure: " + res.summary.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string[] GetLevelsFromBuildSettings()
|
||||||
|
{
|
||||||
|
var levels = new List<string>();
|
||||||
|
|
||||||
|
foreach (var scene in EditorBuildSettings.scenes)
|
||||||
|
{
|
||||||
|
levels.Add(scene.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return levels.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadBuildSettings()
|
||||||
|
{
|
||||||
|
var path = Path.Combine(Application.dataPath, "SLBuild", "BuildSettings.json");
|
||||||
|
|
||||||
|
options["BuildSettings"] = JsonLoader.LoadJson(File.ReadAllText(path))["BuildSettings"];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdateDataScript()
|
||||||
|
{
|
||||||
|
FileUtil.DeleteFileOrDirectory("Assets/Addressables/Data/");
|
||||||
|
|
||||||
|
var destDir = Path.Combine(Application.dataPath, dataAssetPath);
|
||||||
|
|
||||||
|
Directory.CreateDirectory(destDir);
|
||||||
|
|
||||||
|
var loader = SLSystemUtility.CreateInstance<SLDataLoader>("SLWindowsLoader");
|
||||||
|
var system = SLSystemUtility.CreateInstance<SLSystem>("SLSystem");
|
||||||
|
system.Init(loader, DateTime.UtcNow);
|
||||||
|
loader.Load();
|
||||||
|
|
||||||
|
foreach (var session in SLSystem.Data)
|
||||||
|
{
|
||||||
|
var fileName = session.ID + ".json";
|
||||||
|
var paths = Path.Combine(destDir, fileName).Split(Path.DirectorySeparatorChar);
|
||||||
|
var path = "";
|
||||||
|
|
||||||
|
for (var i = 0; i < paths.Length - 1; ++i)
|
||||||
|
{
|
||||||
|
path += paths[i] + Path.DirectorySeparatorChar;
|
||||||
|
if (Directory.Exists(path) == false)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var saveData = SLEntity.Empty;
|
||||||
|
saveData[session.ID] = session;
|
||||||
|
var text = JsonLoader.SaveToJson(saveData);
|
||||||
|
SLFileUtility.MakeFolderFromFilePath(Path.Combine(destDir, fileName));
|
||||||
|
File.WriteAllText(Path.Combine(destDir, fileName), text, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UpdateAddressable()
|
||||||
|
{
|
||||||
|
AssetDatabase.ImportAsset("Assets/Addressables", ImportAssetOptions.ImportRecursive);
|
||||||
|
AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
|
||||||
|
|
||||||
|
var settings
|
||||||
|
= AddressableAssetSettingsDefaultObject.Settings;
|
||||||
|
|
||||||
|
settings.activeProfileId
|
||||||
|
= settings.profileSettings.GetProfileId("Default");
|
||||||
|
var builder
|
||||||
|
= AssetDatabase.LoadAssetAtPath<ScriptableObject>("Assets/AddressableAssetsData/DataBuilders/BuildScriptPackedMode.asset") as IDataBuilder;
|
||||||
|
|
||||||
|
settings.ActivePlayerDataBuilderIndex
|
||||||
|
= settings.DataBuilders.IndexOf((ScriptableObject)builder);
|
||||||
|
|
||||||
|
AddressableAssetSettings.BuildPlayerContent(out var result);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(result.Error))
|
||||||
|
throw new Exception(result.Error);
|
||||||
|
AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdateLoaderID()
|
||||||
|
{
|
||||||
|
EditorSceneManager.OpenScene("Assets/Scenes/Game.unity");
|
||||||
|
var slunity = UnityEngine.Object.FindFirstObjectByType<SLUnity>();
|
||||||
|
if (slunity != null)
|
||||||
|
{
|
||||||
|
slunity.loaderID = "SLUnityDataLoader";
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
|
||||||
|
}
|
||||||
|
|
||||||
|
[PostProcessBuild(999)]
|
||||||
|
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
|
||||||
|
{
|
||||||
|
if (buildTarget == BuildTarget.StandaloneWindows64)
|
||||||
|
{
|
||||||
|
var folderPath = SLFileUtility.FolderPath(path);
|
||||||
|
|
||||||
|
var backupFolder = folderPath + "/" + Application.productName + "_BackUpThisFolder_ButDontShipItWithYourGame";
|
||||||
|
if (Directory.Exists(backupFolder))
|
||||||
|
{
|
||||||
|
Directory.Delete(backupFolder, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var burstDebugFolder = folderPath + "/" + Application.productName + "_BurstDebugInformation_DoNotShip";
|
||||||
|
if (Directory.Exists(burstDebugFolder))
|
||||||
|
{
|
||||||
|
Directory.Delete(burstDebugFolder, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileName = Application.productName;
|
||||||
|
if (options["FileName"])
|
||||||
|
{
|
||||||
|
fileName = options["FileName"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(folderPath + $"/../{fileName}.zip"))
|
||||||
|
{
|
||||||
|
File.Delete(folderPath + $"/../{fileName}.zip");
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
ZipFile.CreateFromDirectory(folderPath, $"./{fileName}.zip");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildTarget == BuildTarget.iOS)
|
||||||
|
{
|
||||||
|
#if UNITY_IOS
|
||||||
|
string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||||
|
|
||||||
|
UnityEditor.iOS.Xcode.PBXProject pbxProject = new UnityEditor.iOS.Xcode.PBXProject();
|
||||||
|
pbxProject.ReadFromFile(projectPath);
|
||||||
|
|
||||||
|
string target = pbxProject.GetUnityMainTargetGuid();
|
||||||
|
pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
|
||||||
|
pbxProject.SetBuildProperty(target, "DEBUG_INFORMATION_FORMAT", "dwarf");
|
||||||
|
|
||||||
|
if (options["iOSProvisionID"])
|
||||||
|
{
|
||||||
|
pbxProject.SetBuildProperty(target, "PROVISIONING_PROFILE", options["iOSProvisionID"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options["iOSProfileSpecifier"])
|
||||||
|
{
|
||||||
|
pbxProject.SetBuildProperty(target, "PROVISIONING_PROFILE_SPECIFIER", options["iOSProfileSpecifier"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options["iOSTeamID"])
|
||||||
|
{
|
||||||
|
pbxProject.SetBuildProperty(target, "DEVELOPMENT_TEAM", options["iOSTeamID"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options["iOSDistribution"])
|
||||||
|
{
|
||||||
|
pbxProject.SetBuildProperty(target, "CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Distribution");
|
||||||
|
}
|
||||||
|
|
||||||
|
pbxProject.WriteToFile(projectPath);
|
||||||
|
|
||||||
|
{
|
||||||
|
string plistPath = path + "/Info.plist";
|
||||||
|
PlistDocument plist = new PlistDocument();
|
||||||
|
plist.ReadFromString(File.ReadAllText(plistPath));
|
||||||
|
|
||||||
|
PlistElementDict rootDict = plist.root;
|
||||||
|
rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);
|
||||||
|
|
||||||
|
File.WriteAllText(plistPath, plist.WriteToString());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BuildWindows()
|
||||||
|
{
|
||||||
|
PreBuild();
|
||||||
|
|
||||||
|
var targetDir = "./build";
|
||||||
|
|
||||||
|
if (Directory.Exists(targetDir))
|
||||||
|
{
|
||||||
|
Directory.Delete(targetDir, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(targetDir) == false)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(targetDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
GenericBuild(targetDir + "/" + Application.productName + ".exe", BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64, BuildOptions.None);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 76ab71d797cc1d548b395605811ee2f4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
34
Assets/_Datas/SLShared/SLUnity/Editor/SLBuild/SLBuildMenu.cs
Normal file
34
Assets/_Datas/SLShared/SLUnity/Editor/SLBuild/SLBuildMenu.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.AddressableAssets.Settings;
|
||||||
|
|
||||||
|
namespace Assets.Scripts.Editor
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class SLBuildMenu
|
||||||
|
{
|
||||||
|
[MenuItem("SLBuild/Build Assets")]
|
||||||
|
public static void BuildAndroidAssets()
|
||||||
|
{
|
||||||
|
AssetDatabase.ImportAsset("Assets/Addressables", ImportAssetOptions.ImportRecursive);
|
||||||
|
AddressableAssetSettings.BuildPlayerContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("SLBuild/Build APK")]
|
||||||
|
public static void BuildAndroidAPK()
|
||||||
|
{
|
||||||
|
SLAppBuild.BuildAndroidAPK();
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("SLBuild/Build iOS IPA")]
|
||||||
|
public static void BuildiOSIPA()
|
||||||
|
{
|
||||||
|
SLAppBuild.BuildiOSIPA();
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("SLBuild/Build Windows")]
|
||||||
|
public static void BuildWindows()
|
||||||
|
{
|
||||||
|
SLAppBuild.BuildWindows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 70051d36fdf85b64d9059a5ca0423c78
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
206
Assets/_Datas/SLShared/SLUnity/Editor/SLFileUtility.cs
Normal file
206
Assets/_Datas/SLShared/SLUnity/Editor/SLFileUtility.cs
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public static class SLFileUtility
|
||||||
|
{
|
||||||
|
public static bool DirectoryCopy(string sourceDirName, string destDirName, bool overwrite, bool copySubDirs, bool displayProgress = false, string pattern = "*.*")
|
||||||
|
{
|
||||||
|
var sourceDir = new DirectoryInfo(sourceDirName);
|
||||||
|
|
||||||
|
if (!sourceDir.Exists)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
//throw new DirectoryNotFoundException(
|
||||||
|
// "Source directory does not exist or could not be found: "
|
||||||
|
// + sourceDirName);
|
||||||
|
}
|
||||||
|
|
||||||
|
var destDir = new DirectoryInfo(destDirName);
|
||||||
|
if (!destDir.Exists)
|
||||||
|
{
|
||||||
|
destDir = Directory.CreateDirectory(destDirName);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copySubDirs)
|
||||||
|
{
|
||||||
|
var dirs = sourceDir.GetDirectories();
|
||||||
|
for (var i = 0; i < dirs.Length; i++)
|
||||||
|
{
|
||||||
|
var subdir = dirs[i];
|
||||||
|
|
||||||
|
var temppath = Path.Combine(destDirName, subdir.Name);
|
||||||
|
if (DirectoryCopy(subdir.FullName, temppath, overwrite, copySubDirs, displayProgress, pattern) == false)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var files = sourceDir.GetFiles(pattern);
|
||||||
|
for (var i = 0; i < files.Length; i++)
|
||||||
|
{
|
||||||
|
var file = files[i];
|
||||||
|
|
||||||
|
if (displayProgress)
|
||||||
|
{
|
||||||
|
if (EditorUtility.DisplayCancelableProgressBar(
|
||||||
|
sourceDir.Name + " > " + destDir.Name,
|
||||||
|
file.Name,
|
||||||
|
i / (float)files.Length))
|
||||||
|
{
|
||||||
|
EditorUtility.ClearProgressBar();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var temppath = Path.Combine(destDirName, file.Name);
|
||||||
|
file.CopyTo(temppath, overwrite);
|
||||||
|
}
|
||||||
|
EditorUtility.ClearProgressBar();
|
||||||
|
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SearchDirectory(string sourceDirName, bool doRecursive, ref List<string> pathList)
|
||||||
|
{
|
||||||
|
var dir = new DirectoryInfo(sourceDirName);
|
||||||
|
|
||||||
|
if (!dir.Exists)
|
||||||
|
{
|
||||||
|
throw new DirectoryNotFoundException(
|
||||||
|
"Source directory does not exist or could not be found: "
|
||||||
|
+ sourceDirName);
|
||||||
|
}
|
||||||
|
|
||||||
|
var dirs = dir.GetDirectories();
|
||||||
|
|
||||||
|
var files = dir.GetFiles();
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
pathList.Add(file.FullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doRecursive)
|
||||||
|
{
|
||||||
|
foreach (var subdir in dirs)
|
||||||
|
{
|
||||||
|
pathList.Add(subdir.FullName);
|
||||||
|
SearchDirectory(subdir.FullName, doRecursive, ref pathList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FixPath(string path)
|
||||||
|
{
|
||||||
|
path = path.Replace('\\', '/');
|
||||||
|
path = path.Replace("//", "/");
|
||||||
|
while (path.Length > 0 && path[0] == '/')
|
||||||
|
{
|
||||||
|
path = path.Remove(0, 1);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FileName(string path)
|
||||||
|
{
|
||||||
|
return Path.GetFileNameWithoutExtension(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FolderPath(string path)
|
||||||
|
{
|
||||||
|
return FixPath(Path.GetDirectoryName(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FolderName(string path)
|
||||||
|
{
|
||||||
|
var dirPath = FolderPath(path);
|
||||||
|
return FixPath(dirPath.Substring(dirPath.LastIndexOf('/') + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string CombinePaths(params string[] paths)
|
||||||
|
{
|
||||||
|
var path = "";
|
||||||
|
for (var i = 0; i < paths.Length; i++)
|
||||||
|
{
|
||||||
|
path = Path.Combine(path, FixPath(paths[i]));
|
||||||
|
}
|
||||||
|
return FixPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string RelativePath(string path)
|
||||||
|
{
|
||||||
|
path = FixPath(path);
|
||||||
|
if (path.StartsWith("Assets"))
|
||||||
|
{
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
if (path.StartsWith(FixPath(Application.dataPath)))
|
||||||
|
{
|
||||||
|
return "Assets" + path.Substring(FixPath(Application.dataPath).Length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MakeFolderFromFilePath(string filePath)
|
||||||
|
{
|
||||||
|
var paths = FixPath(filePath).Split('/');
|
||||||
|
var path = "";
|
||||||
|
|
||||||
|
for (var i = 0; i < paths.Length - 1; ++i)
|
||||||
|
{
|
||||||
|
path += paths[i] + "/";
|
||||||
|
if (Directory.Exists(path) == false)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime GetLastWriteTime(string filePath)
|
||||||
|
{
|
||||||
|
var fileWriteTime = File.GetLastWriteTime(filePath);
|
||||||
|
var metaWriteTime = File.GetLastWriteTime(filePath + ".meta");
|
||||||
|
|
||||||
|
var result = DateTime.Compare(fileWriteTime, metaWriteTime);
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
// file이 meta보다 빠름.
|
||||||
|
return metaWriteTime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return fileWriteTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AttrToNormal(string targetDir)
|
||||||
|
{
|
||||||
|
File.SetAttributes(targetDir, FileAttributes.Normal);
|
||||||
|
|
||||||
|
var files = Directory.GetFiles(targetDir);
|
||||||
|
var dirs = Directory.GetDirectories(targetDir);
|
||||||
|
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.SetAttributes(file, FileAttributes.Normal);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var dir in dirs)
|
||||||
|
{
|
||||||
|
AttrToNormal(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/_Datas/SLShared/SLUnity/Editor/SLFileUtility.cs.meta
Normal file
11
Assets/_Datas/SLShared/SLUnity/Editor/SLFileUtility.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b67bd58dfce671f41947e39a6f5f70bf
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Superlazy
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(SLResourceObject))]
|
||||||
|
public class SLResourceObjectEditor : Editor
|
||||||
|
{
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
base.OnInspectorGUI();
|
||||||
|
|
||||||
|
var resourceObject = (SLResourceObject)target;
|
||||||
|
if (GUILayout.Button("Build Data"))
|
||||||
|
{
|
||||||
|
resourceObject.Init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 326bfe8b78262674cab28d020b02f541
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user