67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using LibXom.Data;
|
|
using LibXom.Streams;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LibW4M.Data.WeaponFactory
|
|
{
|
|
public class WeaponStore : SaveDataEntry
|
|
{
|
|
|
|
public WeaponData Weapon;
|
|
public WeaponData Cluster;
|
|
public bool StockWeapon;
|
|
|
|
internal XomContainer weaponContainer;
|
|
internal XomContainer clusterContainer;
|
|
|
|
public WeaponStore(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
|
|
{
|
|
|
|
}
|
|
|
|
public override void Load()
|
|
{
|
|
int[] weaponStore = this.mainContainer.Decompress();
|
|
this.StockWeapon = (weaponStore[0] == 1);
|
|
this.weaponContainer = this.fileBelongs.xomFile.GetContainerById(weaponStore[1]);
|
|
this.clusterContainer = this.fileBelongs.xomFile.GetContainerById(weaponStore[2]);
|
|
|
|
this.Weapon = new WeaponData(this.fileBelongs, this.weaponContainer);
|
|
this.Cluster = new WeaponData(this.fileBelongs, this.clusterContainer);
|
|
}
|
|
|
|
public override void Save()
|
|
{
|
|
this.Weapon.Save();
|
|
this.Cluster.Save();
|
|
|
|
int[] weaponStore = this.mainContainer.Decompress();
|
|
weaponStore[0] = (this.StockWeapon ? 1 : 0);
|
|
weaponStore[1] = this.weaponContainer.Id;
|
|
weaponStore[2] = this.clusterContainer.Id;
|
|
this.mainContainer.CompressAndUpdate(weaponStore);
|
|
}
|
|
|
|
internal override void delete()
|
|
{
|
|
this.weaponContainer.Delete();
|
|
this.clusterContainer.Delete();
|
|
this.mainContainer.Delete();
|
|
}
|
|
|
|
public override string FriendlyName
|
|
{
|
|
get
|
|
{
|
|
return Weapon.Name.Value;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|