/// <summary>
 /// Applied before AndTagBits runs.
 /// </summary>
 internal static bool Prefix(KPrefabID __instance, ref TagBits ___tagBits,
                             ref TagBits rhs)
 {
     __instance.UpdateTagBits();
     TagBitOps.And(ref rhs, ref ___tagBits);
     return(false);
 }
            /// <summary>
            /// Applied before SetTag runs.
            /// </summary>
            internal static bool Prefix(ref ulong ___bits7, Tag tag)
            {
                var  inst    = ExtendedTagBits.Instance;
                int  index   = inst.ManifestFlagIndex(tag) - ExtendedTagBits.VANILLA_LIMIT;
                bool vanilla = index < 0;

                if (!vanilla)
                {
                    int id = inst.GetIDWithTagSet(TagBitOps.GetUpperBits(___bits7), index);
                    ___bits7 = (___bits7 & 0xFFFFFFFFUL) | ((ulong)id << 32);
                }
                return(vanilla);
            }
Esempio n. 3
0
            /// <summary>
            /// Applied before Clear runs.
            /// </summary>
            internal static bool Prefix(ref ulong ___bits5, Tag tag)
            {
                var  inst    = ExtendedTagBits.Instance;
                int  index   = inst.ManifestFlagIndex(tag) - ExtendedTagBits.VANILLA_LIMIT;
                bool vanilla = index < 0;

                if (!vanilla && ___bits5 != 0UL)
                {
                    int id = inst.GetIDWithTagClear(TagBitOps.GetUpperBits(___bits5), index);
                    ___bits5 = TagBitOps.GetLowerBits(___bits5) | ((ulong)id << 32);
                }
                return(vanilla);
            }
Esempio n. 4
0
        public override void OnLoad(Harmony harmony)
        {
            base.OnLoad(harmony);
            PUtil.InitLibrary();
#if DEBUG
            SpamObjectsHandler.PrepareSpamHandler(new PLib.PatchManager.PPatchManager(harmony));
#endif
            var inst = ExtendedTagBits.Instance;
            // Force these tags into the efficient lower bits
            foreach (var tag in FORCE_LOWER_BITS)
            {
                inst.ManifestFlagIndex(tag);
            }
            FetchManager.disallowedTagMask = TagBitOps.Not(FetchManager.disallowedTagBits);
            FetchAreaChore.StatesInstance.s_transientDeliveryMask = TagBitOps.Not(new TagBits(
                                                                                      new Tag[] { GameTags.Garbage, GameTags.Creatures.Deliverable }));
            new PVersionCheck().Register(this, new SteamVersionChecker());
        }
Esempio n. 5
0
        public static void OnLoad()
        {
#if DEBUG
            PUtil.InitLibrary();
            SpamObjectsHandler.PrepareSpamHandler();
#else
            var assembly = Assembly.GetExecutingAssembly();
            PUtil.LogDebug("Mod {0} initialized, version {1}".F(assembly.GetName()?.Name,
                                                                assembly.GetFileVersion() ?? "Unknown"));
#endif
            var inst = ExtendedTagBits.Instance;
            // Force these tags into the efficient lower bits
            foreach (var tag in FORCE_LOWER_BITS)
            {
                inst.ManifestFlagIndex(tag);
            }
            FetchManager.disallowedTagMask = TagBitOps.Not(FetchManager.disallowedTagBits);
            PDetours.DetourField <FetchAreaChore.StatesInstance, TagBits>(
                "s_transientDeliveryMask").Set(null, TagBitOps.Not(new TagBits(new Tag[] {
                GameTags.Garbage, GameTags.Creatures.Deliverable
            })));
        }
            /// <summary>
            /// Applied before GetTagsVerySlow runs.
            /// </summary>
            internal static bool Prefix(int bits_idx, ulong bits, List <Tag> tags)
            {
                bool extended = bits_idx >= 5;
                var  inst = ExtendedTagBits.Instance;
                int  ubits = TagBitOps.GetUpperBits(bits), nlower = extended ? 32 : 64,
                     baseIdx = BitSet.ULONG_BITS * bits_idx;

                // Vanilla tags in lowest N bits
                for (int i = 0; i < nlower; i++)
                {
                    if ((bits & 1UL) != 0UL)
                    {
                        var tag = inst.GetTagForIndex(baseIdx + i);
                        if (tag != Tag.Invalid)
                        {
                            tags.Add(tag);
                        }
                    }
                    bits >>= 1;
                }
                // Extended tags in highest bits
                if (extended && ubits != 0)
                {
                    var bitSet = inst.GetTagBits(ubits);
                    for (int i = 0; i < bitSet.Capacity; i++)
                    {
                        if (bitSet.Get(i))
                        {
                            var tag = inst.GetTagForIndex(ExtendedTagBits.VANILLA_LIMIT + i);
                            if (tag != Tag.Invalid)
                            {
                                tags.Add(tag);
                            }
                        }
                    }
                }
                return(false);
            }