示例#1
0
            public static void Postfix(SimGameState __instance, SimGameEventTracker ___companyEventTracker)
            {
                void ActivateAnyEvent(float eventChance)
                {
                    float randomRoll = __instance.NetworkRandom.Float(0f, 1f);

                    if (randomRoll < eventChance)
                    {
                        Logger.Debug("----------------------------------------------------------------------------------------------------");
                        Logger.Debug("[SimGameState_OnDayPassed_POSTFIX] ActivateRandomEvent");
                        Logger.Debug("----------------------------------------------------------------------------------------------------");
                        ___companyEventTracker.ActivateRandomEvent();
                    }
                }

                void ActivateSpecialEvent(string eventId, float eventChance)
                {
                    if (SpecialEventCounter >= SpecialEventMax)
                    {
                        Logger.Debug("[SimGameState_OnDayPassed_POSTFIX] SpecialEventMax(" + SpecialEventMax + ") reached. Exiting.");
                        return;
                    }
                    SpecialEventCounter++;

                    float randomRoll = __instance.NetworkRandom.Float(0f, 1f);

                    if (randomRoll < eventChance)
                    {
                        Pilot plt = null;
                        SimGameForcedEvent evt = new SimGameForcedEvent
                        {
                            Scope       = EventScope.Company,
                            EventID     = eventId,
                            MinDaysWait = 0,
                            MaxDaysWait = 0,
                            Probability = 100,
                            RetainPilot = false
                        };
                        Logger.Debug("----------------------------------------------------------------------------------------------------");
                        Logger.Debug("[SimGameState_OnDayPassed_POSTFIX] AddSpecialEvent");
                        Logger.Debug("----------------------------------------------------------------------------------------------------");
                        __instance.AddSpecialEvent(evt, plt);
                    }
                }

                bool activateEvent = DaysUneventfulCounter++ == DaysUneventful;

                if (activateEvent)
                {
                    DaysUneventfulCounter = 0;
                    ActivateSpecialEvent("event_dcm_test", 1f);
                    //ActivateAnyEvent(0.2f);
                }
            }
示例#2
0
        public static void Force(string param)
        {
            SimGameState simGameState = SceneSingletonBehavior <UnityGameInstance> .Instance.Game.Simulation;

            if (param == "help")
            {
                string help = "";
                help += "• This command will let you force an event";
                help += Environment.NewLine;
                help += "• Params: the desired event id";
                help += Environment.NewLine;
                help += "• Example: '/event event_co_littleAccident'";
                help += Environment.NewLine;
                help += Environment.NewLine;
                help += "Currently only events with scope 'Company' are supported";
                PopupHelper.Info(help);

                return;
            }



            string message = "";

            Pilot plt = null;
            SimGameForcedEvent evt = new SimGameForcedEvent
            {
                Scope       = EventScope.Company,
                EventID     = param,
                MinDaysWait = 0,
                MaxDaysWait = 0,
                Probability = 100,
                RetainPilot = false
            };

            simGameState.AddSpecialEvent(evt, plt);



            message = $"Forced event '{param}' to occur the next day";
            Logger.Debug($"[Cheater_Event_Force] {message}");
            PopupHelper.Info(message);
        }