Exemplo n.º 1
0
        private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            // This hook runs on Client and on Server
            orig(self);
            CharacterMaster master = self.master;

            if (!master)
            {
                return;
            }
            MinionOwnership minionOwnership = master.minionOwnership;

            if (!minionOwnership || minionOwnership.ownerMaster || FilterMinions(master))
            {
                return;
            }
            OptionMasterTracker masterTracker = master.GetOrAddComponent <OptionMasterTracker>();
            int newCount = GetCount(self);
            int oldCount = masterTracker.optionItemCount;
            int diff     = newCount - oldCount;

            if (diff != 0)
            {
                masterTracker.optionItemCount = newCount;
                Log.Message($"OnInventoryChanged: Master: {master.name}, OldCount: {oldCount}, NewCount: {newCount}, Difference: {diff}");
                if (diff > 0)
                {
                    LoopAllMinions(master, minion => OptionMasterTracker.SpawnOptions(minion, oldCount, newCount));
                }
                else
                {
                    LoopAllMinions(master, minion => OptionMasterTracker.DestroyOptions(minion, oldCount, newCount));
                }
            }
        }
Exemplo n.º 2
0
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

        private void CharacterBody_onBodyStartGlobal(CharacterBody obj)
        {
            // This hook runs on Client and on Server
            CharacterMaster master = obj.master;

            if (FilterMinions(master) && master.minionOwnership)
            {
                AssignAurelioniteOwner(master);
                CharacterMaster masterMaster = master.minionOwnership.ownerMaster;
                if (masterMaster && GetCount(masterMaster) > 0)
                {
                    OptionMasterTracker masterTracker = masterMaster.GetOrAddComponent <OptionMasterTracker>();
                    Log.Message($"OnBodyStartGlobal: Minion: {master.name}, Master: {masterMaster.name}, Options: {masterTracker.optionItemCount}");
                    OptionMasterTracker.SpawnOptions(obj.gameObject, 0, masterTracker.optionItemCount);
                }
            }
        }