Skip to content

Commit

Permalink
update mod for game version 1.2.3f1 (#6)
Browse files Browse the repository at this point in the history
* renaming settings and main mod file from defaults. moving it to a settings folder as well

* while i'm here, update the underlying train system to latest decompiled

* Update PatchedTransportCarAISystem.cs

* formatting
  • Loading branch information
bcallender authored Feb 2, 2025
1 parent 4d2a595 commit 38a41fb
Show file tree
Hide file tree
Showing 6 changed files with 415 additions and 603 deletions.
29 changes: 17 additions & 12 deletions AllAboard/Mod.cs → AllAboard/AllAboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

namespace AllAboard
{
public class Mod : IMod
public class AllAboard : IMod
{
public static ILog log = LogManager.GetLogger($"{nameof(AllAboard)}.{nameof(Mod)}").SetShowsErrorsInUI(false);
public static Setting m_Setting;
public static ILog log = LogManager.GetLogger($"{nameof(AllAboard)}.Mod")
.SetShowsErrorsInUI(false);

public static AllAboardSettings m_AllAboardSettings;

public void OnLoad(UpdateSystem updateSystem)
{
Expand All @@ -22,15 +24,18 @@ public void OnLoad(UpdateSystem updateSystem)
if (GameManager.instance.modManager.TryGetExecutableAsset(this, out var asset))
log.Info($"Current mod asset at {asset.path}");

m_Setting = new Setting(this);
m_Setting.RegisterInOptionsUI();
GameManager.instance.localizationManager.AddSource("en-US", new LocaleEN(m_Setting));
m_AllAboardSettings = new AllAboardSettings(this);
m_AllAboardSettings.RegisterInOptionsUI();
GameManager.instance.localizationManager.AddSource("en-US", new LocaleEN(m_AllAboardSettings));


AssetDatabase.global.LoadSettings(nameof(AllAboard), m_Setting, new Setting(this));
AssetDatabase.global.LoadSettings("AllAboard", m_AllAboardSettings,
new AllAboardSettings(this));

PublicTransportBoardingHelper.TrainMaxAllowedMinutesLate.Data = (uint) m_Setting.TrainMaxDwellDelaySlider;
PublicTransportBoardingHelper.BusMaxAllowedMinutesLate.Data = (uint) m_Setting.BusMaxDwellDelaySlider;
PublicTransportBoardingHelper.TrainMaxAllowedMinutesLate.Data =
(uint)m_AllAboardSettings.TrainMaxDwellDelaySlider;
PublicTransportBoardingHelper.BusMaxAllowedMinutesLate.Data =
(uint)m_AllAboardSettings.BusMaxDwellDelaySlider;
World.DefaultGameObjectInjectionWorld.GetOrCreateSystemManaged<TransportTrainAISystem>().Enabled = false;
World.DefaultGameObjectInjectionWorld.GetOrCreateSystemManaged<TransportCarAISystem>().Enabled = false;
updateSystem.UpdateAt<PatchedTransportCarAISystem>(SystemUpdatePhase.GameSimulation);
Expand All @@ -44,10 +49,10 @@ public void OnLoad(UpdateSystem updateSystem)
public void OnDispose()
{
log.Info(nameof(OnDispose));
if (m_Setting != null)
if (m_AllAboardSettings != null)
{
m_Setting.UnregisterInOptionsUI();
m_Setting = null;
m_AllAboardSettings.UnregisterInOptionsUI();
m_AllAboardSettings = null;
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions AllAboard/Properties/PublishConfiguration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ tl;dr: This mod adds a hard cap on the Dwell Time of public transport vehicles,

### Changelog

#### 0.1.4
#### 0.1.5
- Rename the root mod files from the generic defaults. Should also make settings actually persist between saves! (Thanks Quoshik!)
- Updated the decompiled versions of the Car/Train AI Systems to 1.2.3f1.

#### 0.1.4
- Fixes a minor namespacing issue.

#### 0.1.3

#### 0.1.3
- Updated for 1.2.0f. Keeps in all of the new CO code that fixes some ResidentAI behavior while keeping a hard cap on
dwell time.

Expand Down Expand Up @@ -136,16 +138,15 @@ vehicle to reject the boarding cims!
<!--Link to the forum post where the mod can be discussed-->
<ForumLink Value=""/>
<!--Version of the mod-->
<ModVersion Value="0.1.4"/>
<ModVersion Value="0.1.5"/>
<!--Recommended version of the base game to use the mod-->
<GameVersion Value="1.2.*"/>
<!--Dependency for the mod, can be set multiple times-->
<Dependency Id=""/>
<!--Change log for new version. Single line or multi line. Supports minimal markdown subset-->
<ChangeLog>
- Fixes a minor namespacing issue.
- Updated for 1.2.0f. Keeps in all of the new CO code that fixes some ResidentAI behavior while keeping a hard cap on
dwell time.
- Rename the root mod files from the generic defaults. Should also make settings actually persist between saves! (Thanks Quoshik!)
- Updated the decompiled versions of the Car/Train AI Systems to 1.2.3f1.
</ChangeLog>
<!--External link. supported types are discord, github, youtube, twitch, x, paypal, patreon, buymeacoffee, kofi, crowdin, gitlab-->
<ExternalLink Type="github" Url="https://github.com/bcallender/AllAboard"/>
Expand Down
36 changes: 18 additions & 18 deletions AllAboard/Setting.cs → AllAboard/Settings/AllAboardSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@

namespace AllAboard
{
[FileLocation(nameof(Mod))]
public class Setting : ModSetting
[FileLocation(nameof(AllAboard))]
public class AllAboardSettings : ModSetting
{
public AllAboardSettings(IMod mod) : base(mod)
{
SetDefaults();
}

[SettingsUISlider(min = 0, max = 30, step = 1, unit = "Minutes")]
public int TrainMaxDwellDelaySlider { get; set; }

Expand All @@ -23,18 +28,13 @@ public bool ApplyButton
{
PublicTransportBoardingHelper.TrainMaxAllowedMinutesLate.Data = (uint)TrainMaxDwellDelaySlider;
PublicTransportBoardingHelper.BusMaxAllowedMinutesLate.Data = (uint)BusMaxDwellDelaySlider;
Mod.log.InfoFormat(
AllAboard.log.InfoFormat(
"Now max dwell delay: Bus: {0} minutes, Train : {1} minutes.",
PublicTransportBoardingHelper.BusMaxAllowedMinutesLate.Data,
PublicTransportBoardingHelper.TrainMaxAllowedMinutesLate.Data);
}
}

public Setting(IMod mod) : base(mod)
{
SetDefaults();
}

public override void SetDefaults()
{
TrainMaxDwellDelaySlider = 8;
Expand All @@ -44,38 +44,38 @@ public override void SetDefaults()

public class LocaleEN : IDictionarySource
{
private readonly Setting _setting;
private readonly AllAboardSettings m_AllAboardSettings;

public LocaleEN(Setting setting)
public LocaleEN(AllAboardSettings allAboardSettings)
{
_setting = setting;
m_AllAboardSettings = allAboardSettings;
}

public IEnumerable<KeyValuePair<string, string>> ReadEntries(IList<IDictionaryEntryError> errors,
Dictionary<string, int> indexCounts)
{
return new Dictionary<string, string>
{
{ _setting.GetSettingsLocaleID(), "All Aboard!" },
{ m_AllAboardSettings.GetSettingsLocaleID(), "All Aboard!" },
{
_setting.GetOptionLabelLocaleID(nameof(Setting.TrainMaxDwellDelaySlider)),
m_AllAboardSettings.GetOptionLabelLocaleID(nameof(AllAboardSettings.TrainMaxDwellDelaySlider)),
"Train Maximum Dwell Delay (in-game minutes)"
},
{
_setting.GetOptionDescLocaleID(nameof(Setting.TrainMaxDwellDelaySlider)),
m_AllAboardSettings.GetOptionDescLocaleID(nameof(AllAboardSettings.TrainMaxDwellDelaySlider)),
"Maximum amount of (in-game) time to allow a Train (Subway, Tram) to 'dwell' beyond its scheduled departure frame. "
},

{
_setting.GetOptionLabelLocaleID(nameof(Setting.BusMaxDwellDelaySlider)),
m_AllAboardSettings.GetOptionLabelLocaleID(nameof(AllAboardSettings.BusMaxDwellDelaySlider)),
"Bus Maximum Dwell Delay (in-game minutes)"
},
{
_setting.GetOptionDescLocaleID(nameof(Setting.BusMaxDwellDelaySlider)),
m_AllAboardSettings.GetOptionDescLocaleID(nameof(AllAboardSettings.BusMaxDwellDelaySlider)),
"Maximum amount of (in-game) time to allow a Bus to 'dwell' beyond its scheduled departure frame. "
},
{ _setting.GetOptionLabelLocaleID(nameof(Setting.ApplyButton)), "Apply" },
{ _setting.GetOptionDescLocaleID(nameof(Setting.ApplyButton)), "Apply Settings" }
{ m_AllAboardSettings.GetOptionLabelLocaleID(nameof(AllAboardSettings.ApplyButton)), "Apply" },
{ m_AllAboardSettings.GetOptionDescLocaleID(nameof(AllAboardSettings.ApplyButton)), "Apply Settings" }
};
}

Expand Down
Loading

0 comments on commit 38a41fb

Please sign in to comment.