コード例 #1
0
        public static string AddCustomAmmoType(string name, string ammoTypeSpritePath, string ammoBackgroundSpritePath)
        {
            Texture2D fgTexture = ResourceExtractor.GetTextureFromResource(ammoTypeSpritePath + ".png");
            Texture2D bgTexture = ResourceExtractor.GetTextureFromResource(ammoBackgroundSpritePath + ".png");

            GameObject fgSpriteObject = new GameObject("sprite fg");

            fgSpriteObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(fgSpriteObject);
            UnityEngine.Object.DontDestroyOnLoad(fgSpriteObject);
            GameObject bgSpriteObject = new GameObject("sprite bg");

            bgSpriteObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(bgSpriteObject);
            UnityEngine.Object.DontDestroyOnLoad(bgSpriteObject);

            dfTiledSprite  fgSprite   = fgSpriteObject.SetupDfSpriteFromTexture <dfTiledSprite>(fgTexture, ShaderCache.Acquire("Daikon Forge/Default UI Shader"));
            dfTiledSprite  bgSprite   = bgSpriteObject.SetupDfSpriteFromTexture <dfTiledSprite>(bgTexture, ShaderCache.Acquire("Daikon Forge/Default UI Shader"));
            GameUIAmmoType uiammotype = new GameUIAmmoType
            {
                ammoBarBG      = bgSprite,
                ammoBarFG      = fgSprite,
                ammoType       = GameUIAmmoType.AmmoType.CUSTOM,
                customAmmoType = name
            };

            CustomClipAmmoTypeToolbox.addedAmmoTypes.Add(uiammotype);
            foreach (GameUIAmmoController uiammocontroller in GameUIRoot.Instance.ammoControllers)
            {
                Add(ref uiammocontroller.ammoTypes, uiammotype);
            }
            return(name);
        }
コード例 #2
0
        // Token: 0x060000C1 RID: 193 RVA: 0x000089D8 File Offset: 0x00006BD8
        public static tk2dSpriteAnimationClip BuildAnimation(AIAnimator aiAnimator, string name, string spriteDirectory, int fps)
        {
            tk2dSpriteCollectionData tk2dSpriteCollectionData = aiAnimator.GetComponent <tk2dSpriteCollectionData>();
            bool flag = !tk2dSpriteCollectionData;

            if (flag)
            {
                tk2dSpriteCollectionData = SpriteBuilder.ConstructCollection(aiAnimator.gameObject, aiAnimator.name + "_collection");
            }
            string[]   resourceNames = ResourceExtractor.GetResourceNames();
            List <int> list          = new List <int>();

            for (int i = 0; i < resourceNames.Length; i++)
            {
                bool flag2 = resourceNames[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase);
                if (flag2)
                {
                    list.Add(SpriteBuilder.AddSpriteToCollection(resourceNames[i], tk2dSpriteCollectionData));
                }
            }
            tk2dSpriteAnimationClip tk2dSpriteAnimationClip = SpriteBuilder.AddAnimation(aiAnimator.spriteAnimator, tk2dSpriteCollectionData, list, name, tk2dSpriteAnimationClip.WrapMode.Loop);

            tk2dSpriteAnimationClip.fps = (float)fps;
            return(tk2dSpriteAnimationClip);
        }
