Skip to content

Commit

Permalink
"Only Allow Specified Engrams" works better with default unlocked eng…
Browse files Browse the repository at this point in the history
…rams.
  • Loading branch information
thommcgrath committed Apr 20, 2024
1 parent 6912f19 commit de9cd28
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 23 deletions.
25 changes: 18 additions & 7 deletions Project/Modules/Game Support/Ark/Configs/EngramControl.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Inherits Ark.ConfigGroup
Var Engrams() As Ark.Engram = Self.Engrams
For Each Engram As Ark.Engram In Engrams
// Get the unlock string from the engram if available, or use the backup if not available.
If (Engram Is Nil) Or Engram.IsDefaultUnlocked Or Project.ContentPackEnabled(Engram.ContentPackId) = False Then
If (Engram Is Nil) Or Project.ContentPackEnabled(Engram.ContentPackId) = False Then
// Don't include default items or items from disabled mods
Continue
End If
Expand All @@ -72,9 +72,10 @@ Inherits Ark.ConfigGroup
Continue
End If

Var DefaultUnlocked As Boolean = Engram.IsDefaultUnlocked
Var EffectivelyHidden As Boolean = Self.EffectivelyHidden(Engram)
Var ExplicitAutoUnlocked As Boolean
If EffectivelyHidden = False Then
If EffectivelyHidden = False And DefaultUnlocked = False Then
If Self.mAutoUnlockAllEngrams = False And Self.mOverrides.HasAttribute(Engram, Self.KeyAutoUnlockLevel) And Self.mOverrides.Value(Engram, Self.KeyAutoUnlockLevel).BooleanValue = True Then
Var Level As Integer
If Self.mOverrides.HasAttribute(Engram, Self.KeyPlayerLevel) And Self.mOverrides.Value(Engram, Self.KeyPlayerLevel).IsNull = False Then
Expand Down Expand Up @@ -106,11 +107,21 @@ Inherits Ark.ConfigGroup
Var EffectivePoints As NullableDouble = Coalesce(Self.RequiredPoints(Engram), OfficialPoints)
Var RemovePrereq As Boolean = If(Self.RemovePrerequisites(Engram) Is Nil, False, Self.RemovePrerequisites(Engram).BooleanValue)

If (EffectiveLevel Is Nil) = False And (EffectivePoints Is Nil) = False And (Whitelisting = True Or EffectiveLevel <> OfficialLevel Or EffectivePoints <> OfficialPoints Or RemovePrereq = True) Then
Arguments.Add("EngramLevelRequirement=" + EffectiveLevel.IntegerValue.ToString)
Arguments.Add("EngramPointsCost=" + EffectivePoints.IntegerValue.ToString)
If RemovePrereq = True Then
Arguments.Add("RemoveEngramPreReq=" + If(RemovePrereq, "True", "False"))
If DefaultUnlocked Then
// 2024-04-20: Default items get unlocked at 1 anyway. Using another value visually changes the unlock page, but it's pointless.
If Whitelisting Then
Arguments.Add("EngramLevelRequirement=1")
Arguments.Add("EngramPointsCost=0")
Else
Continue
End If
Else
If (EffectiveLevel Is Nil) = False And (EffectivePoints Is Nil) = False And (Whitelisting = True Or EffectiveLevel <> OfficialLevel Or EffectivePoints <> OfficialPoints Or RemovePrereq = True) Then
Arguments.Add("EngramLevelRequirement=" + EffectiveLevel.IntegerValue.ToString)
Arguments.Add("EngramPointsCost=" + EffectivePoints.IntegerValue.ToString)
If RemovePrereq = True Then
Arguments.Add("RemoveEngramPreReq=" + If(RemovePrereq, "True", "False"))
End If
End If
End If
End If
Expand Down
25 changes: 18 additions & 7 deletions Project/Modules/Game Support/ArkSA/Configs/EngramControl.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Inherits ArkSA.ConfigGroup
Var Engrams() As ArkSA.Engram = Self.Engrams
For Each Engram As ArkSA.Engram In Engrams
// Get the unlock string from the engram if available, or use the backup if not available.
If (Engram Is Nil) Or Engram.IsDefaultUnlocked Or Project.ContentPackEnabled(Engram.ContentPackId) = False Then
If (Engram Is Nil) Or Project.ContentPackEnabled(Engram.ContentPackId) = False Then
// Don't include default items or items from disabled mods
Continue
End If
Expand All @@ -73,9 +73,10 @@ Inherits ArkSA.ConfigGroup
Continue
End If

