// 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(); }
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.Load <Collection>(Path.Combine(base_dir, mapping.Collection)); }
public Animation GetAnimation(ModLoader.ModInfo info) { if (_Animation != null) { return(_Animation); } return(_Animation = new Animation(info, ReadText(), System.IO.Path.GetDirectoryName(ResourcePath))); }
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); }
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(); }
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}"); }
public Animation(ModLoader.ModInfo info, string text, string base_dir = null) : this(info, _Deserializer.Deserialize <YAML.Animation>(text), base_dir) { }