Worms4Editor/LibW4M/Data/WeaponFactory/WeaponEntry.cs

136 lines
4.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
{
internal class WeaponEntry : SaveDataEntry
{
private int weaponNameId;
public string WeaponName
{
get
{
return this.fileBelongs.w4Save.GetStringById(this.weaponNameId).Value;
}
}
private int weaponType;
private WeaponType detonationType;
private bool homing;
private bool homingAvoidLand;
private bool effectedByWind;
private bool fireOnGround;
private bool poison;
private int retreatTime;
private float wormDamageRadius;
private float wormDamageMagnitude;
private float landDamageRadius;
private float projectileCollisionRadius;
private float push;
private int fuseTime;
private int[] graphicalResourceIds;
private int[] graphicalLocatorIds;
private int launchFX;
private int arielFX;
private int detonationFX;
private int payloadResourceId;
private int projectileLaunchType;
private bool projectilePowersUp;
private int projectileNumClusters;
private float projectileMaxPower;
private float clusterSpread;
private float clusterMaxSpeed;
private XomContainer[] dataContainers;
public WeaponEntry(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
{
}
public override void Delete()
{
throw new NotImplementedException();
}
public override void Load()
{
int[] sWpFc = this.mainContainer.Decompress();
XomContainer top = this.fileBelongs.w4Save.GetContainerById(sWpFc[1]);
XomContainer btm = this.fileBelongs.w4Save.GetContainerById(sWpFc[1]);
// parse top
using(XomStreamReader reader = new XomStreamReader(new MemoryStream(top.GetData())))
{
this.weaponNameId = XomCompressor.DecompressInt(reader.ReadInt32());
reader.Skip(1);
this.detonationType = (WeaponType)reader.ReadInt32();
reader.Skip(1);
this.homing = (reader.ReadByte() == 0x01);
this.homingAvoidLand = (reader.ReadByte() == 0x01);
this.effectedByWind = (reader.ReadByte() == 0x01);
this.fireOnGround = (reader.ReadByte() == 0x01);
this.poison = (reader.ReadByte() == 0x01);
this.retreatTime = reader.ReadInt32();
this.wormDamageRadius = reader.ReadFloat();
this.wormDamageMagnitude = reader.ReadFloat();
this.landDamageRadius = reader.ReadFloat();
this.projectileCollisionRadius = reader.ReadFloat();
this.push = reader.ReadFloat();
this.fuseTime = reader.ReadInt32();
// read GraphicalResourceIds
int totalGraphicalResourceIds = reader.ReadCompressedInt();
this.graphicalResourceIds = new int[totalGraphicalResourceIds];
for (int i = 0; i < totalGraphicalResourceIds; i++) this.graphicalResourceIds[i] = reader.ReadCompressedInt();
// read GraphicalLocatorIds
int totalGraphicalLocatorIds = reader.ReadCompressedInt();
this.graphicalLocatorIds = new int[totalGraphicalLocatorIds];
for (int i = 0; i < totalGraphicalLocatorIds; i++) this.graphicalLocatorIds[i] = reader.ReadCompressedInt();
this.launchFX = reader.ReadCompressedInt();
this.arielFX = reader.ReadCompressedInt();
this.detonationFX = reader.ReadCompressedInt();
this.payloadResourceId = reader.ReadInt32();
this.projectileLaunchType = reader.ReadInt32();
this.projectilePowersUp = (reader.ReadByte() == 0x01);
this.projectileNumClusters = reader.ReadInt32();
this.projectileMaxPower = reader.ReadFloat();
this.clusterSpread = reader.ReadFloat();
this.clusterMaxSpeed = reader.ReadFloat();
}
// parse btm
}
public override void Save()
{
throw new NotImplementedException();
}
}
}