feat: start adding the data structure for actor spawning

This commit is contained in:
Anna 2024-07-22 02:44:22 -04:00
parent ed679ae141
commit fd0ca7f445
Signed by: anna
GPG Key ID: D0943384CD9F87D1
2 changed files with 55 additions and 14 deletions

View File

@ -20,6 +20,9 @@ internal class Message {
public int NegativeVotes { get; set; }
public int UserVote { get; set; }
public uint? Emote { get; set; }
public byte[]? Customise { get; set; }
public int Glyph { get; set; }
internal Vector3 Position => new(this.X, this.Y, this.Z);
@ -45,6 +48,9 @@ internal class MessageWithTerritory {
public int NegativeVotes { get; init; }
public int UserVote { get; set; }
public uint? Emote { get; set; }
public byte[]? Customise { get; set; }
public int Glyph { get; set; }
public bool IsHidden { get; set; }
@ -62,12 +68,56 @@ internal class MessageWithTerritory {
PositiveVotes = message.PositiveVotes,
NegativeVotes = message.NegativeVotes,
UserVote = message.UserVote,
Emote = message.Emote,
Customise = message.Customise,
Glyph = message.Glyph,
IsHidden = false,
};
}
}
[Serializable]
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
internal class EmoteData {
public uint Id { get; set; }
public byte[] Customise { get; set; }
public EquipmentData[] Equipment { get; set; }
public WeaponData[] Weapon { get; set; }
public bool HatHidden { get; set; }
public bool VisorToggled { get; set; }
public bool WeaponHidden { get; set; }
}
[Serializable]
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
internal class EquipmentData {
public ushort Id { get; set; }
public byte Variant { get; set; }
public byte Stain0 { get; set; }
public byte Stain1 { get; set; }
public ulong Value { get; set; }
}
[Serializable]
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
internal class WeaponData {
public WeaponModelId ModelId { get; set; }
public byte State { get; set; }
public ushort Flags1 { get; set; }
public byte Flags2 { get; set; }
}
[Serializable]
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
internal class WeaponModelId {
public ushort Id { get; set; }
public ushort Type { get; set; }
public ushort Variant { get; set; }
public byte Stain0 { get; set; }
public byte Stain1 { get; set; }
public ulong Value { get; set; }
}
[Serializable]
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
internal class ErrorMessage {

View File

@ -21,10 +21,6 @@ internal class ActorManager : IDisposable {
}
private unsafe void OnFramework(IFramework framework) {
if (this._idx is not { } idx) {
return;
}
if (!this._tasks.TryPeek(out var actorAction)) {
return;
}
@ -60,15 +56,8 @@ internal class ActorManager : IDisposable {
}
}
internal unsafe void Spawn(Message message) {
if (this._idx != null) {
Plugin.Log.Warning("refusing to spawn more than one actor");
return;
}
Plugin.Log.Debug("spawning actor");
internal void Spawn(Message message) {
this._tasks.Enqueue(new SpawnAction(message));
}
internal void Despawn() {
@ -80,7 +69,7 @@ internal class ActorManager : IDisposable {
this._tasks.Enqueue(new DeleteAction());
}
private unsafe abstract class BaseActorAction {
private abstract unsafe class BaseActorAction {
/// <summary>
/// Run this action.
/// </summary>
@ -130,6 +119,7 @@ internal class ActorManager : IDisposable {
var chara = (BattleChara*) objMan->GetObjectByIndex((ushort) idx);
chara->ObjectKind = ObjectKind.BattleNpc;
chara->TargetableStatus = 0;
chara->Position = message.Position;
chara->Rotation = message.Yaw;
var drawData = &chara->DrawData;
@ -183,6 +173,7 @@ internal class ActorManager : IDisposable {
}
objMan->DeleteObjectByIndex((ushort) idx, 0);
manager._idx = null;
return true;
}
}