Skip to content

Commit

Permalink
Merge pull request #116 from cyb3rpsych0s1s/fix/biomon-restrictions
Browse files Browse the repository at this point in the history
Additional Biomon restriction
  • Loading branch information
Roms1383 authored Apr 13, 2024
2 parents cb8fecb + fd0a1fc commit fce4108
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/Addicted/ui/BiomonitorController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum BiomonitorRestrictions {
InRadialWheel = 2,
InQuickHackPanel = 3,
InPhotoMode = 4,
InMission = 5,
}

public class BiomonitorController extends inkGameController {
Expand Down Expand Up @@ -159,6 +160,7 @@ public class BiomonitorController extends inkGameController {
private let travelListener: ref<CallbackHandle>;
private let deathListener: ref<CallbackHandle>;
private let interactionsListener: ref<CallbackHandle>;
private let safeAreaListener: ref<CallbackHandle>;
protected cb func OnInitialize() {
E(s"on initialize controller");
Expand Down Expand Up @@ -363,6 +365,11 @@ public class BiomonitorController extends inkGameController {
if IsDefined(interactions) {
this.interactionsListener = interactions.RegisterListenerVariant(definitions.UIInteractions.VisualizersInfo, this, n"OnVisualizersInfo");
}
let safe: ref<IBlackboard> = system.Get(definitions.PlayerStateMachine);
if IsDefined(safe) {
this.safeAreaListener = interactions.RegisterListenerInt(definitions.PlayerStateMachine.Zones, this, n"OnZone");
}
}
protected func UnregisterListeners() -> Void {
let system: ref<BlackboardSystem> = this.GetBlackboardSystem();
Expand Down Expand Up @@ -415,6 +422,11 @@ public class BiomonitorController extends inkGameController {
interactions.UnregisterListenerVariant(definitions.UIInteractions.VisualizersInfo, this.interactionsListener);
this.interactionsListener = null;
}
let safe: ref<IBlackboard> = system.Get(definitions.PlayerStateMachine);
if IsDefined(safe) && IsDefined(this.safeAreaListener) {
safe.UnregisterListenerInt(definitions.PlayerStateMachine.Zones, this.safeAreaListener);
}
}
protected cb func OnCrossThresholdEvent(evt: ref<CrossThresholdEvent>) -> Bool {
Expand Down Expand Up @@ -716,6 +728,15 @@ public class BiomonitorController extends inkGameController {
}
}
protected cb func OnZone(value: Int32) -> Bool {
E(s"enter zone: \(ToString(IntEnum<gamePSMZones>(value)))");
let quests = GameInstance.GetQuestsSystem(this.GetPlayerControlledObject().GetGame());
let safe: Bool = value == EnumInt(gamePSMZones.Safe);
let mission = Cast<Bool>(quests.GetFact(n"mq055_active"));
let restricted = safe && mission;
this.UpdateFlag(restricted, BiomonitorRestrictions.InMission);
}
private func UpdateFlag(value: Bool, flag: BiomonitorRestrictions) -> Void {
let current : Bool = Bits.Has(this.flags, EnumInt(flag));
if NotEquals(current, value) {
Expand Down

0 comments on commit fce4108

Please sign in to comment.