Skip to content

Commit

Permalink
moved singleplayer and atlas bool setting to ServerSettings class
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Feb 28, 2024
1 parent 07b5b30 commit e7d26a1
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 25 deletions.
6 changes: 1 addition & 5 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3261,8 +3261,6 @@ private void LoadMultipliersFromTestCase(testCases.ExtractionTestCase etc)
{
// set all stat-multipliers from testCase
_creatureCollection.serverMultipliers = etc.serverMultipliers.Copy(true);
_creatureCollection.singlePlayerSettings = etc.singleplayerSettings;
_creatureCollection.AtlasSettings = etc.AtlasSettings;
_creatureCollection.allowMoreThanHundredImprinting = etc.allowMoreThanHundredPercentImprinting;
_creatureCollection.maxWildLevel = etc.maxWildLevel;

Expand Down Expand Up @@ -3293,10 +3291,8 @@ private void tsBtAddAsExtractionTest_Click(object sender, EventArgs e)
etc.levelsDom = GetCurrentDomLevels(false);
etc.levelsWild = GetCurrentWildLevels(false);
etc.ModIDs = _creatureCollection.modIDs?.ToList();
etc.serverMultipliers = _creatureCollection.serverMultipliers;
etc.serverMultipliers = _creatureCollection.serverMultipliers.Copy(true);
etc.Species = speciesSelector1.SelectedSpecies;
etc.singleplayerSettings = _creatureCollection.singlePlayerSettings;
etc.AtlasSettings = _creatureCollection.AtlasSettings;
etc.allowMoreThanHundredPercentImprinting = _creatureCollection.allowMoreThanHundredImprinting;
etc.maxWildLevel = _creatureCollection.maxWildLevel;

Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/importExportGun/ImportExportGun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ internal static bool SetServerMultipliers(CreatureCollection cc, ExportGunServer
cc.serverMultipliers.BabyFoodConsumptionSpeedMultiplier = Math.Round(esm.BabyFoodConsumptionSpeedMultiplier, roundToDigits);
cc.serverMultipliers.AllowSpeedLeveling = esm.AllowSpeedLeveling;
cc.serverMultipliers.AllowFlyerSpeedLeveling = esm.AllowFlyerSpeedLeveling;
cc.singlePlayerSettings = esm.UseSingleplayerSettings;
cc.serverMultipliers.SinglePlayerSettings = esm.UseSingleplayerSettings;
cc.Game = esm.Game;

cc.ServerMultipliersHash = newServerMultipliersHash;
Expand Down
17 changes: 16 additions & 1 deletion ARKBreedingStats/library/CreatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ public CreatureCollection()
[JsonProperty]
public ServerMultipliers serverMultipliersEvents; // this object's statMultipliers are not used

/// <summary>
/// Deprecated setting, remove on 2025-01-01
/// </summary>
[JsonProperty]
public bool singlePlayerSettings;

/// <summary>
/// If true, apply extra multipliers for the game ATLAS.
/// Deprecated setting, remove on 2025-01-01
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool AtlasSettings;
Expand Down Expand Up @@ -481,6 +484,18 @@ private void InitializeProperties(StreamingContext ct)
{
if (tags == null) tags = new List<string>();

// backwards compatibility, remove 10 lines below in 2025-01-01
if (singlePlayerSettings && serverMultipliers != null)
{
serverMultipliers.SinglePlayerSettings = singlePlayerSettings;
singlePlayerSettings = false;
}
if (AtlasSettings && serverMultipliers != null)
{
serverMultipliers.AtlasSettings = AtlasSettings;
AtlasSettings = false;
}

// convert DateTimes to local times
foreach (var tle in timerListEntries)
tle.time = tle.time.ToLocalTime();
Expand Down
12 changes: 6 additions & 6 deletions ARKBreedingStats/multiplierTesting/StatsMultiplierTesting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ private void SetStatMultipliersFromCC()
}
SetIBM(_cc.serverMultipliers.BabyImprintingStatScaleMultiplier);

cbSingleplayerSettings.Checked = _cc.singlePlayerSettings;
CbAtlas.Checked = _cc.AtlasSettings;
cbSingleplayerSettings.Checked = _cc.serverMultipliers.SinglePlayerSettings;
CbAtlas.Checked = _cc.serverMultipliers.AtlasSettings;
CbAllowSpeedLeveling.Checked = _cc.serverMultipliers.AllowSpeedLeveling;
CbAllowFlyerSpeedLeveling.Checked = _cc.serverMultipliers.AllowFlyerSpeedLeveling;

Expand Down Expand Up @@ -325,8 +325,8 @@ internal void CheckIfMultipliersAreEqualToSettings()
if (_cc?.serverMultipliers?.statMultipliers != null)
{
showWarning = _cc.serverMultipliers.BabyImprintingStatScaleMultiplier != (double)nudIBM.Value
|| _cc.singlePlayerSettings != cbSingleplayerSettings.Checked
|| _cc.AtlasSettings != CbAtlas.Checked
|| _cc.serverMultipliers.SinglePlayerSettings != cbSingleplayerSettings.Checked
|| _cc.serverMultipliers.AtlasSettings != CbAtlas.Checked
|| _cc.serverMultipliers.AllowSpeedLeveling != CbAllowSpeedLeveling.Checked
|| _cc.serverMultipliers.AllowFlyerSpeedLeveling != CbAllowFlyerSpeedLeveling.Checked;
if (!showWarning)
Expand Down Expand Up @@ -426,8 +426,8 @@ private void copyStatMultipliersToSettingsToolStripMenuItem_Click(object sender,
_statControls[s].SetStatMultiplierWithoutChangingInputs(_statControls[s].StatMultipliers);
}
_cc.serverMultipliers.BabyImprintingStatScaleMultiplier = (double)nudIBM.Value;
_cc.singlePlayerSettings = cbSingleplayerSettings.Checked;
_cc.AtlasSettings = CbAtlas.Checked;
_cc.serverMultipliers.SinglePlayerSettings = cbSingleplayerSettings.Checked;
_cc.serverMultipliers.AtlasSettings = CbAtlas.Checked;
_cc.serverMultipliers.AllowSpeedLeveling = CbAllowSpeedLeveling.Checked;
_cc.serverMultipliers.AllowFlyerSpeedLeveling = CbAllowFlyerSpeedLeveling.Checked;
OnApplyMultipliers?.Invoke();
Expand Down
4 changes: 2 additions & 2 deletions ARKBreedingStats/oldLibraryFormat/FormatConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ public static void TransferParameters(CreatureCollectionOld ccOld, CreatureColle
ccNew.ownerList = ccOld.ownerList;
ccNew.players = ccOld.players;
ccNew.serverList = ccOld.serverList;
ccNew.singlePlayerSettings = ccOld.singlePlayerSettings;
ccNew.tags = ccOld.tags;
ccNew.tagsExclude = ccOld.tagsExclude;
ccNew.tagsInclude = ccOld.tagsInclude;
Expand Down Expand Up @@ -271,7 +270,8 @@ public static void TransferParameters(CreatureCollectionOld ccOld, CreatureColle
EggHatchSpeedMultiplier = ccOld.EggHatchSpeedMultiplier,
BabyMatureSpeedMultiplier = ccOld.BabyMatureSpeedMultiplier,
BabyFoodConsumptionSpeedMultiplier = ccOld.BabyFoodConsumptionSpeedMultiplier,
statMultipliers = ccOld.multipliers // was converted to 12-stats before
statMultipliers = ccOld.multipliers, // was converted to 12-stats before
SinglePlayerSettings = ccOld.singlePlayerSettings
};

ccNew.serverMultipliersEvents = new ServerMultipliers
Expand Down
8 changes: 4 additions & 4 deletions ARKBreedingStats/settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ private void LoadSettings(CreatureCollection cc)
else _multSetter[s].Multipliers = null;
}
}
cbSingleplayerSettings.Checked = cc.singlePlayerSettings;
CbAtlasSettings.Checked = _cc.AtlasSettings;
cbSingleplayerSettings.Checked = cc.serverMultipliers?.SinglePlayerSettings == true;
CbAtlasSettings.Checked = _cc.serverMultipliers?.AtlasSettings == true;
if (_cc.Game == Ark.Asa)
{
RbGameAsa.Checked = true;
Expand Down Expand Up @@ -501,8 +501,8 @@ private void SaveSettings()
_cc.serverMultipliers.statMultipliers[Stats.Torpidity][Stats.IndexLevelWild] = 1;
}

_cc.singlePlayerSettings = cbSingleplayerSettings.Checked;
_cc.AtlasSettings = CbAtlasSettings.Checked;
_cc.serverMultipliers.SinglePlayerSettings = cbSingleplayerSettings.Checked;
_cc.serverMultipliers.AtlasSettings = CbAtlasSettings.Checked;
_cc.Game = RbGameAsa.Checked ? Ark.Asa : Ark.Ase;
Properties.Settings.Default.NewLibraryGame = RbNewLibraryGameAse.Checked ? Ark.Game.Ase
: RbNewLibraryGameAsa.Checked ? Ark.Game.Asa
Expand Down
1 change: 0 additions & 1 deletion ARKBreedingStats/testCases/ExtractionTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class ExtractionTestCase
public double tamingEff;
public double imprintingBonus;
public ServerMultipliers serverMultipliers;
public bool singleplayerSettings;
public bool AtlasSettings;
public int maxWildLevel;
public bool allowMoreThanHundredPercentImprinting;
Expand Down
13 changes: 12 additions & 1 deletion ARKBreedingStats/values/ServerMultipliers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public class ServerMultipliers
[JsonProperty]
public bool AllowFlyerSpeedLeveling { get; set; }

[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool SinglePlayerSettings { get; set; }

/// <summary>
/// If true, apply extra multipliers for the game ATLAS.
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool AtlasSettings { get; set; }

/// <summary>
/// Fix any null values
/// </summary>
Expand Down Expand Up @@ -88,7 +97,9 @@ public ServerMultipliers Copy(bool withStatMultipliers)
BabyCuddleIntervalMultiplier = BabyCuddleIntervalMultiplier,
BabyImprintingStatScaleMultiplier = BabyImprintingStatScaleMultiplier,
BabyImprintAmountMultiplier = BabyImprintAmountMultiplier,
AllowFlyerSpeedLeveling = AllowFlyerSpeedLeveling
AllowFlyerSpeedLeveling = AllowFlyerSpeedLeveling,
SinglePlayerSettings = SinglePlayerSettings,
AtlasSettings = AtlasSettings
};

if (withStatMultipliers && statMultipliers != null)
Expand Down
7 changes: 3 additions & 4 deletions ARKBreedingStats/values/Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@ public void ApplyMultipliers(CreatureCollection cc, bool eventMultipliers = fals

ServerMultipliers singlePlayerServerMultipliers = null;

if (cc.singlePlayerSettings)
if (currentServerMultipliers.SinglePlayerSettings)
{
// The singleplayer multipliers are saved as a regular multiplierpreset, but they work differently
// The singleplayer multipliers are saved as a regular multiplier preset, but they work differently
// in the way they are multiplied on existing multipliers and won't work on their own.
// The preset name "singleplayer" should only be used for this purpose.
singlePlayerServerMultipliers = serverMultipliersPresets.GetPreset(ServerMultipliersPresets.Singleplayer);
Expand Down Expand Up @@ -592,8 +592,7 @@ double GetRawStatValue(int statIndex, int statValueTypeIndex, bool customOverrid
sp.SetCustomImprintingMultipliers(imprintingMultiplierOverrides);

// ATLAS multipliers

if (cc.AtlasSettings)
if (cc.serverMultipliers.AtlasSettings)
{
sp.stats[Stats.Health].BaseValue *= 1.25;
sp.stats[Stats.Health].IncPerTamedLevel *= 1.5;
Expand Down

0 comments on commit e7d26a1

Please sign in to comment.