Skip to content

Commit

Permalink
Merge pull request #117 from cyb3rpsych0s1s/fix/biomon-restrictions
Browse files Browse the repository at this point in the history
Second attempt: additional biomon restrictions
  • Loading branch information
Roms1383 authored Apr 14, 2024
2 parents fce4108 + 27f8980 commit 80eff66
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion scripts/Addicted/ui/BiomonitorController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ public class BiomonitorController extends inkGameController {
private let interactionsListener: ref<CallbackHandle>;
private let safeAreaListener: ref<CallbackHandle>;
private let journal: ref<JournalManager>;
protected cb func OnInitialize() {
E(s"on initialize controller");
Expand Down Expand Up @@ -370,6 +372,11 @@ public class BiomonitorController extends inkGameController {
if IsDefined(safe) {
this.safeAreaListener = interactions.RegisterListenerInt(definitions.PlayerStateMachine.Zones, this, n"OnZone");
}
this.journal = GameInstance.GetJournalManager(this.GetPlayerControlledObject().GetGame());
if IsDefined(this.journal) {
this.journal.RegisterScriptCallback(this, n"OnJournal", gameJournalListenerType.State);
}
}
protected func UnregisterListeners() -> Void {
let system: ref<BlackboardSystem> = this.GetBlackboardSystem();
Expand Down Expand Up @@ -427,6 +434,11 @@ public class BiomonitorController extends inkGameController {
if IsDefined(safe) && IsDefined(this.safeAreaListener) {
safe.UnregisterListenerInt(definitions.PlayerStateMachine.Zones, this.safeAreaListener);
}
if IsDefined(this.journal) {
this.journal.UnregisterScriptCallback(this, n"OnJournal");
this.journal = null;
}
}
protected cb func OnCrossThresholdEvent(evt: ref<CrossThresholdEvent>) -> Bool {
Expand Down Expand Up @@ -732,11 +744,20 @@ public class BiomonitorController extends inkGameController {
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 mission = Cast<Bool>(quests.GetFact(n"mq055_apt_interactions_off"));
let restricted = safe && mission;
this.UpdateFlag(restricted, BiomonitorRestrictions.InMission);
}
protected cb func OnJournal(hash: Uint32, className: CName, notifyOption: JournalNotifyOption, changeType: JournalChangeType) -> Bool {
let entry: wref<JournalEntry> = this.journal.GetEntry(hash);
let state: gameJournalEntryState = this.journal.GetEntryState(entry);
let ty: gameJournalQuestType = this.journal.GetQuestType(entry);
if Equals(ty, gameJournalQuestType.ApartmentQuest) {
E(s"apartment quest: id \(entry.GetId()) / state \(ToString(state)) / notify option \(ToString(notifyOption))");
}
}
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 80eff66

Please sign in to comment.