public void SetRestrictions(RestrictionEnum _Restrictions = defaultRestrictions) { if (Restrictions == _Restrictions) { return; } needsUpdate = true; Restrictions = _Restrictions; }
public void SetRestriction(RestrictionEnum Restriction, bool CanOrIs) { if (CanOrIs) { if (!this.HasRestriction(Restriction)) { this.Restriction |= (int)Restriction; } } else if (this.HasRestriction(Restriction)) { this.Restriction ^= (int)Restriction; } }
public void ApplyConfig(string config) { Match match; match = regexPos.Match(config); SetPosition( match.Success ? Utils.TryGetDouble(match.Groups[1].Value, defaultPosX) : defaultPosX, match.Success ? Utils.TryGetDouble(match.Groups[2].Value, defaultPosY) : defaultPosY ); match = regexScale.Match(config); SetScale( match.Success ? Utils.TryGetDouble(match.Groups[1].Value, defaultScale) : defaultScale ); match = regexColor.Match(config); SetColor(match.Success ? match.Groups[1].Value : defaultColor); if (config.IndexOf(monospaceFont, StringComparison.OrdinalIgnoreCase) != -1) { SetFont(monospaceFont); } else { SetFont(); } SetNoHideHud(config.IndexOf("nohide", StringComparison.OrdinalIgnoreCase) != -1); match = regexBackground.Match(config); if (match.Success) { SetBackground( true, match.Groups[1].Value, Utils.TryGetInt(match.Groups[2].Value, defaultBackgroundOpacity) ); } else { SetBackground(false); } match = regexRange.Match(config); if (match.Success) { switch (match.Groups[1].Value) { case "all": RangeType = RangeTypeEnum.All; break; case "faction": RangeType = RangeTypeEnum.Faction; break; default: RangeType = RangeTypeEnum.Player; break; } SetRange( true, Utils.TryGetInt(match.Groups[2].Value, defaultRange) ); } else { SetRange(false); } var matches = regexRestriction.Matches(config); if (matches.Count > 0 || HasRange) { RestrictionEnum NewRestrictions = RestrictionEnum.None; foreach (Match one in matches) { switch (one.Groups[1].Value) { case "first": NewRestrictions |= RestrictionEnum.First; break; case "third": NewRestrictions |= RestrictionEnum.Third; break; case "camera": NewRestrictions |= RestrictionEnum.Camera; break; case "anyview": NewRestrictions |= RestrictionEnum.Any; break; } } SetRestrictions(NewRestrictions); } else { SetRestrictions(); } }
public bool HasRestriction(RestrictionEnum Restriction) { return((this.Restriction & (int)Restriction) == (int)Restriction); }