コード例 #1
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();
                }
コード例 #2
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);
        }
コード例 #3
0
ファイル: AnimatorGenerator.cs プロジェクト: Seethiur/ETGMod
            public AnimatorGenerator(ModLoader.ModInfo mod_info, string base_dir, YAML.Animation mapping)
            {
                ModInfo = mod_info;
                Mapping = mapping;

                Collection = mod_info.Load <Collection>(Path.Combine(base_dir, mapping.Collection));
            }
コード例 #4
0
 public Animation GetAnimation(ModLoader.ModInfo info)
 {
     if (_Animation != null)
     {
         return(_Animation);
     }
     return(_Animation = new Animation(info, ReadText(), System.IO.Path.GetDirectoryName(ResourcePath)));
 }
コード例 #5
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);
        }
コード例 #6
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($"ETGMod Collection '{deserialized.Name}'");

                _Generator     = new CollectionGenerator(info, base_dir, _DeserializedYAMLDoc, GameObject);
                CollectionData = _Generator.ConstructCollection();
            }
コード例 #7
0
ファイル: LoadedResource.cs プロジェクト: Seethiur/ETGMod
        public T SpecialCast <T>(ModLoader.ModInfo info)
        {
            object result = null;
            var    type   = typeof(T);

            if (_SpecialCastCache.TryGetValue(type, out result))
            {
                return((T)result);
            }

            result = SpecialCastCallback.Invoke(info, type, this);
            if (result != null)
            {
                _SpecialCastCache[type] = result;
                return((T)result);
            }

            throw new InvalidOperationException($"Unsupported special type: {typeof(T).FullName}");
        }
コード例 #8
0
 public Animation(ModLoader.ModInfo info, string text, string base_dir = null)
     : this(info, _Deserializer.Deserialize <YAML.Animation>(text), base_dir)
 {
 }