Example #1
0
        private static object _RunLuaHook(ModLoader.ModInfo mod, LuaState lua, long method_token, object target, object[] args, out bool returned)
        {
            returned = false;

            if (mod.Hooks != null)
            {
                _Logger.Debug($"Running hook '{method_token}' in mod {mod.Name}");
                var obj = mod.Hooks.TryRun(lua, method_token, target, args, out returned);
                if (returned)
                {
                    return(obj);
                }
            }
            if (mod.HasAnyEmbeddedMods)
            {
                for (int i = 0; i < mod.EmbeddedMods.Count; i++)
                {
                    var obj = _RunLuaHook(mod.EmbeddedMods[i], lua, method_token, target, args, out returned);
                    if (returned)
                    {
                        return(obj);
                    }
                }
            }

            return(null);
        }
            public AnimatorGenerator(ModLoader.ModInfo mod_info, string base_dir, YAML.Animation mapping)
            {
                ModInfo = mod_info;
                Mapping = mapping;

                Collection = mod_info.LoadCollection(Path.Combine(base_dir, mapping.Collection));
            }
Example #3
0
                // Mod mode - use ModResources facilities to load textures
                public CollectionGenerator(ModLoader.ModInfo mod_info, string base_dir, YAML.Collection mapping, GameObject gameobj)
                {
                    TargetGameObject = gameobj;
                    Mapping          = mapping;

                    // initialize texture array and spritesheet mappings
                    Logger.Debug("Generating spritesheet->id->texture mapping");
                    var tex_list = new List <Texture2D>();

                    // first the general spritesheet, if it exists
                    if (mapping.Spritesheet != null)
                    {
                        _SpritesheetID(mapping.Spritesheet);
                        tex_list.Add(mod_info.LoadTexture(Path.Combine(base_dir, mapping.Spritesheet)));
                        Logger.Debug($"New spritesheet: '{mapping.Spritesheet}', ID: {_LastSpritesheetID - 1}");
                    }

                    // ...then the clip spritesheets
                    foreach (var def in mapping.Definitions)
                    {
                        if (def.Value.Spritesheet != null)
                        {
                            _SpritesheetID(def.Value.Spritesheet);
                            tex_list.Add(mod_info.LoadTexture(Path.Combine(base_dir, def.Value.Spritesheet)));
                            Logger.Debug($"New spritesheet: '{def.Value.Spritesheet}', ID: {_LastSpritesheetID - 1}");
                        }
                    }

                    // and then turn the list into an array
                    Textures = tex_list.ToArray();
                }
 public Animation GetAnimation(ModLoader.ModInfo info)
 {
     if (_Animation != null)
     {
         return(_Animation);
     }
     return(_Animation = new Animation(info, ReadText(), System.IO.Path.GetDirectoryName(ResourcePath)));
 }
Example #5
0
            public Collection(ModLoader.ModInfo info, YAML.Collection deserialized, string base_dir = null)
            {
                _DeserializedYAMLDoc = deserialized;
                if (base_dir == null)
                {
                    base_dir = info.Resources.BaseDir;
                }

                GameObject = new GameObject($"ModTheGungeon Collection '{deserialized.Name}'");

                _Generator     = new CollectionGenerator(info, base_dir, _DeserializedYAMLDoc, GameObject);
                CollectionData = _Generator.ConstructCollection();
            }
Example #6
0
        public Animation(ModLoader.ModInfo info, YAML.Animation deserialized, string base_dir = null)
        {
            _ModInfo             = info;
            _DeserializedYAMLDoc = deserialized;
            if (base_dir == null)
            {
                base_dir = info.Resources.BaseDir;
            }

            _Generator  = new AnimatorGenerator(_ModInfo, base_dir, _DeserializedYAMLDoc);
            _Collection = _Generator.Collection;
            _Clips      = _Generator.ConstructClips(_Collection.CollectionData);
        }
Example #7
0
 public Collection(ModLoader.ModInfo info, string text, string base_dir = null)
     : this(info, _Deserializer.Deserialize <YAML.Collection>(text), base_dir)
 {
 }