Pārlūkot izejas kodu

update editor scripts

mbunch_kascope 1 gadu atpakaļ
vecāks
revīzija
5e74008c17

+ 11 - 5
Assets/Editor/Fixing Scripts/GetHighestCardIndex.cs

@@ -7,12 +7,12 @@ using UnityEngine;
 using UnityEngine.SceneManagement;
 using DCGO.CardEntities;
 
-namespace DCGO.Tools.Repair 
+namespace DCGO.Tools 
 {
     public class GetHighestCardIndex : MonoBehaviour
     {
-        [MenuItem("Window/DCGO/Repair/Get Highest Card Index")]
-        static void FixEntityClassNames()
+        [MenuItem("Window/DCGO/Get Index/Get Highest Card Index")]
+        static void GetIndex()
         {
             List<CEntity_Base> Entities = GetAsset.LoadAll<CEntity_Base>("Assets/CardBaseEntity/");
             int cardIndex = 0;
@@ -23,6 +23,9 @@ namespace DCGO.Tools.Repair
                 if (card.CardID.Contains("P-"))
                     continue;
 
+                if (cardIndex == card.CardIndex)
+                    Debug.LogWarning($"DUPLICATE INDEX FOUND: {card.CardSpriteName} - {cardIndex}");
+
                 if (card.CardIndex > cardIndex)
                 {
                     cardIndex = card.CardIndex;
@@ -36,8 +39,8 @@ namespace DCGO.Tools.Repair
 
     public class GetHighestPromoCardIndex : MonoBehaviour
     {
-        [MenuItem("Window/DCGO/Repair/Get Highest Promo Index")]
-        static void FixEntityClassNames()
+        [MenuItem("Window/DCGO/Get Index/Get Highest Promo Index")]
+        static void GetIndex()
         {
             List<CEntity_Base> Entities = GetAsset.LoadAll<CEntity_Base>("Assets/CardBaseEntity/");
             int cardIndex = 0;
@@ -48,6 +51,9 @@ namespace DCGO.Tools.Repair
                 if (!card.CardID.Contains("P-"))
                     continue;
 
+                if (cardIndex == card.CardIndex)
+                    Debug.LogWarning($"DUPLICATE INDEX FOUND: {card.CardSpriteName} - {cardIndex}");
+
                 if (card.CardIndex > cardIndex)
                 {
                     cardIndex = card.CardIndex;

+ 100 - 0
Assets/Editor/Fixing Scripts/GetLowestCardIndex.cs

@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEditor.SceneManagement;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.SceneManagement;
+using DCGO.CardEntities;
+using static UnityEditor.ShaderGraph.Internal.KeywordDependentCollection;
+
+namespace DCGO.Tools
+{
+    public class GetLowestCardIndex : MonoBehaviour
+    {
+        [MenuItem("Window/DCGO/Get Index/Get Lowest Card Index")]
+        static void GetIndex()
+        {
+
+            string path = "";
+            int minValue = 0;
+
+            if (Selection.assetGUIDs.Length != 0)
+                path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
+
+            if (path != "")
+            {
+                List<CEntity_Base> List = GetAsset.LoadAll<CEntity_Base>(path)
+                .OrderBy(x => x.CardIndex).ToList();
+
+                minValue = List[0].CardIndex;
+            }
+
+            List<CEntity_Base> Entities = GetAsset.LoadAll<CEntity_Base>("Assets/CardBaseEntity/")
+            .Filter(entity => !entity.CardID.Contains("P-"))
+            .Filter(entity => entity.CardIndex >= minValue);
+            int cardIndex = 0;
+            string name = "";
+
+            foreach (CEntity_Base card in Entities)
+            {
+                if (card.CardID.Contains("P-"))
+                    continue;
+
+                if (cardIndex == card.CardIndex)
+                    Debug.LogWarning($"DUPLICATE INDEX FOUND: {card.CardSpriteName} - {cardIndex}");
+
+                if (card.CardIndex < cardIndex || cardIndex == 0)
+                {
+                    cardIndex = card.CardIndex;
+                    name = card.CardSpriteName;
+                }
+            }
+
+            Debug.Log($"Lowest Card Index: {cardIndex} - {name}");
+        }
+    }
+
+    public class GetLowestPromoCardIndex : MonoBehaviour
+    {
+        [MenuItem("Window/DCGO/Get Index/Get Lowest Promo Index")]
+        static void GetIndex()
+        {
+            string path = "";
+            int minValue = 0;
+
+            if (Selection.assetGUIDs.Length != 0)
+                path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
+
+            if(path != "")
+            {
+                CEntity_Base entity = GetAsset.Load<CEntity_Base>(path);
+
+                minValue = entity.CardIndex;
+            }
+            
+
+            List<CEntity_Base> Entities = GetAsset.LoadAll<CEntity_Base>("Assets/CardBaseEntity/")
+            .Filter(entity => entity.CardID.Contains("P-"))
+            .Filter(entity => entity.CardIndex > minValue);
+
+            int cardIndex = 0;
+            string name = "";
+
+            Debug.Log($"CARD COUNT: {Entities.Count}");
+            foreach (CEntity_Base card in Entities)
+            {
+                if (cardIndex == card.CardIndex)
+                    Debug.LogWarning($"DUPLICATE INDEX FOUND: {card.CardSpriteName} - {cardIndex}");
+
+                if ((card.CardIndex < cardIndex || cardIndex == 0))
+                {
+                    cardIndex = card.CardIndex;
+                    name = card.CardSpriteName;
+                }
+            }
+
+            Debug.Log($"Lowest Card Index: {cardIndex} - {name}");
+        }
+    }
+}

+ 11 - 0
Assets/Editor/Fixing Scripts/GetLowestCardIndex.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5ba00a03ae900094d9b18e9b248f90e6
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 16 - 4
Assets/Editor/JSONLoader_CardEntity.cs

@@ -155,7 +155,7 @@ namespace DCGO.CardEntities
                 SaveScriptableObject(cardEntity);
             }
             else
-                Debug.Log($"DATA {cardEntity.name}: {cardEntity.CardSpriteName}, {cardEntity.CardEffectClassName}");
+                Debug.Log($"DATA {cardEntity.name}: {cardEntity.CardSpriteName}, {cardEntity.CardEffectClassName}, {GetCardIndex(cardEntity)}");
         }
 
         void CreateAA(CardData data)
@@ -216,19 +216,31 @@ namespace DCGO.CardEntities
         {
             int index = _loadJSON.setCardIndex;
 
-            if (entity.SetID.Equals("P"))
+            /*f (entity.SetID.Equals("P"))
             {
                 index = _loadJSON.promoCardIndex;
                 _loadJSON.promoCardIndex++;
             }
-            else
+            else*/
+            _loadJSON.setCardIndex++;
+
+            while (CheckIndexIsUsed())
+            {
                 _loadJSON.setCardIndex++;
+            }
 
-            EditorUtility.SetDirty(_loadJSON);
+            if (!debugMode)
+                EditorUtility.SetDirty(_loadJSON);
 
             return index;
         }
 
+        bool CheckIndexIsUsed()
+        {
+            return GetAsset.LoadAll<CEntity_Base>("Assets/CardBaseEntity/")
+                .Any(x => x.CardIndex == _loadJSON.setCardIndex);
+        }
+
         //Parse ScriptableObject Name
         string FixCharactersInName(string str)
         {