コード例 #3
0
 public static void SetupEntry(this AIActor enemy, string shortDesc, string longDesc, string portrait, string AmmonomiconSprite, string EnemyName)
 {
     SpriteBuilder.AddSpriteToCollection(AmmonomiconSprite, ammonomiconCollection);
     if (enemy.GetComponent <EncounterTrackable>() != null)
     {
         UnityEngine.Object.Destroy(enemy.GetComponent <EncounterTrackable>());
     }
     enemy.encounterTrackable               = enemy.gameObject.AddComponent <EncounterTrackable>();
     enemy.encounterTrackable.journalData   = new JournalEntry();
     enemy.encounterTrackable.EncounterGuid = enemy.EnemyGuid;
     enemy.encounterTrackable.prerequisites = new DungeonPrerequisite[0];
     enemy.encounterTrackable.journalData.SuppressKnownState    = false;
     enemy.encounterTrackable.journalData.IsEnemy               = true;
     enemy.encounterTrackable.journalData.SuppressInAmmonomicon = false;
     enemy.encounterTrackable.journalData.AmmonomiconSprite     = AmmonomiconSprite;
     enemy.encounterTrackable.journalData.enemyPortraitSprite   = ResourceExtractor.GetTextureFromResource(portrait + ".png");
     enemy.encounterTrackable.ProxyEncounterGuid = "";
     Strings.Enemies.Set("#" + EnemyName.ToUpper(), EnemyName);
     Strings.Enemies.Set("#" + shortDesc.ToUpper(), shortDesc);
     Strings.Enemies.Set("#" + longDesc.ToUpper(), longDesc);
     enemy.encounterTrackable.journalData.PrimaryDisplayName           = "#" + EnemyName.ToUpper();
     enemy.encounterTrackable.journalData.NotificationPanelDescription = "#" + shortDesc.ToUpper();
     enemy.encounterTrackable.journalData.AmmonomiconFullEntry         = "#" + longDesc.ToUpper();
     enemy.encounterTrackable.journalData.SuppressKnownState           = false;
 }
コード例 #4
0
        public static tk2dSpriteAnimationClip BuildAnimation(AIAnimator aiAnimator, string name, string spriteDirectory, int fps, tk2dSpriteAnimationClip.WrapMode wrapMode = tk2dSpriteAnimationClip.WrapMode.Loop)
        {
            tk2dSpriteCollectionData collection = aiAnimator.GetComponent <tk2dSpriteCollectionData>();

            if (!collection)
            {
                collection = SpriteBuilder.ConstructCollection(aiAnimator.gameObject, $"{aiAnimator.name}_collection");
            }

            string[]   resources = ResourceExtractor.GetResourceNames();
            List <int> indices   = new List <int>();

            for (int i = 0; i < resources.Length; i++)
            {
                if (resources[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase))
                {
                    indices.Add(SpriteBuilder.AddSpriteToCollection(resources[i], collection));
                }
            }
            tk2dSpriteAnimationClip clip = SpriteBuilder.AddAnimation(aiAnimator.spriteAnimator, collection, indices, name, tk2dSpriteAnimationClip.WrapMode.Loop);

            clip.fps      = fps;
            clip.wrapMode = wrapMode;
            return(clip);
        }
コード例 #5
0
        public static List <string> BuildStringListFromEmbeddedResource(string filePath)
        {
            List <string> list = new List <string>();

            if (string.IsNullOrEmpty(filePath))
            {
                return(list);
            }
            filePath = filePath.Replace("/", ".");
            filePath = filePath.Replace("\\", ".");
            string text = ResourceExtractor.BytesToString(ResourceExtractor.ExtractEmbeddedResource(string.Format("{0}.", ResourceExtractor.nameSpace) + filePath));

            if (string.IsNullOrEmpty(text))
            {
                return(list);
            }
            string[] array = text.Split(new char[]
            {
                '\n'
            });
            if (array == null | array.Length == 0)
            {
                return(list);
            }
            foreach (string item in array)
            {
                list.Add(item);
            }
            return(list);
        }
コード例 #6
0
        // Token: 0x06000004 RID: 4 RVA: 0x00002190 File Offset: 0x00000390
        public static int AddSpriteToCollection(string resourcePath, tk2dSpriteCollectionData collection)
        {
            string str = (!resourcePath.EndsWith(".png")) ? ".png" : "";

            resourcePath += str;
            Texture2D            textureFromResource  = ResourceExtractor.GetTextureFromResource(resourcePath);
            tk2dSpriteDefinition tk2dSpriteDefinition = SpriteBuilder.ConstructDefinition(textureFromResource);

            tk2dSpriteDefinition.name = textureFromResource.name;
            return(SpriteBuilder.AddSpriteToCollection(tk2dSpriteDefinition, collection));
        }
コード例 #7
0
        /// <summary>
        /// Adds a sprite (from a resource) to a collection
        /// </summary>
        /// <returns>The spriteID of the defintion in the collection</returns>
        public static int AddSpriteToCollection(string resourcePath, tk2dSpriteCollectionData collection)
        {
            string extension = !resourcePath.EndsWith(".png") ? ".png" : "";

            resourcePath += extension;
            var texture = ResourceExtractor.GetTextureFromResource(resourcePath); //Get Texture

            var definition = ConstructDefinition(texture);                        //Generate definition

            definition.name = texture.name;                                       //naming the definition is actually extremely important
            return(AddSpriteToCollection(definition, collection));
        }
