2017-09-21 18:33:05 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace CodeWalker.GameFiles
|
|
|
|
|
{
|
|
|
|
|
public class YbnFile : GameFile, PackedFile
|
|
|
|
|
{
|
|
|
|
|
public Bounds Bounds { get; set; }
|
|
|
|
|
|
2020-01-03 19:50:23 +08:00
|
|
|
|
|
|
|
|
|
//used by the editor:
|
|
|
|
|
public bool HasChanged { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
|
2017-09-21 18:33:05 +08:00
|
|
|
|
public YbnFile() : base(null, GameFileType.Ybn)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public YbnFile(RpfFileEntry entry) : base(entry, GameFileType.Ybn)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-03 19:50:23 +08:00
|
|
|
|
public void Load(byte[] data)
|
|
|
|
|
{
|
|
|
|
|
//direct load from a raw, compressed ybn file
|
|
|
|
|
|
|
|
|
|
RpfFile.LoadResourceFile(this, data, 43);
|
|
|
|
|
|
|
|
|
|
Loaded = true;
|
|
|
|
|
}
|
2017-09-21 18:33:05 +08:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bounds = rd.ReadBlock<Bounds>();
|
|
|
|
|
|
2020-01-03 19:50:23 +08:00
|
|
|
|
Bounds.OwnerYbn = this;
|
2017-09-21 18:33:05 +08:00
|
|
|
|
Bounds.OwnerName = entry.Name;
|
|
|
|
|
|
|
|
|
|
Loaded = true;
|
|
|
|
|
}
|
2019-01-27 18:50:24 +08:00
|
|
|
|
|
|
|
|
|
public byte[] Save()
|
|
|
|
|
{
|
|
|
|
|
byte[] data = ResourceBuilder.Build(Bounds, 43); //ybn is type/version 43...
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-06 19:17:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool RemoveBounds(Bounds b)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
public bool RemovePoly(BoundPolygon p)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-01-07 17:51:53 +08:00
|
|
|
|
public bool RemoveVertex(BoundVertex v)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-01-06 19:17:51 +08:00
|
|
|
|
|
2017-09-21 18:33:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|