Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extension to travel calculator for mods #2539

Merged
merged 1 commit into from Oct 9, 2023

Conversation

ajrb
Copy link
Collaborator

@ajrb ajrb commented Sep 24, 2023

Required for new settings for Travel Options mod in DFU release 1.0

@KABoissonneault
Copy link
Collaborator

I assume the intent of this change is so DaggerfallTravelPopup can be overriden to use a custom TravelTimeCalculator. But the calculator is also used by the Questing Clock, in GetTravelTimeInSeconds

            // Create a path to location
            // Use the most cautious time possible allowing for player to camp out or stop at inns along the way
            TravelTimeCalculator travelTimeCalculator = new TravelTimeCalculator();
            int travelTimeMinutes = travelTimeCalculator.CalculateTravelTime(endPos, true, false, false, false, true);

I feel like we should also provide a way for mods to override the quest travel time calculator for consistency.

I'd suggest adding a public static Func<TravelTimeCalculator> TravelTimeCalculatorFactory = () => new TravelTimeCalculator(); in Clock, and replacing the above snippet with

            // Create a path to location
            // Use the most cautious time possible allowing for player to camp out or stop at inns along the way
            TravelTimeCalculator travelTimeCalculator = TravelTimeCalculatorFactory();
            int travelTimeMinutes = travelTimeCalculator.CalculateTravelTime(endPos, true, false, false, false, true);

@ajrb
Copy link
Collaborator Author

ajrb commented Sep 25, 2023

I simply want to be able to manipulate the travel costs after they're calculated - they're retrieved from the calc class several times by the popup so this is to prevent me duplicating quite a bit of popup code by adjusting the cost variables in the calc class once they're calculated. Actually I only need to have the virtual on CalculateTripCost() but I thought it was worth making the others virtual as well.

Keeping the changes as simple as possible to get them in to 1.0 was my focus, and my mod already overrides the popup, but by all means create a follow on PR. I won't require that myself though.

@Interkarma Interkarma merged commit 612cf45 into Interkarma:master Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants