public void Awake()
        {
            if (!RoR2Application.isModded)
            {
                RoR2Application.isModded = true;
            }

            if (Chainloader.PluginInfos.ContainsKey("com.funkfrog_sipondo.sharesuite"))
            {
                ShareSuite = Chainloader.PluginInfos["com.funkfrog_sipondo.sharesuite"].Instance;
                AddMoney   = ShareSuite.GetType().GetMethod("AddMoneyExternal", BindingFlags.Instance | BindingFlags.Public);
            }

            const string moneySection = "Money";

            var conUtil = new ConditionalUtil(this.Config);

            LatestStageToReceiveMoney = conUtil.AddConditionalConfig <uint>(
                moneySection,
                nameof(LatestStageToReceiveMoney),
                4,
                false,
                new ConfigDescription("Enable to set a latest stage you wish to receive a bonus on. E.g. set this to 4 and you will receive bonus for first 4 rounds and then none after.")
                );

            StageFlatMoney = Config.Bind <uint>(
                moneySection,
                nameof(StageFlatMoney),
                0,
                new ConfigDescription(
                    "The flat amount of extra money the player should receive at beginning of each stage"
                    )
                );

            StageWeightedMoney = Config.Bind <float>(
                moneySection,
                nameof(StageWeightedMoney),
                1.0f,
                new ConfigDescription(
                    "The equivalent number of small chest worth of money you get at start of each stage"
                    )
                );

            RoR2.SceneDirector.onPostPopulateSceneServer += SceneDirector_onPostPopulateSceneServer;
        }
        public void Start()
        {
            if (!RoR2Application.isModded)
            {
                RoR2Application.isModded = true;
            }

            #region ConfigSetup
            const string statsSection   = "Stats";
            const string vampireSection = "RiskOfVampirsm";

            Leech = Config.Bind <float>(
                statsSection,
                "%LifeLeech",
                0.2f,
                new ConfigDescription(
                    "The amount leech given to vampires (% damage)",
                    new AcceptableValueRange <float>(0, 1)));

            DecayTime = Config.Bind <int>(
                statsSection,
                "HealthDecayTime",
                30,
                "The time(s) for player to degenerate health to zero");

            DegenerationThreshold = Config.Bind <int>(
                statsSection,
                "DegenerationThreshold",
                1,
                new ConfigDescription("You will not degenerate below this threshold number", null, "Advanced")
                );

            var conditionalUtil = new FluffyLabsConfigManagerTools.Util.ConditionalUtil(Config);
            MaxHealthGainOnKill = conditionalUtil.AddConditionalConfig <int>(
                vampireSection,
                "GainMaximumHealthOnKill",
                1,
                true,
                new ConfigDescription("Enable to gain +1 base max health for each kill you make"));

            IsVampire = Config.Bind <bool>(
                "Enable/Disable Mod",
                "IsAVampire",
                true,
                "Set to true to be a vampire (Enable/Disable the mod)");

            TurretsTransferLifeToOwner = Config.Bind <bool>(
                vampireSection,
                "TurretsTransferLifeToOwner",
                true,
                new ConfigDescription("Set to true and turrets will lifesteal for the engineer (i.e. turret damage restores life to main engi body)", null, "Advanced"));

            SurvivorCoefficients = GetSurvivorConfigEntries().ToList();
            InitialiseButtonConfigs();
            #endregion

            RoR2.GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal;
            RoR2.GlobalEventManager.onServerDamageDealt    += GlobalEventManager_onServerDamageDealt;
            RoR2.Run.onRunStartGlobal              += Run_onRunStartGlobal;
            On.RoR2.CharacterBody.FixedUpdate      += CharacterBody_FixedUpdate;
            IL.RoR2.CharacterBody.RecalculateStats += CharacterBody_RecalculateStats;
        }
        public void Awake()
        {
            if (!RoR2Application.isModded)
            {
                RoR2Application.isModded = true;
            }

            #region ConfigSetup
            const string votesSection = "Votes";

            VotesEnabled = Config.Bind <bool>(
                votesSection,
                "Enable Votes",
                true,
                new ConfigDescription(
                    "Disable this to bypass voting (i.e. interact with teleporter etc as normal)"
                    ));

            EnableTimerCountdown = Config.Bind <bool>(
                votesSection,
                "Enable Timer Countdown",
                true,
                new ConfigDescription(
                    "Enable/Disable countdown timer to override vote"
                    ));

            ChatCommandCanStartTimer = Config.Bind <bool>(
                votesSection,
                "ChatCommandCanStartTimer",
                false,
                new ConfigDescription(
                    "When enabled the timer can be started by chat command. If disabled timer only starts on interaction.",
                    null,
                    "Advanced"
                    ));

            var cUtil = new ConditionalUtil(this.Config);
            MaximumVotes = cUtil.AddConditionalConfig <int>(
                votesSection,
                "Maximum Votes",
                4,
                false,
                new ConfigDescription(
                    "Enable to set maximum number of votes needed to continue (regardless of player count)."
                    ));
            #endregion

            #region HookRegistration
            //Main hooks - triggers restriction logics
            On.RoR2.TeleporterInteraction.OnInteractionBegin      += TeleporterInteraction_OnInteractionBegin;
            TeleporterInteraction.onTeleporterBeginChargingGlobal += TeleporterInteraction_onTeleporterBeginChargingGlobal;
            TeleporterInteraction.onTeleporterChargedGlobal       += TeleporterInteraction_onTeleporterChargedGlobal;
            TeleporterInteraction.onTeleporterFinishGlobal        += TeleporterInteraction_onTeleporterFinishGlobal;
            On.RoR2.Interactor.PerformInteraction += Interactor_PerformInteraction;
            On.RoR2.PlayerCharacterMasterController.OnBodyDeath += PlayerCharacterMasterController_OnBodyDeath;

            //Chat Ready Command - type "r" to set yourself as ready
            Chat.onChatChanged += Chat_onChatChanged;

            //Prevent an exploitative interaction with teleporter and fireworks
            //IL.RoR2.GlobalEventManager.OnInteractionBegin += GlobalEventManager_OnInteractionBegin;

            //Cleanup Hooks - Needed to avoid bugs where list persists from one run to another
            Run.onRunDestroyGlobal += Run_onRunDestroyGlobal;
            On.RoR2.Run.BeginStage += Run_BeginStage;
            On.RoR2.Run.EndStage   += Run_EndStage;
            #endregion
        }
