private static AbnormalityInfo AbnormalityXmlNodeToInfo(XmlNode node, AbnormalityType type, string idPrefix) { if (node?.Attributes == null) { throw new ArgumentNullException(nameof(node), "XmlNode and its attributes cannot be null!"); } AbnormalityInfo abnormality = new AbnormalityInfo { Id = int.Parse(node.Attributes["ID"].Value), Type = type, Offset = int.Parse(node.Attributes["Offset"].Value, System.Globalization.NumberStyles.HexNumber), IsDebuff = bool.Parse(node.Attributes["IsDebuff"]?.Value ?? "False"), IsGearBuff = bool.Parse(node.Attributes["IsGearBuff"]?.Value ?? "False"), IsInfinite = bool.Parse(node.Attributes["IsInfinite"]?.Value ?? "False"), IconName = node.Attributes["Icon"]?.Value, HasConditions = bool.Parse(node.Attributes["HasConditions"]?.Value ?? "False"), ConditionOffset = int.Parse(node.Attributes["ConditionOffset"]?.Value ?? "0"), Stack = int.Parse(node.Attributes["Stack"]?.Value ?? "0"), IsPercentageBuff = bool.Parse(node.Attributes["IsPercentageBuff"]?.Value ?? "False"), MaxTimer = float.Parse(node.Attributes["MaxTimer"]?.Value ?? "0", System.Globalization.CultureInfo.InvariantCulture) }; abnormality.InternalId = $"{idPrefix}_{abnormality.Id}"; if (string.IsNullOrEmpty(abnormality.IconName)) { abnormality.IconName = "ICON_MISSING"; } return(abnormality); }
public Abnormality(AbnormalityInfo info) { Type = info.Type; Id = info.Id; InternalID = info.InternalId; IsDebuff = info.IsDebuff; IsInfinite = info.IsInfinite; Icon = info.IconName; }
public Abnormality(AbnormalityInfo info) { Type = info.Type; Id = info.Id; InternalID = info.InternalId; IsDebuff = info.IsDebuff; IsInfinite = info.IsInfinite; Icon = info.IconName; IsPercentageBuff = info.IsPercentageBuff; MaxTimer = info.MaxTimer; }
private void UpdateAbnormality(AbnormalityInfo info, long baseAddress) { const int firstHornBuffOffset = 0x38; long abnormalityAddress = baseAddress + info.Offset; float duration = Scanner.READ_FLOAT(abnormalityAddress); bool hasConditions = info.HasConditions; byte stack = 0; // Palico and misc buffs don't stack switch (info.Type) { case "HUNTINGHORN": stack = Scanner.READ_BYTE(baseAddress + 0x164 + (info.Offset - firstHornBuffOffset) / 4); break; case "MISC": if (info.HasConditions) { stack = Scanner.READ_BYTE(baseAddress + info.Offset + info.ConditionOffset); hasConditions = stack > 0; } break; } if ((int)duration <= 0 && !(hasConditions && info.IsInfinite)) { if (Abnormalities[info.InternalId] != null) { Abnormalities.Remove(info.InternalId); } return; } if (stack < info.Stack) { return; } if (Abnormalities[info.InternalId] != null) { Abnormalities[info.InternalId].UpdateAbnormalityInfo(duration, stack); } else { var a = new Abnormality(info); a.UpdateAbnormalityInfo(duration, stack); Abnormalities.Add(info.InternalId, a); } }