47 lines
1.5 KiB
C#
47 lines
1.5 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 WeaponContainer Weapon;
|
|
public WeaponContainer Cluster;
|
|
|
|
internal XomContainer weaponContainer;
|
|
internal XomContainer clusterContainer;
|
|
|
|
public WeaponStore(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
|
|
{
|
|
this.Load();
|
|
}
|
|
public override void Load()
|
|
{
|
|
int[] weaponStore = this.mainContainer.Decompress();
|
|
this.weaponContainer = this.fileBelongs.xomFile.GetContainerById(weaponStore[1]);
|
|
this.clusterContainer = this.fileBelongs.xomFile.GetContainerById(weaponStore[2]);
|
|
|
|
this.Weapon = new WeaponContainer(this.weaponContainer.GetData(), this.fileBelongs);
|
|
this.Cluster = new WeaponContainer(this.clusterContainer.GetData(), this.fileBelongs);
|
|
}
|
|
|
|
public override void Save()
|
|
{
|
|
this.weaponContainer.SetData(this.Weapon.serialize());
|
|
this.clusterContainer.SetData(this.Cluster.serialize());
|
|
|
|
int[] weaponStore = this.mainContainer.Decompress();
|
|
weaponStore[1] = this.weaponContainer.Id;
|
|
weaponStore[2] = this.clusterContainer.Id;
|
|
this.mainContainer.CompressAndUpdate(weaponStore);
|
|
}
|
|
}
|
|
}
|