Var DefaultUnlocked As Boolean = Engram.IsDefaultUnlocked
Var EffectivelyHidden As Boolean = Self.EffectivelyHidden(Engram)
Var ExplicitAutoUnlocked As Boolean
If EffectivelyHidden = False Then
If EffectivelyHidden = False And DefaultUnlocked = False Then
If Self.mAutoUnlockAllEngrams = False And Self.mOverrides.HasAttribute(Engram, Self.KeyAutoUnlockLevel) And Self.mOverrides.Value(Engram, Self.KeyAutoUnlockLevel).BooleanValue = True Then
Var Level As Integer
If Self.mOverrides.HasAttribute(Engram, Self.KeyPlayerLevel) And Self.mOverrides.Value(Engram, Self.KeyPlayerLevel).IsNull = False Then
Expand Down Expand Up @@ -107,11 +108,21 @@ Inherits ArkSA.ConfigGroup
Var EffectivePoints As NullableDouble = Coalesce(Self.RequiredPoints(Engram), OfficialPoints)
Var RemovePrereq As Boolean = If(Self.RemovePrerequisites(Engram) Is Nil, False, Self.RemovePrerequisites(Engram).BooleanValue)

If (EffectiveLevel Is Nil) = False And (EffectivePoints Is Nil) = False And (Whitelisting = True Or EffectiveLevel <> OfficialLevel Or EffectivePoints <> OfficialPoints Or RemovePrereq = True) Then
Arguments.Add("EngramLevelRequirement=" + EffectiveLevel.IntegerValue.ToString)
Arguments.Add("EngramPointsCost=" + EffectivePoints.IntegerValue.ToString)
If RemovePrereq = True Then
Arguments.Add("RemoveEngramPreReq=" + If(RemovePrereq, "True", "False"))
If DefaultUnlocked Then
// 2024-04-20: Default items get unlocked at 1 anyway. Using another value visually changes the unlock page, but it's pointless.
If Whitelisting Then
Arguments.Add("EngramLevelRequirement=1")
Arguments.Add("EngramPointsCost=0")
Else
Continue
End If
Else
If (EffectiveLevel Is Nil) = False And (EffectivePoints Is Nil) = False And (Whitelisting = True Or EffectiveLevel <> OfficialLevel Or EffectivePoints <> OfficialPoints Or RemovePrereq = True) Then
Arguments.Add("EngramLevelRequirement=" + EffectiveLevel.IntegerValue.ToString)
Arguments.Add("EngramPointsCost=" + EffectivePoints.IntegerValue.ToString)
If RemovePrereq = True Then
Arguments.Add("RemoveEngramPreReq=" + If(RemovePrereq, "True", "False"))
End If
End If
End If
End If
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,11 @@ End

Var IsEnabled As Boolean = Not Config.EffectivelyHidden(Engram)
If Engram.IsDefaultUnlocked Then
Behaviors.Add("Unlocked by default")
If Config.OnlyAllowSpecifiedEngrams And IsEnabled = False Then
Behaviors.Add("Disabled by default")
Else
Behaviors.Add("Unlocked by default")
End If
ElseIf Not IsEnabled Then
Var Hidden As NullableBoolean = Config.Hidden(Engram)
If IsNull(Hidden) Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,14 @@ End
End If

If Engrams.Count > 0 Then
Var DisabledByDefault As Boolean
Var Config As ArkSA.Configs.EngramControl = ArkSA.Configs.EngramControl(Project.ConfigGroup(ArkSA.Configs.NameEngramControl, False))
If (Config Is Nil) = False Then
DisabledByDefault = Config.OnlyAllowSpecifiedEngrams
End If
Var OriginallySingle As Boolean = (Engrams.Count = 1)
For Idx As Integer = Engrams.LastIndex DownTo 0
If Engrams(Idx).IsDefaultUnlocked Then
If Engrams(Idx).IsDefaultUnlocked And DisabledByDefault = False Then
Engrams.RemoveAt(Idx)
End If
Next
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ End
Config = New Ark.Configs.EngramControl
AddWhenFinished = True
End If
Var DisabledByDefault As Boolean = Config.OnlyAllowSpecifiedEngrams

