72 lines
2.3 KiB
C#
72 lines
2.3 KiB
C#
using LibW4M.Data.WeaponFactory;
|
|
using LibXom.Data;
|
|
using LibXom.Streams;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LibW4M.Data.WXFE.UnlockableItem
|
|
{
|
|
public class UnlockableItemData : SaveDataEntry
|
|
{
|
|
public int Type;
|
|
public int State;
|
|
public XomString DescriptionName;
|
|
public int Value;
|
|
public XomString[] UnlockRequirements;
|
|
public bool UnlockRequirementsMet;
|
|
|
|
internal string? nameOverride;
|
|
|
|
public UnlockableItemData(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
|
|
{
|
|
}
|
|
public override string FriendlyName
|
|
{
|
|
get
|
|
{
|
|
if (this.nameOverride is not null) return nameOverride;
|
|
return this.DescriptionName.Value;
|
|
}
|
|
}
|
|
|
|
public override void Load()
|
|
{
|
|
using (XomStreamReader reader = new XomStreamReader(new MemoryStream(this.mainContainer.GetData())))
|
|
{
|
|
reader.Skip(3);
|
|
|
|
this.Type = reader.ReadInt32();
|
|
this.State = reader.ReadInt32();
|
|
this.DescriptionName = this.fileBelongs.LookupStringFromId(reader.ReadCompressedInt());
|
|
this.Value = reader.ReadInt32();
|
|
this.UnlockRequirements = fileBelongs.IntArrayToXomStringArray(reader.ReadCompressedIntArray());
|
|
this.UnlockRequirementsMet = reader.ReadBool();
|
|
}
|
|
}
|
|
|
|
public override void Save()
|
|
{
|
|
using (MemoryStream ms = new MemoryStream())
|
|
{
|
|
using (XomStreamWriter writer = new XomStreamWriter(ms))
|
|
{
|
|
writer.Skip(3);
|
|
|
|
writer.WriteInt32(this.Type);
|
|
writer.WriteInt32(this.State);
|
|
writer.WriteCompressedInt(this.DescriptionName.Id);
|
|
writer.WriteInt32(this.Value);
|
|
writer.WriteCompressedIntArray(this.fileBelongs.XomStringArrayToIntArray(this.UnlockRequirements));
|
|
writer.WriteBool(this.UnlockRequirementsMet);
|
|
|
|
ms.Seek(0x00, SeekOrigin.Begin);
|
|
mainContainer.SetData(ms.ToArray());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|