Skip to content

Commit

Permalink
⚰️ remove modsettings dependency
Browse files Browse the repository at this point in the history
mod difficulty now reflects game's
  • Loading branch information
Roms1383 committed Oct 27, 2024
1 parent c874d4b commit 2470d95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 40 deletions.
13 changes: 0 additions & 13 deletions scripts/Addicted/Config.reds
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
// inspired from DJ_Kovrik

enum AddictedMode {
Normal = 0,
Hard = 1,
}

public class AddictedConfig {
@runtimeProperty("ModSettings.mod", "Addicted")
@runtimeProperty("ModSettings.displayName", "Mod-Addicted-Mode")
@runtimeProperty("ModSettings.displayValues.Normal", "Mod-Addicted-Mode-Normal")
@runtimeProperty("ModSettings.displayValues.Hard", "Mod-Addicted-Mode-Hard")
public let mode: AddictedMode = AddictedMode.Normal;
}

// Replace false with true to show full debug logs in CET console
public static func ShowDebugLogsAddicted() -> Bool = false
32 changes: 5 additions & 27 deletions scripts/Addicted/System.reds
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public class AddictedSystem extends ScriptableSystem {
private let timeSystem: ref<TimeSystem>;
private let callbackSystem: ref<CallbackSystem>;
private let config: ref<AddictedConfig>;
private let onoManager: ref<AudioManager>;
private let stimulantManager: ref<StimulantManager>;
private let blacklaceManager: ref<BlackLaceManager>;
Expand Down Expand Up @@ -113,7 +111,6 @@ public class AddictedSystem extends ScriptableSystem {
this.RefreshStats(this.player);
this.RegisterListeners(this.player);
this.RefreshConfig();
} else { F(s"no player found!"); }
}
Expand All @@ -131,15 +128,11 @@ public class AddictedSystem extends ScriptableSystem {
if !IsDefined(this.consumptions) {
this.consumptions = new Consumptions();
}
OnAddictedPostAttach(this);
}
private func OnDetach() -> Void {
E(s"on detach system");
this.UnregisterListeners(this.player);
OnAddictedPostDetach(this);
}
private func OnRestored(saveVersion: Int32, gameVersion: Int32) -> Void {
Expand All @@ -150,15 +143,6 @@ public class AddictedSystem extends ScriptableSystem {
private cb func OnPreSave(event: ref<GameSessionEvent>) {
this.ShrinkDoses();
}
public func RefreshConfig() -> Void {
E(s"refresh config");
this.config = new AddictedConfig();
}
public func OnModSettingsChange() -> Void {
this.RefreshConfig();
}
public final static func GetInstance(gameInstance: GameInstance) -> ref<AddictedSystem> {
let container = GameInstance.GetScriptableSystemsContainer(gameInstance);
Expand Down Expand Up @@ -535,7 +519,11 @@ public class AddictedSystem extends ScriptableSystem {
GameInstance.GetUISystem(this.player.GetGame()).QueueEvent(event);
}
public func IsHard() -> Bool { return Equals(EnumInt(this.config.mode), EnumInt(AddictedMode.Hard)); }
public func IsHard() -> Bool {
let difficulty = GameInstance.GetStatsDataSystem(this.GetGameInstance()).GetDifficulty();
return Equals(difficulty, gameDifficulty.Hard)
|| Equals(difficulty, gameDifficulty.VeryHard);
}
public func UnderInfluence(id: TweakDBID) -> Bool {
let effect = StatusEffectHelper.GetStatusEffectByID(this.player, id);
Expand Down Expand Up @@ -714,16 +702,6 @@ public class AddictedSystem extends ScriptableSystem {
}
}

@if(!ModuleExists("ModSettingsModule"))
private func OnAddictedPostAttach(_: ref<AddictedSystem>) -> Void {}
@if(ModuleExists("ModSettingsModule"))
private func OnAddictedPostAttach(system: ref<AddictedSystem>) -> Void { ModSettings.RegisterListenerToModifications(system); }

@if(!ModuleExists("ModSettingsModule"))
private func OnAddictedPostDetach(_: ref<AddictedSystem>) -> Void {}
@if(ModuleExists("ModSettingsModule"))
private func OnAddictedPostDetach(system: ref<AddictedSystem>) -> Void { ModSettings.UnregisterListenerToModifications(system); }

struct Consumed {
let amount: Int32;
let hint: Bool;
Expand Down

0 comments on commit 2470d95

Please sign in to comment.