Updated submodules
This commit is contained in:
@@ -1,28 +1,29 @@
|
||||
using CustomizePlus.GameData.Data;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Control;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using OtterGui.Log;
|
||||
using Penumbra.GameData.Actors;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Interop;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CustomizePlus.GameData.Services;
|
||||
|
||||
public class ObjectManager(IFramework framework, IClientState clientState, global::Penumbra.GameData.Interop.ObjectManager objects, ActorManager actorManager, ITargetManager targetManager)
|
||||
: IReadOnlyDictionary<ActorIdentifier, ActorData>
|
||||
public class ObjectManager(
|
||||
IFramework framework,
|
||||
IClientState clientState,
|
||||
IObjectTable objects,
|
||||
DalamudPluginInterface pi,
|
||||
Logger log,
|
||||
ActorManager actors,
|
||||
ITargetManager targets)
|
||||
: global::Penumbra.GameData.Interop.ObjectManager(pi, log, framework, objects)
|
||||
{
|
||||
public global::Penumbra.GameData.Interop.ObjectManager Objects
|
||||
=> objects;
|
||||
|
||||
public DateTime LastUpdate { get; private set; }
|
||||
public DateTime LastUpdate
|
||||
=> LastFrame;
|
||||
|
||||
private DateTime _identifierUpdate;
|
||||
public bool IsInGPose { get; private set; }
|
||||
public ushort World { get; private set; }
|
||||
|
||||
@@ -33,41 +34,27 @@ public class ObjectManager(IFramework framework, IClientState clientState, globa
|
||||
public IReadOnlyDictionary<ActorIdentifier, ActorData> Identifiers
|
||||
=> _identifiers;
|
||||
|
||||
public void Update()
|
||||
public override bool Update()
|
||||
{
|
||||
var lastUpdate = framework.LastUpdate;
|
||||
if (lastUpdate <= LastUpdate)
|
||||
return;
|
||||
if (!base.Update() && _identifierUpdate >= LastUpdate)
|
||||
return false;
|
||||
|
||||
LastUpdate = lastUpdate;
|
||||
World = (ushort)(clientState.LocalPlayer?.CurrentWorld.Id ?? 0u);
|
||||
_identifierUpdate = LastUpdate;
|
||||
World = (ushort)(this[0].Valid ? this[0].HomeWorld : 0);
|
||||
_identifiers.Clear();
|
||||
_allWorldIdentifiers.Clear();
|
||||
_nonOwnedIdentifiers.Clear();
|
||||
|
||||
for (var i = 0; i < (int)ScreenActor.CutsceneStart; ++i)
|
||||
foreach (var actor in BattleNpcs.Concat(CutsceneCharacters))
|
||||
{
|
||||
Actor character = objects[i];
|
||||
if (character.Identifier(actorManager, out var identifier))
|
||||
HandleIdentifier(identifier, character);
|
||||
}
|
||||
|
||||
for (var i = (int)ScreenActor.CutsceneStart; i < (int)ScreenActor.CutsceneEnd; ++i)
|
||||
{
|
||||
Actor character = objects[i];
|
||||
// Technically the game does not create holes in cutscenes or GPose.
|
||||
// But for Brio compatibility, we allow holes in GPose.
|
||||
// Since GPose always has the event actor in the first cutscene slot, we can still optimize in this case.
|
||||
if (!character.Valid && i == (int)ScreenActor.CutsceneStart)
|
||||
break;
|
||||
|
||||
HandleIdentifier(character.GetIdentifier(actorManager), character);
|
||||
if (actor.Identifier(actors, out var identifier))
|
||||
HandleIdentifier(identifier, actor);
|
||||
}
|
||||
|
||||
void AddSpecial(ScreenActor idx, string label)
|
||||
{
|
||||
Actor actor = objects[(int)idx];
|
||||
if (actor.Identifier(actorManager, out var ident))
|
||||
var actor = this[(int)idx];
|
||||
if (actor.Identifier(actors, out var ident))
|
||||
{
|
||||
var data = new ActorData(actor, label);
|
||||
_identifiers.Add(ident, data);
|
||||
@@ -83,15 +70,15 @@ public class ObjectManager(IFramework framework, IClientState clientState, globa
|
||||
AddSpecial(ScreenActor.Card7, "Card Actor 7");
|
||||
AddSpecial(ScreenActor.Card8, "Card Actor 8");
|
||||
|
||||
for (var i = (int)ScreenActor.ScreenEnd; i < objects.Count; ++i)
|
||||
foreach (var actor in EventNpcs)
|
||||
{
|
||||
Actor character = objects[i];
|
||||
if (character.Identifier(actorManager, out var identifier))
|
||||
HandleIdentifier(identifier, character);
|
||||
if (actor.Identifier(actors, out var identifier))
|
||||
HandleIdentifier(identifier, actor);
|
||||
}
|
||||
|
||||
var gPose = GPosePlayer;
|
||||
IsInGPose = gPose.Utf8Name.Length > 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void HandleIdentifier(ActorIdentifier identifier, Actor character)
|
||||
@@ -111,8 +98,8 @@ public class ObjectManager(IFramework framework, IClientState clientState, globa
|
||||
|
||||
if (identifier.Type is IdentifierType.Player or IdentifierType.Owned)
|
||||
{
|
||||
var allWorld = actorManager.CreateIndividualUnchecked(identifier.Type, identifier.PlayerName, ushort.MaxValue,
|
||||
identifier.Kind,
|
||||
var allWorld = actors.CreateIndividualUnchecked(identifier.Type, identifier.PlayerName, ushort.MaxValue,
|
||||
identifier.Kind,
|
||||
identifier.DataId);
|
||||
|
||||
if (!_allWorldIdentifiers.TryGetValue(allWorld, out var allWorldData))
|
||||
@@ -128,7 +115,7 @@ public class ObjectManager(IFramework framework, IClientState clientState, globa
|
||||
|
||||
if (identifier.Type is IdentifierType.Owned)
|
||||
{
|
||||
var nonOwned = actorManager.CreateNpc(identifier.Kind, identifier.DataId);
|
||||
var nonOwned = actors.CreateNpc(identifier.Kind, identifier.DataId);
|
||||
if (!_nonOwnedIdentifiers.TryGetValue(nonOwned, out var nonOwnedData))
|
||||
{
|
||||
nonOwnedData = new ActorData(character, nonOwned.ToString());
|
||||
@@ -142,26 +129,26 @@ public class ObjectManager(IFramework framework, IClientState clientState, globa
|
||||
}
|
||||
|
||||
public Actor GPosePlayer
|
||||
=> objects[(int)ScreenActor.GPosePlayer];
|
||||
=> this[(int)ScreenActor.GPosePlayer];
|
||||
|
||||
public Actor Player
|
||||
=> objects[0];
|
||||
=> this[0];
|
||||
|
||||
public unsafe Actor Target
|
||||
=> clientState.IsGPosing ? TargetSystem.Instance()->GPoseTarget : TargetSystem.Instance()->Target;
|
||||
|
||||
public Actor Focus
|
||||
=> targetManager.FocusTarget?.Address ?? nint.Zero;
|
||||
=> targets.FocusTarget?.Address ?? nint.Zero;
|
||||
|
||||
public Actor MouseOver
|
||||
=> targetManager.MouseOverTarget?.Address ?? nint.Zero;
|
||||
=> targets.MouseOverTarget?.Address ?? nint.Zero;
|
||||
|
||||
public (ActorIdentifier Identifier, ActorData Data) PlayerData
|
||||
{
|
||||
get
|
||||
{
|
||||
Update();
|
||||
return Player.Identifier(actorManager, out var ident) && _identifiers.TryGetValue(ident, out var data)
|
||||
return Player.Identifier(actors, out var ident) && _identifiers.TryGetValue(ident, out var data)
|
||||
? (ident, data)
|
||||
: (ident, ActorData.Invalid);
|
||||
}
|
||||
@@ -172,27 +159,18 @@ public class ObjectManager(IFramework framework, IClientState clientState, globa
|
||||
get
|
||||
{
|
||||
Update();
|
||||
return Target.Identifier(actorManager, out var ident) && _identifiers.TryGetValue(ident, out var data)
|
||||
return Target.Identifier(actors, out var ident) && _identifiers.TryGetValue(ident, out var data)
|
||||
? (ident, data)
|
||||
: (ident, ActorData.Invalid);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<ActorIdentifier, ActorData>> GetEnumerator()
|
||||
=> Identifiers.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
=> GetEnumerator();
|
||||
|
||||
public int Count
|
||||
=> Identifiers.Count;
|
||||
|
||||
/// <summary> Also handles All Worlds players and non-owned NPCs. </summary>
|
||||
public bool ContainsKey(ActorIdentifier key)
|
||||
=> Identifiers.ContainsKey(key) || _allWorldIdentifiers.ContainsKey(key) || _nonOwnedIdentifiers.ContainsKey(key);
|
||||
|
||||
public bool TryGetValue(ActorIdentifier key, out ActorData value)
|
||||
=> Identifiers.TryGetValue(key, out value);
|
||||
=> Identifiers.TryGetValue(key, out value);
|
||||
|
||||
public bool TryGetValueAllWorld(ActorIdentifier key, out ActorData value)
|
||||
=> _allWorldIdentifiers.TryGetValue(key, out value);
|
||||
|
||||
Reference in New Issue
Block a user