コード例 #8
0
        /// <summary>
        /// Returns an object with a tk2dSprite component with the
        /// texture of a file in the sprites folder
        /// </summary>
        public static GameObject SpriteFromFile(string spriteName, GameObject obj = null, bool copyFromExisting = true)
        {
            string filename = spriteName.Replace(".png", "");

            var texture = ResourceExtractor.GetTextureFromFile(filename);

            if (texture == null)
            {
                return(null);
            }

            return(SpriteFromTexture(texture, spriteName, obj, copyFromExisting));
        }
コード例 #9
0
        /// <summary>
        /// Returns an object with a tk2dSprite component with the
        /// texture of a file in the sprites folder
        /// </summary>
        public static GameObject SpriteFromFile(string spriteName)
        {
            string filename = spriteName.Replace(".png", "");

            var texture = ResourceExtractor.GetTextureFromFile(filename);

            if (texture == null)
            {
                return(null);
            }

            return(SpriteFromTexture(texture, spriteName));
        }
コード例 #10
0
 /// <summary>
 /// Sets the base assembly of the ResourceExtractor, so
 /// resources can be accessed
 /// </summary>
 public static void Init()
 {
     try
     {
         MethodBase method        = new StackFrame(1, false).GetMethod();
         var        declaringType = method.DeclaringType;
         ResourceExtractor.SetAssembly(declaringType);
     }
     catch (Exception e)
     {
         ETGModConsole.Log(e.Message);
         ETGModConsole.Log(e.StackTrace);
     }
 }
コード例 #11
0
        /// <summary>
        /// Returns an object with a tk2dSprite component with the
        /// texture of an embedded resource
        /// </summary>
        public static GameObject SpriteFromResource(string spriteName, GameObject obj = null, bool copyFromExisting = true)
        {
            string extension    = !spriteName.EndsWith(".png") ? ".png" : "";
            string resourcePath = spriteName + extension;

            var texture = ResourceExtractor.GetTextureFromResource(resourcePath);

            if (texture == null)
            {
                return(null);
            }

            return(SpriteFromTexture(texture, resourcePath, obj, copyFromExisting));
        }
コード例 #12
0
 public static void Init()
 {
     FakePrefabHooks.Init();
     try
     {
         MethodBase method        = new StackFrame(1, false).GetMethod();
         Type       declaringType = method.DeclaringType;
         ResourceExtractor.SetAssembly(declaringType);
     }
     catch (Exception ex)
     {
         ETGModConsole.Log(ex.Message, false);
         ETGModConsole.Log(ex.StackTrace, false);
     }
 }
コード例 #13
0
        // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
        public static GameObject SpriteFromFile(string spriteName, GameObject obj = null, bool copyFromExisting = true)
        {
            string     fileName        = spriteName.Replace(".png", "");
            Texture2D  textureFromFile = ResourceExtractor.GetTextureFromFile(fileName, ".png");
            bool       flag            = textureFromFile == null;
            GameObject result;

            if (flag)
            {
                result = null;
            }
            else
            {
                result = SpriteBuilder.SpriteFromTexture(textureFromFile, spriteName, obj, copyFromExisting);
            }
            return(result);
        }
コード例 #14
0
        // Token: 0x06000002 RID: 2 RVA: 0x00002098 File Offset: 0x00000298
        public static GameObject SpriteFromResource(string spriteName, GameObject obj = null, bool copyFromExisting = true)
        {
            string     str  = (!spriteName.EndsWith(".png")) ? ".png" : "";
            string     text = spriteName + str;
            Texture2D  textureFromResource = ResourceExtractor.GetTextureFromResource(text);
            bool       flag = textureFromResource == null;
            GameObject result;

            if (flag)
            {
                result = null;
            }
            else
            {
                result = SpriteBuilder.SpriteFromTexture(textureFromResource, text, obj, copyFromExisting);
            }
            return(result);
        }