Пример #4
0
        public void Awake()
        {
            if (!RoR2Application.isModded)
            {
                RoR2Application.isModded = true;
            }

            #region ConfigWrappers
            const string infusionSectionName = "Infusion";
            const string engineerSectionName = "Engineer";

            var conditionalUtil = new ConditionalUtil(this.Config);
            MaximumHealthPerInfusion = conditionalUtil.AddConditionalConfig <uint>(
                infusionSectionName,
                nameof(MaximumHealthPerInfusion),
                100,
                true,
                new ConfigDescription("Maximum health gained per infusion. Disable for no limit."));

            MaxHealthGainPerKill = conditionalUtil.AddConditionalConfig <uint>(
                infusionSectionName,
                nameof(MaxHealthGainPerKill),
                5,
                false,
                new ConfigDescription(
                    "Enable to set the maximum value for health gain per kill."
                    )
                );

            TurretReceivesBonusFromEngineer = Config.Bind <bool>(
                engineerSectionName,
                nameof(TurretReceivesBonusFromEngineer),
                true,
                new ConfigDescription(
                    "If enabled then turrets will receive the current infusion bonus of the Engineer on creation"
                    )
                );

            TurretGivesEngineerLifeOrbs = Config.Bind <bool>(
                engineerSectionName,
                nameof(TurretGivesEngineerLifeOrbs),
                true,
                new ConfigDescription(
                    "If enabled the main engineer body will receive an infusion orb whenever a turret he owns makes a kill"
                    )
                );

            MaximumHealth = Config.Bind(
                infusionSectionName,
                nameof(MaximumHealth),
                999999,
                new ConfigDescription(
                    "Maximum Health you can reach with infusion bonuses - this value probably never needs to change",
                    null,
                    "Advanced"
                    )
                );
            #endregion

            On.RoR2.Inventory.AddInfusionBonus          += Inventory_AddInfusionBonus;
            On.RoR2.GlobalEventManager.OnCharacterDeath += GlobalEventManager_OnCharacterDeath;
            IL.RoR2.GlobalEventManager.OnCharacterDeath += GlobalEventManager_OnCharacterDeath1;
            On.RoR2.CharacterMaster.AddDeployable       += CharacterMaster_AddDeployable;
        }