Publish weapon fire refusals
This commit is contained in:
parent
9d55ab67ff
commit
52b3664adf
3 changed files with 39 additions and 1 deletions
|
|
@ -292,6 +292,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var triggerResult = CommitWeaponRound(attacker, weapon);
|
||||
if (triggerResult == WeaponRoundResult.ReloadStarted)
|
||||
AppendWeaponEvent(run, zone, attacker, weapon, frameId, "weapon.reload.started");
|
||||
PublishWeaponRoundResult(run, zone, attacker, weapon, frameId, triggerResult);
|
||||
if (triggerResult != WeaponRoundResult.Fired) continue;
|
||||
}
|
||||
weapon.State.BurstRemaining = weapon.BurstCount;
|
||||
|
|
@ -309,6 +310,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var roundResult = CommitWeaponRound(attacker, weapon);
|
||||
if (roundResult == WeaponRoundResult.ReloadStarted)
|
||||
AppendWeaponEvent(run, zone, attacker, weapon, frameId, "weapon.reload.started");
|
||||
PublishWeaponRoundResult(run, zone, attacker, weapon, frameId, roundResult);
|
||||
if (roundResult != WeaponRoundResult.Fired)
|
||||
{
|
||||
weapon.State.BurstRemaining = 0;
|
||||
|
|
@ -379,6 +381,39 @@ namespace GameCult.Aetheria.State.Verse
|
|||
});
|
||||
}
|
||||
|
||||
private static void PublishWeaponRoundResult(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeZoneSnapshotCommit zone,
|
||||
AetheriaRuntimeEntitySnapshotCommit entity,
|
||||
ResolvedWeapon weapon,
|
||||
long frameId,
|
||||
WeaponRoundResult result)
|
||||
{
|
||||
var reason = result == WeaponRoundResult.InsufficientEnergy ? "insufficient-energy" :
|
||||
result == WeaponRoundResult.NoAmmo ? "no-ammunition" : "";
|
||||
if (string.IsNullOrEmpty(reason))
|
||||
{
|
||||
weapon.State.LastRefusalReason = "";
|
||||
return;
|
||||
}
|
||||
if (string.Equals(weapon.State.LastRefusalReason, reason, StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
weapon.State.LastRefusalReason = reason;
|
||||
AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit
|
||||
{
|
||||
EventId = $"frame:{frameId}:zone:{zone.ZoneIndex}:entity:{entity.EntityIndex}:weapon:{weapon.State.OwnerIndex}:{weapon.State.BehaviorIndex}:refused:{reason}",
|
||||
Kind = "weapon.fire.refused",
|
||||
FrameId = frameId,
|
||||
ZoneIndex = zone.ZoneIndex,
|
||||
SourceEntityIndex = entity.EntityIndex,
|
||||
TargetEntityIndex = entity.TargetEntityIndex,
|
||||
SubjectKey = reason,
|
||||
ItemKey = weapon.ItemKey,
|
||||
ScalarValue = weapon.State.Ammo
|
||||
});
|
||||
}
|
||||
|
||||
private static void UpdateWeaponLock(
|
||||
AetheriaRuntimeEntitySnapshotCommit attacker,
|
||||
AetheriaRuntimeEntitySnapshotCommit target,
|
||||
|
|
|
|||
|
|
@ -1113,6 +1113,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
[Key(18)]
|
||||
public int LockTargetEntityIndex { get; set; } = -1;
|
||||
|
||||
[Key(19)]
|
||||
public string LastRefusalReason { get; set; } = "";
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
Loading…
Reference in a new issue