74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using LibXom.Data;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LibW4M.Data.WeaponFactory
|
|
{
|
|
public class WeaponsCollective : SaveDataEntry
|
|
{
|
|
private List<WeaponStore> weaponCollective;
|
|
|
|
public WeaponStore this[int i]
|
|
{
|
|
get
|
|
{
|
|
return weaponCollective[i];
|
|
}
|
|
set
|
|
{
|
|
weaponCollective[i] = value;
|
|
}
|
|
}
|
|
public int Length
|
|
{
|
|
get
|
|
{
|
|
return weaponCollective.Count;
|
|
}
|
|
}
|
|
public WeaponsCollective(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
|
|
{
|
|
this.weaponCollective = new List<WeaponStore>();
|
|
this.Load();
|
|
}
|
|
|
|
public void Delete(WeaponStore store)
|
|
{
|
|
for(int i = 0; i < this.Length; i++)
|
|
{
|
|
WeaponStore weaponStore = this[i];
|
|
if(weaponStore.uuid.Equals(store.uuid, StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
weaponCollective.RemoveAt(i);
|
|
weaponStore.weaponContainer.Delete();
|
|
weaponStore.clusterContainer.Delete();
|
|
weaponStore.mainContainer.Delete();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Load()
|
|
{
|
|
int[] collective = mainContainer.Decompress();
|
|
for (int i = 0; i < collective[0]; i++) weaponCollective.Add(new WeaponStore(this.fileBelongs, this.fileBelongs.xomFile.GetContainerById(collective[i + 1])));
|
|
}
|
|
|
|
public override void Save()
|
|
{
|
|
int[] collective = mainContainer.Decompress();
|
|
collective[0] = weaponCollective.Count;
|
|
for (int i = 0; i < weaponCollective.Count; i++)
|
|
{
|
|
WeaponStore store = weaponCollective[i];
|
|
store.Save();
|
|
collective[i + 1] = store.mainContainer.Id;
|
|
}
|
|
mainContainer.CompressAndUpdate(collective);
|
|
}
|
|
}
|
|
}
|