コード例 #1
0
        private void ApplyPurchaseLogic(GameObject barrel, GameObject allyDummy)
        {
            spawnedBarrels.Add(barrel);

            BarrelInteraction interaction = barrel.GetComponent <BarrelInteraction>();

            interaction.expReward  = 0;
            interaction.goldReward = 0;

            AllyDetails details = interaction.gameObject.AddComponent <AllyDetails>();

            details.ally = allyDummy;
        }
コード例 #2
0
        private void BarrelInteraction_OnInteractionBegin(On.RoR2.BarrelInteraction.orig_OnInteractionBegin orig, BarrelInteraction self, Interactor activator)
        {
            if (!NetworkServer.active)
            {
                orig(self, activator);
                return;
            }

            if (IsOnVIPSelectionStage)
            {
                if (self.Networkopened)
                {
                    orig(self, activator);
                    return;
                }

                foreach (var barrel in spawnedBarrels)
                {
                    BarrelInteraction interaction = barrel.GetComponent <BarrelInteraction>();
                    if (self != interaction)
                    {
                        interaction.Networkopened = true;
                    }
                }

                AllyDetails details = self.GetComponent <AllyDetails>();
                if (details && details.ally)
                {
                    CharacterMaster summonCharacterMaster = activator.GetComponent <CharacterBody>().master;
                    CharacterMaster allyCharacterMaster   = details.ally.GetComponent <CharacterMaster>();

                    AllyMaster allyMaster = allyCharacterMaster.gameObject.AddComponent <AllyMaster>();
                    allyMaster.NameToken = "VIP";

                    GiveHelpingHand(allyCharacterMaster);
                    ApplyNormalAI(
                        details.ally.GetComponent <BaseAI>(),
                        summonCharacterMaster.GetBodyObject());

                    allies.Add(allyCharacterMaster);
                    allySquad.AddMember(allyCharacterMaster);

                    Chat.SendBroadcastChat(new Chat.SimpleChatMessage()
                    {
                        baseToken = $"<color=#{ColorUtility.ToHtmlStringRGB(Color.green)}>Protect the VIP:</color> " +
                                    $"<color=#{ColorUtility.ToHtmlStringRGB(Color.gray)}>Protect the ally at all costs.</color> " +
                                    $"<color=#{ColorUtility.ToHtmlStringRGB(Color.red)}>If it dies, you die.</color>"
                    });
                }
                else if (details && !details.ally)
                {
                    Chat.SendBroadcastChat(new Chat.SimpleChatMessage()
                    {
                        baseToken = $"<color=#{ColorUtility.ToHtmlStringRGB(Color.green)}>Protect the VIP:</color> " +
                                    $"<color=#{ColorUtility.ToHtmlStringRGB(Color.gray)}>Starting run with no ally.</color>"
                    });
                }
                else
                {
                    Debug.LogError("No details attached to barrel :( Starting normal run...");
                }

                GoToNextLevel();

                Debug.Log("Unhooking from RoR2.BarrelInteraction.OnInteractionBegin");
                On.RoR2.BarrelInteraction.OnInteractionBegin -= BarrelInteraction_OnInteractionBegin;
            }

            orig(self, activator);
        }