62 lines
2.1 KiB
C#
62 lines
2.1 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 : SaveDataCollective
|
|
{
|
|
|
|
public WeaponsCollective(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
|
|
{
|
|
}
|
|
internal WeaponData? findWeaponWithContainerUuid(string uuid)
|
|
{
|
|
for (int i = 0; i < this.Length; i++)
|
|
{
|
|
WeaponStore weaponStore = this[i] as WeaponStore;
|
|
if (weaponStore is null) continue;
|
|
|
|
if (weaponStore.Weapon.mainContainer.Uuid.Equals(uuid, StringComparison.InvariantCultureIgnoreCase)) return weaponStore.Weapon;
|
|
else if (weaponStore.Cluster.mainContainer.Uuid.Equals(uuid, StringComparison.InvariantCultureIgnoreCase)) return weaponStore.Cluster;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public override void Create()
|
|
{
|
|
WeaponStore store = new WeaponStore(this.fileBelongs, this.fileBelongs.CreateContainer("StoreWeaponFactory"), false);
|
|
this.collectiveEntries.Add(store);
|
|
}
|
|
|
|
public override void Load()
|
|
{
|
|
int[] collective = mainContainer.Decompress();
|
|
for (int i = 0; i < collective[0]; i++)
|
|
{
|
|
WeaponStore store = new WeaponStore(this.fileBelongs, this.fileBelongs.LookupContainerById(collective[i + 1]));
|
|
base.collectiveEntries.Add(store);
|
|
}
|
|
}
|
|
|
|
public override void Save()
|
|
{
|
|
int len = this.Length;
|
|
int[] collective = new int[len+1];
|
|
collective[0] = len;
|
|
for (int i = 0; i < len; i++)
|
|
{
|
|
WeaponStore store = collectiveEntries[i] as WeaponStore;
|
|
if (store is null) continue;
|
|
|
|
store.Save();
|
|
collective[i + 1] = store.mainContainer.Id;
|
|
}
|
|
mainContainer.CompressAndUpdate(collective);
|
|
}
|
|
}
|
|
}
|