public override bool Autoload(ref string name, ref string texture) { var path = AssetDirectory.Buffs + name; texture = ModContent.TextureExists(path) ? path : AssetDirectory.Debug; return(true); }
public override bool OrchidPreDraw(SpriteBatch spriteBatch, Color lightColor) { if (!(this.CatalystItem.modItem is OrchidModShamanItem shamanItem)) { return(false); } if (!ModContent.TextureExists(shamanItem.CatalystTexture)) { return(false); } var player = Main.player[projectile.owner]; var color = Lighting.GetColor((int)(projectile.Center.X / 16f), (int)(projectile.Center.Y / 16f), Color.White); if (shamanItem.PreDrawCatalyst(spriteBatch, projectile, player, ref color)) { var texture = ModContent.GetTexture(shamanItem.CatalystTexture); var position = projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY; var effect = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; spriteBatch.Draw(texture, position, null, color, projectile.rotation, texture.Size() * 0.5f, projectile.scale, effect, 0f); } shamanItem.PostDrawCatalyst(spriteBatch, projectile, player, color); return(false); }
internal BossInfo(EntryType type, float progression, string modSource, string name, List <int> npcIDs, Func <bool> downed, Func <bool> available, List <int> spawnItem, List <int> collection, List <int> loot, string pageTexture, string info, string despawnMessage = "", string overrideIconTexture = "") { this.type = type; this.progression = progression; this.modSource = modSource; this.internalName = name.StartsWith("$") ? name.Substring(name.LastIndexOf('.') + 1) : name; this.name = name; this.npcIDs = npcIDs ?? new List <int>(); this.downed = downed; this.spawnItem = spawnItem ?? new List <int>(); this.collection = collection ?? new List <int>(); //this.collectType = SetupCollectionTypes(this.collection); Do this during the BossFinalization for orphan data this.loot = loot ?? new List <int>(); this.info = info ?? ""; if (this.info == "") { this.info = "Mods.BossChecklist.BossLog.DrawnText.NoInfo"; } this.despawnMessage = despawnMessage?.StartsWith("$") == true?despawnMessage.Substring(1) : despawnMessage; if ((this.despawnMessage == null || this.despawnMessage == "") && type == EntryType.Boss) { this.despawnMessage = "Mods.BossChecklist.BossVictory.Generic"; } this.pageTexture = pageTexture ?? $"BossChecklist/Resources/BossTextures/BossPlaceholder_byCorrina"; if (!Main.dedServ && !ModContent.TextureExists(this.pageTexture) && this.pageTexture != $"BossChecklist/Resources/BossTextures/BossPlaceholder_byCorrina") { if (SourceDisplayName != "Terraria" && SourceDisplayName != "Unknown") { BossChecklist.instance.Logger.Warn($"Boss Display Texture for {SourceDisplayName} {this.name} named {this.pageTexture} is missing"); } this.pageTexture = $"BossChecklist/Resources/BossTextures/BossPlaceholder_byCorrina"; } this.overrideIconTexture = overrideIconTexture ?? ""; if (!Main.dedServ && !ModContent.TextureExists(this.overrideIconTexture) && this.overrideIconTexture != "") { // If unused, no overriding is needed. If used, we attempt to override the texture used for the boss head icon in the Boss Log. if (SourceDisplayName != "Terraria" && SourceDisplayName != "Unknown") { BossChecklist.instance.Logger.Warn($"Boss Head Icon Texture for {SourceDisplayName} {this.name} named {this.overrideIconTexture} is missing"); } this.overrideIconTexture = "Terraria/NPC_Head_0"; } this.available = available ?? (() => true); this.hidden = false; }
TextSnippet ITagHandler.Parse(string text, Color baseColor, string options) { // TODO: option for scale or absolute size // TODO: option for tooltip/translation key // TODO: option for frame (animated?) // tTooltip // f0;0;20;20 // string tooltip = null; float scale = 1f; int vOffset = 0; string[] array = options.Split(','); foreach (var option in array) { if (option.Length != 0) { if (option[0] == 't') { tooltip = option.Substring(1).Replace(';', ':'); } if (option[0] == 's') { float.TryParse(option.Substring(1), out scale); } if (option[0] == 'v') { int.TryParse(option.Substring(1), out vOffset); } } //return new TextSnippet("<" + text.Replace("\\[", "[").Replace("\\]", "]") + ">", baseColor, 1f); } if (ModContent.TextureExists(text)) { return(new ImageSnippet(text, tooltip, 1f, scale) { vOffset = vOffset }); } return(new TextSnippet(text)); }
/// <summary> /// Attempts to construct the animation source, and rejects any that have bad inputs. /// </summary> private static bool TryConstructSource(Type type, Mod mod, out AnimationSource source) { source = (AnimationSource)Activator.CreateInstance(type, true); string fullName = source.GetType().FullName; if (fullName is null) { throw new ArgumentException($"Invalid full type name from type {source.GetType()}", nameof(type)); } string texturePath = fullName.Replace('.', '/'); if (!source.Load(ref texturePath)) { source = null; return(false); } if (source.tracks is null) { throw new Exception($"[{mod.Name}:{type.FullName}]: Error constructing {type.Name}: Tracks cannot be null."); } if (source.spriteSize.x == 0 || source.spriteSize.y == 0) { throw new Exception($"[{mod.Name}:{type.FullName}]: Error constructing {type.Name}: Sprite Size cannot contain a value of 0."); } if (!ModContent.TextureExists(texturePath)) { throw new MissingResourceException($"[{mod.Name}:{type.FullName}]: Error constructing {type.Name}: Invalid texture path \"{texturePath}\"."); } source.mod = mod; source.texture = ModContent.GetTexture(texturePath); return(true); }
// New system is better internal void AddBoss(float val, int id, string source, string name, Func <bool> down, List <int> spawn, List <int> collect, List <int> loot, string texture) { if (!ModContent.TextureExists(texture)) { texture = "BossAssist/Resources/BossTextures/Boss0"; } SortedBosses.Add(new BossInfo(val, id, source, name, down, spawn, SortCollectibles(collect), loot, texture)); SortedBosses.Sort((x, y) => x.progression.CompareTo(y.progression)); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write("<<Boss Assist>> "); Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write(source + " has added a boss!"); Console.WriteLine(); Console.ResetColor(); if (BossAssist.ServerCollectedRecords != null) { for (int i = 0; i < 255; i++) { BossAssist.ServerCollectedRecords[i].Add(new BossStats()); } // Adding a boss to each player } }
/// <summary> /// Creates a new instance of <see cref="ReferencedTexture2D"/> with the given texture path. /// </summary> /// <param name="texturePath">Path of the texture to get. Either relative to <see cref="OriMod"/> or ModLoader.</param> /// <exception cref="System.InvalidOperationException">Texture classes cannot be constructed on a server.</exception> /// <exception cref="System.ArgumentException"><paramref name="texturePath"/> is empty, or is not a valid texture path.</exception> public ReferencedTexture2D(string texturePath) { if (Main.netMode == NetmodeID.Server) { throw new InvalidOperationException("Texture classes cannot be constructed on a server."); } if (string.IsNullOrWhiteSpace(texturePath)) { throw new ArgumentException($"{nameof(texturePath)} cannot be empty.", nameof(texturePath)); } if (OriMod.instance.TextureExists(texturePath)) { texture = OriMod.instance.GetTexture(texturePath); } else if (ModContent.TextureExists(texturePath)) { texture = ModContent.GetTexture(texturePath); } else { throw new ArgumentException($"{texturePath} is not a valid texture path.", nameof(texturePath)); } }