2017-09-21 18:33:05 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace CodeWalker.GameFiles
|
|
|
|
|
{
|
|
|
|
|
public class YwrFile : GameFile, PackedFile
|
|
|
|
|
{
|
|
|
|
|
public WaypointRecordList Waypoints { get; set; }
|
|
|
|
|
|
|
|
|
|
public YwrFile() : base(null, GameFileType.Ywr)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public YwrFile(RpfFileEntry entry) : base(entry, GameFileType.Ywr)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Load(byte[] data, RpfFileEntry entry)
|
|
|
|
|
{
|
|
|
|
|
Name = entry.Name;
|
|
|
|
|
RpfFileEntry = entry;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;
|
|
|
|
|
if (resentry == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("File entry wasn't a resource! (is it binary data?)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ResourceDataReader rd = new ResourceDataReader(resentry, data);
|
|
|
|
|
|
|
|
|
|
//MemoryUsage = 0;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Waypoints = rd.ReadBlock<WaypointRecordList>();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
string err = ex.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Loaded = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 21:35:23 +08:00
|
|
|
|
public byte[] Save()
|
|
|
|
|
{
|
|
|
|
|
byte[] data = ResourceBuilder.Build(Waypoints, 1); //ywr is type/version 1...
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 18:33:05 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|