コード例 #1
0
        void Awake()
        {
            Debug.Log("Begin mod init: TravelOptions");

            Mod  roadsMod        = ModManager.Instance.GetMod(ROADS_MODNAME);
            bool roadsModEnabled = roadsMod != null && roadsMod.Enabled;

            ModSettings settings = mod.GetSettings();

            RoadsIntegration = settings.GetValue <bool>("RoadsIntegration", "Enable") && roadsModEnabled;
            if (RoadsIntegration)
            {
                VariableSizeDots = settings.GetValue <bool>("RoadsIntegration", "VariableSizeDots");
                followKeyCode    = followKeys[settings.GetValue <int>("RoadsIntegration", "FollowPathsKey")];
            }

            enableWeather   = settings.GetValue <bool>("GeneralOptions", "AllowWeather");
            enableSounds    = settings.GetValue <bool>("GeneralOptions", "AllowAnnoyingSounds");
            enableRealGrass = settings.GetValue <bool>("GeneralOptions", "AllowRealGrass");
            locationPause   = settings.GetValue <int>("GeneralOptions", "LocationPause");

            CautiousTravel = settings.GetValue <bool>("CautiousTravel", "PlayerControlledCautiousTravel");
            int speedPenalty = settings.GetValue <int>("CautiousTravel", "SpeedPenalty");

            CautiousTravelMultiplier = 1 - ((float)speedPenalty / 100);
            maxAvoidChance           = settings.GetValue <int>("CautiousTravel", "MaxChanceToAvoidEncounter");
            CautiousHealthMinPc      = settings.GetValue <int>("CautiousTravel", "HealthMinimumPercentage");
            CautiousFatigueMin       = settings.GetValue <int>("CautiousTravel", "FatigueMinimumValue") + 1;

            StopAtInnsTravel               = settings.GetValue <bool>("StopAtInnsTravel", "PlayerControlledInnsTravel");
            ShipTravelPortsOnly            = settings.GetValue <bool>("ShipTravel", "OnlyFromPorts");
            ShipTravelDestinationPortsOnly = settings.GetValue <bool>("ShipTravel", "OnlyToPorts");

            defaultStartingAccel   = startAccelVals[settings.GetValue <int>("TimeAcceleration", "DefaultStartingAcceleration")];
            alwaysUseStartingAccel = settings.GetValue <bool>("TimeAcceleration", "AlwaysUseStartingAcceleration");
            accelerationLimit      = settings.GetValue <int>("TimeAcceleration", "AccelerationLimit");

            UIWindowFactory.RegisterCustomUIWindow(UIWindowType.TravelMap, typeof(TravelOptionsMapWindow));
            UIWindowFactory.RegisterCustomUIWindow(UIWindowType.TravelPopUp, typeof(TravelOptionsPopUp));

            baseFixedDeltaTime = Time.fixedDeltaTime;

            travelControlUI           = new TravelControlUI(DaggerfallUI.UIManager, defaultStartingAccel, accelerationLimit);
            travelControlUI.OnCancel += (sender) => { ClearTravelDestination(); };
            travelControlUI.OnClose  += () => { InterruptTravel(); };
            travelControlUI.OnTimeAccelerationChanged += (timeAcceleration) => { SetTimeScale(timeAcceleration); };

            // Clear destination on new game or load game.
            SaveLoadManager.OnLoad                    += (saveData) => { ClearTravelDestination(); };
            StartGameBehaviour.OnNewGame              += () => { ClearTravelDestination(); };
            GameManager.OnEncounter                   += GameManager_OnEncounter;
            PlayerGPS.OnEnterLocationRect             += PlayerGPS_OnEnterLocationRect;
            PlayerGPS.OnMapPixelChanged               += PlayerGPS_OnMapPixelChanged;
            StreamingWorld.OnUpdateLocationGameObject += StreamingWorld_OnUpdateLocationGameObject;

            mod.MessageReceiver = MessageReceiver;
            mod.IsReady         = true;

            Debug.Log("Finished mod init: TravelOptions");
        }