Esempio n. 1
0
 public static bool IsValidNPC(INpcGetter npc)
 {
     return(!Configuration.NPCs2Skip.Contains(npc.FormKey) &&
            !IsChild(npc) && !IsGhost(npc) &&
            (Regex.IsMatch(npc.EditorID, Configuration.Patcher.ValidNpcRegex, RegexOptions.IgnoreCase) ||
             !Regex.IsMatch(npc.EditorID, Configuration.Patcher.InvalidNpcRegex, RegexOptions.IgnoreCase)));
 }
Esempio n. 2
0
        // Check if the NPC matches an entry in the list
        private static bool NpcMatchesListEditorID(INpcGetter npc)
        {
            if (NpCsToProtect.Contains(npc.EditorID ?? ""))
            {
                return(true);
            }
            if (PatcherOutputLevel == OutputLevel.Debug)
            {
                Console.WriteLine("[INFO] \"" + npc.EditorID +
                                  "\" is not in the list of NPCs to mark as protected.");
            }

            return(false);
        }
Esempio n. 3
0
        // Checks if the given NPC has the Essential Flag
        private static bool NpcIsEssential(INpcGetter npc)
        {
            if (!npc.Configuration.Flags.HasFlag(NpcConfiguration.Flag.Essential))
            {
                return(false);
            }
            if (PatcherOutputLevel == OutputLevel.Verbose ||
                PatcherOutputLevel == OutputLevel.Debug)
            {
                Console.WriteLine("[INFO] [Skipping] \"" + npc.EditorID + "\" is Essential and will be skipped.");
            }

            return(true);
        }
Esempio n. 4
0
        public static Npc addNPCtoPatch(INpcGetter userSelectedNPC, PatcherSettings settings, IPatcherState <ISkyrimMod, ISkyrimModGetter> state)
        {
            switch (settings.ForwardConflictWinnerData)
            {
            case false: return(state.PatchMod.Npcs.GetOrAddAsOverride(userSelectedNPC));

            case true:
                var allContexts = state.LinkCache.ResolveAllContexts <INpc, INpcGetter>(userSelectedNPC.FormKey)
                                  .Take(2)
                                  .ToList();
                if (allContexts.Count < 2)
                {
                    return(state.PatchMod.Npcs.GetOrAddAsOverride(userSelectedNPC));
                }
                else
                {
                    var winningOR   = allContexts[^ 2].Record;
Esempio n. 5
0
        public TNPC(IPatcherState <ISkyrimMod, ISkyrimModGetter> state, INpcGetter npc)
        {
            NpcName = npc.Name == null ? "" : npc.Name.String;
            NPCKey  = npc.FormKey.ToString();
            Eid     = npc.EditorID;

            ClassKey = npc.Class.FormKey.ToString();
            var npcClass = state.LinkCache.Resolve <IClassGetter>(npc.Class.FormKey);

            ClassEID = npcClass.EditorID;

            ClassGroup   = HelperUtils.GetRegexBasedGroup(Configuration.Patcher.OutfitRegex, ClassEID).ToList();
            NameGroup    = HelperUtils.GetRegexBasedGroup(Configuration.Patcher.OutfitRegex, Eid).ToList();
            FactionGroup = new();
            npc.Factions.ForEach(facs =>
            {
                var fac = facs.Faction.Resolve(state.LinkCache).EditorID;
                if (HelperUtils.IsValidFaction(fac))
                {
                    var list = HelperUtils.GetRegexBasedGroup(Configuration.Patcher.OutfitRegex, fac);
                    list.ForEach(l => FactionGroup[l] = fac);
                }
            });

            Identifier = FactionGroup.Count() > 0 ? FactionGroup.Keys.Last()
                            : ClassGroup.Count() > 0 ? ClassGroup.First()
                            : NameGroup.Count() > 0 ? NameGroup.First()
                            : ClassEID == "Citizen"? "CitizenRich":"";

            string facregex = Configuration.Patcher.DividableFactions;
            Match  matcher  = Regex.Match(Identifier, facregex, RegexOptions.IgnoreCase);

            if (matcher.Success)
            {
                var faction = matcher.Value;
                var list    = HelperUtils.GetRegexBasedGroup(Configuration.Patcher.ArmorTypeRegex, ClassEID)
                              .Select(x => x.Replace(faction, "")).EmptyIfNull();
                ArmorType = list.Count() == 0 ? "" : list.First();
            }
        }
Esempio n. 6
0
 public static bool IsFollower(INpcGetter npc)
 {
     return(npc.Factions.Any(r => r.Faction.Resolve <IFactionGetter>(Configuration.Cache).EditorID.Contains("FollowerFaction")));
 }
Esempio n. 7
0
 public static bool IsFemale(INpcGetter npc)
 {
     return(npc.Configuration.Flags.HasFlag(NpcConfiguration.Flag.Female));
 }
Esempio n. 8
0
 public static bool IsGhost(INpcGetter npc)
 {
     return(npc.Configuration.Flags.HasFlag(NpcConfiguration.Flag.IsGhost));
 }
Esempio n. 9
0
 public static bool IsProtected(INpcGetter npc)
 {
     return(npc.Configuration.Flags.HasFlag(NpcConfiguration.Flag.Protected));
 }
Esempio n. 10
0
 public static bool IsEssential(INpcGetter npc)
 {
     return(npc.Configuration.Flags.HasFlag(NpcConfiguration.Flag.Essential));
 }
Esempio n. 11
0
 public static bool IsUnique(INpcGetter npc)
 {
     return(npc.Configuration.Flags.HasFlag(NpcConfiguration.Flag.Unique));
 }
Esempio n. 12
0
 public static bool IsChild(INpcGetter npc)
 {
     return(IsChild(Configuration.Cache.Resolve <IRaceGetter>(npc.Race.FormKey)) ||
            IsChild(Configuration.Cache.Resolve <IClassGetter>(npc.Class.FormKey).EditorID));
 }
Esempio n. 13
0
 private bool ShouldPatch(INpcGetter npc)
 {
     return(!Storage.NPCExclusions.IsExcluded(npc));
 }
Esempio n. 14
0
 public static partial void WriteBinaryDataMarkerCustom(MutagenWriter writer, INpcGetter item)
 {
     using var header = HeaderExport.Subrecord(writer, RecordTypes.DATA);
 }
 public static bool IsEssential(this INpcGetter npc) => npc.Configuration.Flags.HasFlag(NpcConfiguration.Flag.Essential);
        //public static void SetEssential(this NpcConfiguration.Flag Flags , bool value) => Flags = value==Flags.HasFlag(NpcConfiguration.Flag.Essential)?Flags: value ? (Flags & (~NpcConfiguration.Flag.Protected)) | NpcConfiguration.Flag.Essential : (Flags & (~NpcConfiguration.Flag.Essential));
        //public static void SetProtected(this NpcConfiguration.Flag Flags, bool value, bool ignoreIfEssential = true) => Flags =  value == Flags.HasFlag(NpcConfiguration.Flag.Protected) ||(Flags.HasFlag(NpcConfiguration.Flag.Essential) && ignoreIfEssential)? Flags : value ? (Flags & (~NpcConfiguration.Flag.Essential)) | NpcConfiguration.Flag.Essential : (Flags & (~NpcConfiguration.Flag.Protected));

        public static bool IsProtected(this INpcGetter npc) => npc.Configuration.Flags.HasFlag(NpcConfiguration.Flag.Protected);