Worms4Editor/LibW4M/Data/SaveDataEntry.cs

68 lines
1.7 KiB
C#
Raw Normal View History

2023-01-09 13:18:25 +00:00
using LibXom.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibW4M.Data
{
2023-01-11 09:22:45 +00:00
public abstract class SaveDataEntry
2023-01-09 13:18:25 +00:00
{
2023-03-07 07:49:53 +00:00
private Guid guid = Guid.NewGuid();
2023-01-09 13:18:25 +00:00
internal W4SaveFile fileBelongs;
internal XomContainer mainContainer;
2023-01-12 03:50:02 +00:00
internal int containerId
{
get
{
return mainContainer.Id;
}
}
2023-03-07 07:49:53 +00:00
public string Uuid
2023-01-09 13:18:25 +00:00
{
get
{
return guid.ToString();
}
}
2023-01-12 03:50:02 +00:00
public virtual string FriendlyName
{ get
{
return this.mainContainer.Type.Name;
2023-01-12 03:50:02 +00:00
}
}
2023-03-07 07:49:53 +00:00
public override int GetHashCode()
{
return this.Uuid.GetHashCode();
}
public override bool Equals(object? obj)
{
if (obj is not SaveDataEntry) return false;
return this.Uuid.Equals((obj as SaveDataEntry).Uuid, StringComparison.InvariantCultureIgnoreCase);
}
2023-01-09 13:18:25 +00:00
public abstract void Load();
public abstract void Save();
internal virtual void loadDefaults()
{
//this.Save();
}
2023-03-07 07:49:53 +00:00
public virtual void DeleteEntries()
2023-01-12 03:50:02 +00:00
{
this.mainContainer.Delete();
}
internal SaveDataEntry (W4SaveFile fileBelongs, XomContainer mainContainer, bool load=true)
2023-01-09 13:18:25 +00:00
{
this.fileBelongs = fileBelongs;
this.mainContainer = mainContainer;
2023-01-12 03:50:02 +00:00
if (load)
this.Load();
else
this.loadDefaults();
2023-01-09 13:18:25 +00:00
}
}
}