mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-07-07 18:31:23 +08:00
49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using CodeWalker.GameFiles;
|
|
using SharpDX;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CodeWalker.World
|
|
{
|
|
[TypeConverter(typeof(ExpandableObjectConverter))] public class Weapon
|
|
{
|
|
public string Name { get; set; } = string.Empty;
|
|
public MetaHash NameHash { get; set; } = 0;//base weapon name hash
|
|
public MetaHash ModelHash { get; set; } = 0;//weapon model name hash, can be _hi
|
|
|
|
public YmapEntityDef RenderEntity = new YmapEntityDef(); //placeholder entity object for rendering
|
|
|
|
public Vector3 Position { get; set; } = Vector3.Zero;
|
|
public Quaternion Rotation { get; set; } = Quaternion.Identity;
|
|
|
|
|
|
public void Init(string name, GameFileCache gfc, bool hidef = true)
|
|
{
|
|
Name = name;
|
|
var modelnamel = name.ToLowerInvariant();
|
|
MetaHash modelhash = JenkHash.GenHash(modelnamel);
|
|
MetaHash modelhashhi = JenkHash.GenHash(modelnamel + "_hi");
|
|
var ydrhash = hidef ? modelhashhi : modelhash;
|
|
|
|
NameHash = modelhash;
|
|
ModelHash = ydrhash;
|
|
|
|
|
|
UpdateEntity();
|
|
}
|
|
|
|
|
|
public void UpdateEntity()
|
|
{
|
|
RenderEntity.SetPosition(Position);
|
|
RenderEntity.SetOrientation(Rotation);
|
|
}
|
|
|
|
}
|
|
}
|