public CustomSprite(SpriteManager.Group group, string id, Atlas.Sprite sprite) { Group = group; Id = id; Sprite = sprite; TechType = TechType.None; }
public CustomSprite(TechType type, Atlas.Sprite sprite) { Group = SpriteManager.Group.None; TechType = type; Id = type.AsString(); Sprite = sprite; }
/// <summary> /// Creates a new ModSprite to be used with a specific TechType. /// Created with an Atlas Sprite. /// </summary> /// <param name="type">The techtype paired to this sprite.</param> /// <param name="sprite">The sprite to be added.</param> public ModSprite(TechType type, UnityEngine.Sprite sprite) { TechType = type; Id = type.AsString(); Sprite = sprite; Group = SpriteManager.Group.Item; }
/// <summary> /// Creates a new ModSprite to be used with a specific group and internal ID. /// Created with an Atlas Sprite. /// </summary> /// <param name="group">The sprite group.</param> /// <param name="type">The techtype paired to this sprite.</param> /// <param name="sprite">The sprite to be added.</param> public ModSprite(SpriteManager.Group group, TechType type, Atlas.Sprite sprite) { Group = group; Id = type.AsString(); Sprite = sprite; TechType = type; }
private static bool Prefix(ref Atlas.Sprite __result, SpriteManager.Group group, string name) { if (group == SpriteManager.Group.Pings) { if (CustomPings.PingExists(name)) { __result = CustomPings.GetSprite(name); return(false); } } return(true); }
private static bool Prefix(SpriteManager.Group group, string name, ref Atlas.Sprite __result) { if (group == SpriteManager.Group.Pings) { if (CustomBeaconManager.DoesCustomPingExist(name)) { __result = CustomBeaconManager.GetSprite(name); return(false); } } return(true); }
private static bool Prefix(ref Atlas.Sprite __result, SpriteManager.Group group, string name) { Dictionary <string, Atlas.Sprite> sprites; if (spriteDatabase.TryGetValue(group, out sprites)) { if (sprites.TryGetValue(name, out __result)) { return(false); } } return(true); }
private static Dictionary <string, Sprite> GetSpriteGroup(SpriteManager.Group groupKey) { if (groupsInfo != null) { return(Groups[groupKey]); } else if (atlasesInfo != null) { string groupName = SpriteManager.mapping[groupKey]; return(Atlases[groupName]); } Logger.Error("SpritePatcher was unable to find a sprite dictionary"); return(null); }
internal static void Add(SpriteManager.Group group, string name, Atlas.Sprite sprite) { if (group == SpriteManager.Group.None) { group = SpriteManager.Group.Item; } // There are no calls for sprites in the None Group. // All sprite calls for almost anything we don't manually group is in the Item group. if (!ModSprites.ContainsKey(group)) { ModSprites.Add(group, new Dictionary <string, Atlas.Sprite>(StringComparer.InvariantCultureIgnoreCase)); } ModSprites[group][name] = sprite; }
public static void Set(SpriteManager.Group group, string name, Atlas.Sprite sprite) { if (!spriteDatabase.ContainsKey(group)) { throw new ArgumentException("group is invalid"); } if (string.IsNullOrEmpty(name)) { throw new ArgumentException("name is null or empty"); } if (group == SpriteManager.Group.Background) { throw new NotSupportedException("can not edit backgrounds"); } spriteDatabase[group][name] = sprite ?? throw new ArgumentNullException("sprite is null"); }
internal static void PatchCheck(SpriteManager.Group group, string name) { if (string.IsNullOrEmpty(name) || !ModSprite.ModSprites.TryGetValue(group, out var groupDict) || !groupDict.TryGetValue(name, out _)) { return; } #if BELOWZERO if (!SpriteManager.hasInitialized) { return; } #endif Dictionary <string, Sprite> atlas = GetSpriteAtlas(group); if (atlas != null && !atlas.TryGetValue(name, out _)) { PatchSprites(); } }
internal static void Add(SpriteManager.Group group, string name, Atlas.Sprite sprite) { if (group == SpriteManager.Group.None) { group = SpriteManager.Group.Item; } // There are no calls for sprites in the None Group. // All sprite calls for almost anything we don't manually group is in the Item group. if (!ModSprites.ContainsKey(group)) { ModSprites.Add(group, new Dictionary <string, Atlas.Sprite>(StringComparer.InvariantCultureIgnoreCase)); } if (ModSprites[group].ContainsKey(name)) { Logger.Debug($"ModSprite already registered for {group}/{name}. Old sprite will be overwritten."); } ModSprites[group][name] = sprite; }
private static Dictionary <string, Sprite> GetSpriteAtlas(SpriteManager.Group groupKey) { if (!SpriteManager.mapping.TryGetValue(groupKey, out string atlasName)) { Logger.Error($"SpritePatcher was unable to find a sprite mapping for {nameof(SpriteManager.Group)}.{groupKey}"); return(null); } #if SUBNAUTICA var atlas = Atlas.GetAtlas(atlasName); if (atlas?.nameToSprite != null) { return(atlas.nameToSprite); } #elif BELOWZERO if (SpriteManager.atlases.TryGetValue(atlasName, out var spriteGroup)) { return(spriteGroup); } #endif Logger.Error($"SpritePatcher was unable to find a sprite atlas for {nameof(SpriteManager.Group)}.{groupKey}"); return(null); }
/// <summary> /// Creates a new ModSprite to be used with a specific group and internal ID. /// Created with a UnityEngine Sprite. /// </summary> /// <param name="group">The sprite group this sprite will be added to.</param> /// <param name="id">The sprite internal identifier.</param> /// <param name="sprite">The sprite to be added.</param> public ModSprite(SpriteManager.Group group, string id, UnityEngine.Sprite sprite) : this(group, id, new Atlas.Sprite(sprite, false)) { }
/// <summary> /// Registers a new sprite to the game. /// </summary> /// <param name="group">The sprite group.</param> /// <param name="id">The sprite internal identifier.</param> /// <param name="filePathToImage">The file path to image.</param> /// <seealso cref="ImageUtils.LoadSpriteFromFile(string, TextureFormat)" /> public static void RegisterSprite(SpriteManager.Group group, string id, string filePathToImage) { Main.RegisterSprite(group, id, filePathToImage); }
/// <summary> /// Registers a new sprite to the game. /// </summary> /// <param name="group">The sprite group this sprite will be added to.</param> /// <param name="id">The sprite internal identifier.</param> /// <param name="sprite">The sprite to be added.</param> public static void RegisterSprite(SpriteManager.Group group, string id, Sprite sprite) { Main.RegisterSprite(group, id, sprite); }
/// <summary> /// Registers a new sprite to the game. /// </summary> /// <param name="group">The sprite group.</param> /// <param name="id">The sprite internal identifier.</param> /// <param name="filePathToImage">The file path to image.</param> /// <param name="format"><para>The texture format. By default, this uses <see cref="TextureFormat.BC7" />.</para> /// <para>https://docs.unity3d.com/ScriptReference/TextureFormat.BC7.html</para> /// <para>Don't change this unless you really know what you're doing.</para></param> /// <seealso cref="ImageUtils.LoadSpriteFromFile(string, TextureFormat)" /> void ISpriteHandler.RegisterSprite(SpriteManager.Group group, string id, string filePathToImage, TextureFormat format) { Atlas.Sprite sprite = ImageUtils.LoadSpriteFromFile(filePathToImage, format); Main.RegisterSprite(group, id, sprite); }
/// <summary> /// Registers a new sprite to the game. /// </summary> /// <param name="group">The sprite group this sprite will be added to.</param> /// <param name="id">The sprite internal identifier.</param> /// <param name="sprite">The sprite to be added.</param> void ISpriteHandler.RegisterSprite(SpriteManager.Group group, string id, Sprite sprite) { ModSprite.Add(group, id, new Atlas.Sprite(sprite)); }
/// <summary> /// Registers a new sprite to the game. /// </summary> /// <param name="group">The sprite group.</param> /// <param name="id">The sprite internal identifier.</param> /// <param name="filePathToImage">The file path to image.</param> /// <param name="format"><para>The texture format. By default, this uses <see cref="TextureFormat.BC7" />.</para> /// <para>https://docs.unity3d.com/ScriptReference/TextureFormat.BC7.html</para> /// <para>Don't change this unless you really know what you're doing.</para></param> /// <seealso cref="ImageUtils.LoadSpriteFromFile(string, TextureFormat)" /> public static void RegisterSprite(SpriteManager.Group group, string id, string filePathToImage, TextureFormat format) { Main.RegisterSprite(group, id, filePathToImage, format); }
internal static void AddSprite(SpriteManager.Group group, string spriteName, Sprite sprite) { var spriteGroup = GetSpriteGroup(group); spriteGroup.Add(spriteName, sprite); }
public CustomSprite(SpriteManager.Group group, string id, Sprite sprite) : this(group, id, new Atlas.Sprite(sprite, false)) { }