public void AddIncomingAttachment(TagSet rule, Position position) { if (rule != null) { incomingAttachments.Add(rule, position); } }
public void AddOutgoingAttachment(TagSet rule, OutgoingAttachment outgoingAttachment) { if (rule != null) { outgoingAttachments.Add(rule, outgoingAttachment); } }
public int GetOrCreateItemIdForAuction(SaveAuction auction, HypixelContext context) { var clearedName = ItemReferences.RemoveReforgesAndLevel(auction.ItemName); var tag = GetIdForName(auction.Tag ?? clearedName); if (tag != null && TagLookup.TryGetValue(tag, out int value)) { return(value); } Console.WriteLine($"Creating item {clearedName} ({auction.ItemName},{auction.Tag})"); // doesn't exist yet, create it var itemByTag = context.Items.Where(item => item.Tag == auction.Tag).FirstOrDefault(); if (itemByTag != null) { // new alternative name if (clearedName != null) { this.ReverseNames[clearedName] = auction.Tag; } TagLookup.Add(auction.Tag, itemByTag.Id); var exists = context.AltItemNames .Where(name => name.Name == clearedName && name.DBItemId == itemByTag.Id) .Any(); if (!exists) { context.AltItemNames.Add(new AlternativeName() { DBItemId = itemByTag.Id, Name = clearedName }); } return(itemByTag.Id); } Console.WriteLine($"!! completely new !! {JsonConvert.SerializeObject(auction)}"); // new Item //var tempAuction = new Hypixel.NET.SkyblockApi.Auction(){Category=auction.Category,}; //AddNewItem(tempAuction,auction.ItemName,auction.Tag,null); var item = new DBItem() { Tag = auction.Tag, Name = auction.ItemName, Names = new List <AlternativeName>() { new AlternativeName() { Name = auction.ItemName } } }; if (item.Tag == null) { // unindexable item return(MAX_MEDIUM_INT); } ToFillDetails[item.Tag] = item; return(AddItemToDB(item)); //throw new CoflnetException("can_add","can't add this item"); }
/// <param name="celAlphaMasks">Fill with masks created from Cels</param> /// <param name="allMasks">Fill with all created masks</param> public void RegenerateAlphaMask() { masks.TryRemoveBaseFallBack(); // <- it is about to be regenerated // If this frame has a single sprite-containing Cel, generate it directly if (firstLayer != null && firstLayer.next == null) { Mask mask = new Mask { data = firstLayer.spriteRef.ResolveRequire().GetAlphaMask(), isGeneratedAlphaMask = true, }; masks.Add(new TagSet(), mask); } else // ... Otherwise, try to create a mask merged from the frame's layers { List <MaskData> layerMasks = new List <MaskData>(); foreach (var cel in layers) { MaskData maskData = cel.spriteRef.ResolveRequire().GetAlphaMask(); if (maskData.Width != 0 && maskData.Height != 0) { layerMasks.Add(maskData); } } Rectangle maxBounds = Rectangle.Empty; foreach (var maskData in layerMasks) { maxBounds = RectangleExtensions.UnionIgnoreEmpty(maxBounds, maskData.Bounds); } Mask mask = new Mask() { isGeneratedAlphaMask = true }; mask.data = new MaskData(maxBounds); foreach (var layerMask in layerMasks) { Debug.Assert(!Asserts.enabled || mask.data.Bounds.Contains(layerMask.Bounds)); mask.data.SetBitwiseOrFrom(layerMask); } masks.Add(new TagSet(), mask); } }
public void AddAnimation(TagSet rule, Animation animation) { if (rule != null) { animations.Add(rule, animation); } else { (unusedAnimations ?? (unusedAnimations = new List <Animation>())).Add(animation); } }
/// <summary>Construct from text file lines</summary> public StringBank(IEnumerable <string> inputLines, bool generateUpperCase = false) { // This is so we can collate the strings per tag set: Dictionary <TagSet, List <string> > temporaryLookup = new Dictionary <TagSet, List <string> >(); int stringCount = 0; // Load all of the localized lines and collate them: foreach (var line in inputLines) { if (string.IsNullOrWhiteSpace(line) || line.TrimStart(' ').StartsWith("#")) { continue; // ignore comment lines and empty lines } var split = line.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries); Debug.Assert(split.Length == 2, "invalid localization format"); if (split.Length != 2) { continue; } var value = split[1].Trim(); if (value == "[NONE]") { continue; } // to represent multiple symbols in a tag we use Symbol1,Symbol2 var symbols = split[0].Trim().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var tagSet = new TagSet(symbols); // Shove it in the string list for now... List <string> stringList; if (!temporaryLookup.TryGetValue(tagSet, out stringList)) { temporaryLookup.Add(tagSet, stringList = new List <string>()); } stringList.Add(ButtonGlyphReplacement(value)); stringCount++; } // Fill out the real lookup with the collated lines: lookup = new TagLookup <StringRange>(temporaryLookup.Count); lowercase = new List <string>(stringCount); foreach (var kvp in temporaryLookup) { StringRange sr = new StringRange { start = lowercase.Count, count = kvp.Value.Count }; lowercase.AddRange(kvp.Value); Debug.Assert(lowercase.Count == sr.start + sr.count); lookup.Add(kvp.Key, sr); } // Now that all strings are loaded, swap out any reference tags, // i.e. "I am a <BeardedDragon>" -> "I am a Bearded Dragon" Regex tagsPattern = new Regex(@"<(\w*)>", RegexOptions.Compiled); for (int i = 0; i < lowercase.Count; i++) { lowercase[i] = tagsPattern.Replace(lowercase[i], m => { List <string> replacements; if (temporaryLookup.TryGetValue(new TagSet(m.Groups[1].Captures[0].Value), out replacements) ) // <- NOTE: doing dictionary lookup, not tag lookup { return(replacements[0]); } else { Console.WriteLine("Failed to find string replacement for \"{0}\"", m.Value); return(m.Value); } }); } // If you ask nicely, we'll generate upper-case strings as well... if (generateUpperCase) { uppercase = new List <string>(lowercase.Count); for (int i = 0; i < lowercase.Count; i++) { uppercase.Add(lowercase[i].ToUpperInvariant()); } } }