+
+
@( HasSaveFile ? "Сохранение есть" : "Нет сохранения" )
+
+
+ @if ( HasSaveFile )
+ {
+
+ }
+
+
+
+ @if ( HasSaveFile )
+ {
+
+ }
+
@code {
@@ -107,6 +222,10 @@
private float ReloadProgress { get; set; } = 0f;
private int TotalInInventory { get; set; } = 0;
private bool HasWeapon { get; set; } = false;
+
+ // Переменные для системы сохранения
+ private bool HasSaveFile { get; set; } = false;
+ private TimeSince _lastCheck = 0f;
protected override void OnUpdate()
{
@@ -122,6 +241,47 @@
// Проверяем, есть ли оружие в руках (если MaxAmmo > 0, значит есть оружие)
HasWeapon = MaxAmmo > 0;
+
+ // Проверяем наличие файла сохранения каждые 2 секунды
+ if ( _lastCheck > 2f )
+ {
+ CheckSaveFile();
+ _lastCheck = 0f;
+ }
+ }
+
+ protected override void OnStart()
+ {
+ CheckSaveFile();
+ }
+
+ private void CheckSaveFile()
+ {
+ HasSaveFile = Sasalka.InventorySaveSystem.HasSaveFile();
+ }
+
+ private void SaveInventory()
+ {
+ if ( Dedugan.Local?.Inventory != null )
+ {
+ Sasalka.InventorySaveSystem.SaveInventory( Dedugan.Local.Inventory );
+ CheckSaveFile();
+ }
+ }
+
+ private void LoadInventory()
+ {
+ if ( Dedugan.Local?.Inventory != null )
+ {
+ Sasalka.InventorySaveSystem.LoadInventory( Dedugan.Local.Inventory );
+ CheckSaveFile();
+ }
+ }
+
+ private void ClearSave()
+ {
+ Sasalka.InventorySaveSystem.DeleteSaveFile();
+ CheckSaveFile();
}
protected override int BuildHash()
@@ -136,8 +296,8 @@
hash.Add( IsReloading );
hash.Add( ReloadProgress );
hash.Add( HasWeapon );
+ hash.Add( HasSaveFile );
return hash.ToHashCode();
}
-
}