forked from keallu/CSL-HideIt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
219 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using com.github.TheCSUser.Shared.Common; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace com.github.TheCSUser.HideItBobby.Features.Decorations | ||
{ | ||
internal abstract class HideDecorations : UpdatableFeatureBase | ||
{ | ||
protected TerrainProperties TerrainProperties => TerrainManager.exists ? TerrainManager.instance.m_properties : null; | ||
|
||
public HideDecorations(IModContext context) : base(context) { } | ||
|
||
public override FeatureFlags Update() | ||
{ | ||
if (IsDisposed || IsError || !IsAvailable || !IsInitialized) return Result(false); | ||
try | ||
{ | ||
var result = OnUpdate(); | ||
return Result(result, true); | ||
} | ||
catch (Exception e) | ||
{ | ||
IncreaseErrorCount(); | ||
Log.Error($"{GetType().Name}.{nameof(OnUpdate)} failed", e); | ||
return Result(false); | ||
} | ||
} | ||
|
||
protected override bool OnEnable() => OnUpdate(); | ||
protected override bool OnDisable() => OnUpdate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using com.github.TheCSUser.HideItBobby.Properties; | ||
using com.github.TheCSUser.HideItBobby.Settings.Providers; | ||
using com.github.TheCSUser.HideItBobby.Settings.SettingsFiles; | ||
using com.github.TheCSUser.HideItBobby.VersionMigrations; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace com.github.TheCSUser.HideItBobby | ||
{ | ||
public sealed partial class Mod | ||
{ | ||
private Provider_Version VersionProvider; | ||
private List<Migration> _migrations; | ||
internal File_Version VersionFile; | ||
|
||
private void InitMigrations() | ||
{ | ||
VersionProvider = new Provider_Version(Context); | ||
|
||
_migrations = new List<Migration> | ||
{ | ||
new Migrate_1_18_to_1_21(Context), | ||
new Migrate_1_20_to_1_21(Context), | ||
new Migrate_1_21_to_1_22(Context), | ||
new Migrate_1_24_to_1_25(Context), | ||
new Migrate_1_28_to_1_28_1(Context), | ||
}; | ||
} | ||
|
||
private void Migrate() | ||
{ | ||
try | ||
{ | ||
VersionFile = VersionProvider.Load(); | ||
if (VersionFile is null || VersionFile.Version < ModProperties.VersionInteger) | ||
{ | ||
foreach (var migration in _migrations) | ||
{ | ||
if (!(migration is null)) migration.Migrate(); | ||
} | ||
|
||
VersionProvider.Save(VersionFile = new File_Version() | ||
{ | ||
Version = ModProperties.VersionInteger | ||
}); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Log.Error($"{nameof(Mod)}.{nameof(Migrate)} failed", e); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.