Var Engrams() As Ark.Engram = Beacon.Merge(Config.Engrams, Ark.DataSource.Pool.Get(False).GetEngramEntries("", Self.mProject.ContentPacks, ""))
Self.mEngramCount = Engrams.Count
Expand All @@ -443,6 +444,9 @@ End
End If

If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
Self.Increment()
Continue
End If
Expand All @@ -460,7 +464,11 @@ End
Return
End If

If Engram.IsDefaultUnlocked Or Engram.IsTagged("tek") Then
If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
ElseIf Engram.IsTagged("tek") Then
Self.Increment()
Continue
End If
Expand All @@ -478,6 +486,9 @@ End
End If

If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
Self.Increment()
Continue
End If
Expand All @@ -494,7 +505,11 @@ End
Return
End If

If Engram.IsDefaultUnlocked Or Engram.IsTagged("tek") Then
If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
ElseIf Engram.IsTagged("tek") Then
Self.Increment()
Continue
End If
Expand Down Expand Up @@ -600,6 +615,9 @@ End
End If

If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
Self.Increment()
Continue
End If
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,11 @@ End

Var IsEnabled As Boolean = Not Config.EffectivelyHidden(Engram)
If Engram.IsDefaultUnlocked Then
Behaviors.Add("Unlocked by default")
If Config.OnlyAllowSpecifiedEngrams And IsEnabled = False Then
Behaviors.Add("Disabled by default")
Else
Behaviors.Add("Unlocked by default")
End If
ElseIf Not IsEnabled Then
Var Hidden As NullableBoolean = Config.Hidden(Engram)
If IsNull(Hidden) Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,14 @@ End
End If

If Engrams.Count > 0 Then
Var DisabledByDefault As Boolean
Var Config As ArkSA.Configs.EngramControl = ArkSA.Configs.EngramControl(Project.ConfigGroup(ArkSA.Configs.NameEngramControl, False))
If (Config Is Nil) = False Then
DisabledByDefault = Config.OnlyAllowSpecifiedEngrams
End If
Var OriginallySingle As Boolean = (Engrams.Count = 1)
For Idx As Integer = Engrams.LastIndex DownTo 0
If Engrams(Idx).IsDefaultUnlocked Then
If Engrams(Idx).IsDefaultUnlocked And DisabledByDefault = False Then
Engrams.RemoveAt(Idx)
End If
Next
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ End
Config = New ArkSA.Configs.EngramControl
AddWhenFinished = True
End If
Var DisabledByDefault As Boolean = Config.OnlyAllowSpecifiedEngrams

Var Engrams() As ArkSA.Engram = Beacon.Merge(Config.Engrams, ArkSA.DataSource.Pool.Get(False).GetEngramEntries("", Self.mProject.ContentPacks, ""))
Self.mEngramCount = Engrams.Count
Expand All @@ -443,6 +444,9 @@ End
End If

If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
Self.Increment()
Continue
End If
Expand All @@ -460,7 +464,11 @@ End
Return
End If

If Engram.IsDefaultUnlocked Or Engram.IsTagged("tek") Then
If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
ElseIf Engram.IsTagged("tek") Then
Self.Increment()
Continue
End If
Expand All @@ -478,6 +486,9 @@ End
End If

If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
Self.Increment()
Continue
End If
Expand All @@ -494,7 +505,11 @@ End
Return
End If

If Engram.IsDefaultUnlocked Or Engram.IsTagged("tek") Then
If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
ElseIf Engram.IsTagged("tek") Then
Self.Increment()
Continue
End If
Expand All @@ -511,7 +526,7 @@ End
Return
End If

If Engram.IsDefaultUnlocked OR Engram.ValidForMask(Mask) Then
If Engram.IsDefaultUnlocked Or Engram.ValidForMask(Mask) Then
Self.Increment()
Continue
End If
Expand Down Expand Up @@ -600,6 +615,9 @@ End
End If

If Engram.IsDefaultUnlocked Then
If DisabledByDefault Then
Config.Hidden(Engram) = False
End If
Self.Increment()
Continue
End If
Expand Down

0 comments on commit de9cd28

Please sign in to comment.