80 lines
2.3 KiB
C#
80 lines
2.3 KiB
C#
using LibW4M.Data.Teams;
|
|
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.LookupContainerById(weaponStore[1]);
|
|
this.clusterContainer = this.fileBelongs.LookupContainerById(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);
|
|
}
|
|
|
|
|
|
|
|
public override void DeleteEntries()
|
|
{
|
|
bool clusterUsed = false;
|
|
bool weaponUsed = false;
|
|
|
|
foreach (TeamData team in fileBelongs.TeamDataColective)
|
|
{
|
|
if (team.SecretWeapon.Equals(this.Weapon)) weaponUsed = true;
|
|
if (team.SecretWeaponCluster.Equals(this.Cluster)) clusterUsed = true;
|
|
}
|
|
|
|
if (!clusterUsed) { this.Cluster.DeleteEntries(); }
|
|
if (!weaponUsed) { this.Weapon.DeleteEntries(); }
|
|
|
|
base.DeleteEntries();
|
|
}
|
|
|
|
public override string FriendlyName
|
|
{
|
|
get
|
|
{
|
|
return Weapon.Name.Value;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|