feat(mosstank): add VTank-style automation PoC
This commit is contained in:
parent
f6fe0f2a4f
commit
4e6e9bc9d9
212 changed files with 49462 additions and 416 deletions
|
|
@ -774,6 +774,45 @@ public sealed class ClientObjectTable
|
|||
public bool UpdateProperties(uint itemId, PropertyBundle incoming)
|
||||
{
|
||||
if (!_objects.TryGetValue(itemId, out var item)) return false;
|
||||
MergeProperties(item, incoming);
|
||||
ApplyCooldownProperties(item, incoming);
|
||||
ObjectUpdated?.Invoke(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Atomically retains every successful item-appraisal result: the typed
|
||||
/// property tables and the per-item SpellBook block. Publishing one update
|
||||
/// prevents observers from seeing properties without their matching spell
|
||||
/// manifest (or the reverse).
|
||||
/// </summary>
|
||||
public bool UpdateAppraisal(
|
||||
uint itemId,
|
||||
PropertyBundle incoming,
|
||||
IReadOnlyList<uint> spellIds,
|
||||
double receivedAtSeconds = 0d)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(incoming);
|
||||
ArgumentNullException.ThrowIfNull(spellIds);
|
||||
if (!_objects.TryGetValue(itemId, out var item)) return false;
|
||||
MergeProperties(item, incoming);
|
||||
item.AppraisedSpellIds = spellIds.Count == 0
|
||||
? Array.Empty<uint>()
|
||||
: spellIds.ToArray();
|
||||
if (double.IsFinite(receivedAtSeconds) && receivedAtSeconds >= 0d)
|
||||
{
|
||||
long milliseconds = checked((long)Math.Round(
|
||||
receivedAtSeconds * 1000d,
|
||||
MidpointRounding.AwayFromZero));
|
||||
item.LastAppraisalTimeMs = unchecked((int)milliseconds);
|
||||
}
|
||||
ApplyCooldownProperties(item, incoming);
|
||||
ObjectUpdated?.Invoke(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void MergeProperties(ClientObject item, PropertyBundle incoming)
|
||||
{
|
||||
foreach (var kv in incoming.Ints) item.Properties.Ints[kv.Key] = kv.Value;
|
||||
foreach (var kv in incoming.Int64s) item.Properties.Int64s[kv.Key] = kv.Value;
|
||||
foreach (var kv in incoming.Bools) item.Properties.Bools[kv.Key] = kv.Value;
|
||||
|
|
@ -781,9 +820,6 @@ public sealed class ClientObjectTable
|
|||
foreach (var kv in incoming.Strings) item.Properties.Strings[kv.Key] = kv.Value;
|
||||
foreach (var kv in incoming.DataIds) item.Properties.DataIds[kv.Key] = kv.Value;
|
||||
foreach (var kv in incoming.InstanceIds) item.Properties.InstanceIds[kv.Key] = kv.Value;
|
||||
ApplyCooldownProperties(item, incoming);
|
||||
ObjectUpdated?.Invoke(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue