diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index bc17c9d4b..a348ff62b 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -14,6 +14,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks YmirBeamTraceReturnsFirstSpatialContact(); ConstantWeaponRunsOnDaemonThroughYmirBeamContact(); ChargedWeaponCannotBypassChargeLifecycle(); + ChargedWeaponHoldRiskMalfunctionsDeterministically(); DaemonSimulationAppliesYmirHit(); ProjectileDeathEmitsOnce(); MissingPhysicsOwnerCannotAdvanceProjectiles(); @@ -158,7 +159,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks { var source = Entity(0, 0, "player"); source.DirectionX = 1; - source.TargetEntityIndex = 1; + source.TargetEntityIndex = -1; source.WeaponGroups = [new[] { 0 }]; source.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit { @@ -197,6 +198,81 @@ internal sealed class AetheriaDaemonYmirSmokeChecks "pressing an authored ChargedWeapon must not bypass charging through the instant weapon resolver"); Require(Math.Abs(Stat(target, "hull") - 100) < 0.000001, "charged weapon admission must not apply damage before a daemon-owned release commits the shot"); + var state = source.WeaponStates.Single(value => value.BehaviorKind == AetheriaRuntimeBehaviorKinds.ChargedWeapon); + for (var frame = 1; frame < 11; frame++) + AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, + new AetheriaRuntimeDaemonSimulationSettings(), new AetheriaYmirProjectilePhysics(), + new AetheriaYmirWorldPhysics(), + new AetheriaRuntimeCatalogSnapshot([CatalogItem("test-charged", payload)], [], []), frame, frame * 0.1); + Require(state.Charging && state.Charged && state.Charge >= 1 && state.ChargeHoldSeconds > 0, + "one semantic request must precharge without a firing solution and enter persisted hold state"); + Require(!run.GameEvents.Any(value => value.Kind == "projectile.launched"), + "ready charged weapon must hold rather than invent a firing solution"); + source.TargetEntityIndex = target.EntityIndex; + AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, + new AetheriaRuntimeDaemonSimulationSettings(), new AetheriaYmirProjectilePhysics(), + new AetheriaYmirWorldPhysics(), + new AetheriaRuntimeCatalogSnapshot([CatalogItem("test-charged", payload)], [], []), 11, 1.1); + Require(run.GameEvents.Count(value => value.Kind == "weapon.charge.committed") == 1 && + run.GameEvents.Any(value => value.Kind == "projectile.launched" && + value.ItemKey == "test-charged" && Math.Abs(value.ScalarValue - 40) < 0.000001), + "stored full charge must commit automatically when a firing solution becomes available"); + var surface = AetheriaRuntimeDaemonGameSurfaceBuilder.Build( + new AetheriaRuntimeDaemonFrameDocument { FrameId = 11, Run = run }, + new AetheriaRuntimeDaemonHealthDocument(), + AetheriaRuntimeDaemonCommandBoundaryDocument.Create("daemon")); + Require(Flatten(surface.Surface.Root).Any(node => node.Kind == "weapon.state" && + node.Props.ContainsKey("chargeMalfunctionRisk")), + "Eve must expose charged hold duration and malfunction risk generically"); + Require(Flatten(surface.Surface.Root).Any(node => node.Kind == "feedback.event" && + node.Props["eventKind"] == "weapon.charge.committed"), + "Eve feedback must expose charged solution commit chronology"); + } + + private static void ChargedWeaponHoldRiskMalfunctionsDeterministically() + { + var source = Entity(0, 0, "player"); + source.WeaponGroups = [new[] { 0 }]; + var item = new AetheriaRuntimeLoadoutItemCommit + { ItemKey = "risk-charger", Quality = 1, Durability = 1, Enabled = true }; + source.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit { Item = item }]; + var run = new AetheriaRuntimeRunCheckpointCommit + { + RunId = "charged-risk-smoke", GenerationSeed = 17, + CurrentZoneIndex = 0, CurrentEntityKey = "zone.0.entity.0", + Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [source] }] + }; + var payload = new AetheriaRuntimeBehaviorPayload(0, AetheriaRuntimeBehaviorKinds.ChargedWeapon, 0, + [ + new AetheriaRuntimeBehaviorField(2, PerformanceStat(20)), + new AetheriaRuntimeBehaviorField(6, PerformanceStat(150)), + new AetheriaRuntimeBehaviorField(17, PerformanceStat(1)), + new AetheriaRuntimeBehaviorField(19, PerformanceStat(0.5)), + new AetheriaRuntimeBehaviorField(21, PerformanceStat(1)), + new AetheriaRuntimeBehaviorField(25, Number(1)), + new AetheriaRuntimeBehaviorField(26, Number(0.25)) + ]); + var catalog = new AetheriaRuntimeCatalogSnapshot([CatalogItem(item.ItemKey, payload)], [], []); + for (var frame = 0; frame < 21; frame++) + { + var intents = new AetheriaRuntimeDaemonIntentState(); + if (frame == 0) intents.WeaponGroups.Add(new AetheriaRuntimeDaemonWeaponGroupIntent + { ActorEntityKey = "zone.0.entity.0", WeaponGroup = 0, Fire = true, Active = true }); + AetheriaRuntimeDaemonSimulation.Step(run, intents, 0.1, + new AetheriaRuntimeDaemonSimulationSettings(), new AetheriaYmirProjectilePhysics(), + new AetheriaYmirWorldPhysics(), catalog, frame, frame * 0.1); + } + var state = source.WeaponStates.Single(value => value.BehaviorKind == AetheriaRuntimeBehaviorKinds.ChargedWeapon); + Require(!state.Charging && !state.Charged && state.CoolingDown && state.ChargeRiskChecks == 1 && + Math.Abs(state.ChargeMalfunctionRisk - 1) < 0.000001, + "held full charge must persist its risk check and fail when authored risk reaches certainty"); + RequireNear(0.75, item.Durability, 0.000001, + "charged malfunction must damage canonical equipped-item durability"); + Require(run.GameEvents.Count(value => value.Kind == "weapon.charge.malfunctioned" && + value.SubjectKey == "hold-risk" && value.ItemKey == item.ItemKey) == 1, + "charged hold risk must emit one authoritative malfunction event"); + Require(!run.GameEvents.Any(value => value.Kind == "projectile.launched"), + "malfunction without a firing solution must never leak a projectile"); } private static void AgentTowsStationIntoPersistentOrbit() diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs index a12936c4f..038b8d247 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs @@ -1111,7 +1111,10 @@ namespace GameCult.Aetheria.State.Verse double reloadProgress, double ammoIntervalProgress, double lockProgress, - string lockTargetEntityKey) + string lockTargetEntityKey, + double chargeHoldSeconds, + int chargeRiskChecks, + double chargeMalfunctionRisk) { OwnerKind = ownerKind; OwnerIndex = ownerIndex; @@ -1132,6 +1135,9 @@ namespace GameCult.Aetheria.State.Verse AmmoIntervalProgress = ammoIntervalProgress; LockProgress = lockProgress; LockTargetEntityKey = lockTargetEntityKey; + ChargeHoldSeconds = chargeHoldSeconds; + ChargeRiskChecks = chargeRiskChecks; + ChargeMalfunctionRisk = chargeMalfunctionRisk; } public string OwnerKind { get; set; } @@ -1153,6 +1159,9 @@ namespace GameCult.Aetheria.State.Verse public double AmmoIntervalProgress { get; set; } public double LockProgress { get; set; } public string LockTargetEntityKey { get; set; } + public double ChargeHoldSeconds { get; set; } + public int ChargeRiskChecks { get; set; } + public double ChargeMalfunctionRisk { get; set; } } [MessagePackObject(true)] diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs index 3e9ba5b58..5f2adfe03 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs @@ -1073,7 +1073,10 @@ namespace GameCult.Aetheria.State.Verse var ammoIntervalProgress = ReadFieldDouble(ref reader, weaponFields, 16); var lockProgress = ReadFieldDouble(ref reader, weaponFields, 17); var lockTargetEntityKey = ReadFieldString(ref reader, weaponFields, 18); - SkipRemaining(ref reader, weaponFields, 19); + var chargeHoldSeconds = ReadFieldDouble(ref reader, weaponFields, 19); + var chargeRiskChecks = ReadFieldInt32(ref reader, weaponFields, 20); + var chargeMalfunctionRisk = ReadFieldDouble(ref reader, weaponFields, 21); + SkipRemaining(ref reader, weaponFields, 22); weaponStates[weapon] = new AetheriaRuntimeWeaponStateSnapshot( ownerKind, ownerIndex, @@ -1093,7 +1096,10 @@ namespace GameCult.Aetheria.State.Verse reloadProgress, ammoIntervalProgress, lockProgress, - lockTargetEntityKey); + lockTargetEntityKey, + chargeHoldSeconds, + chargeRiskChecks, + chargeMalfunctionRisk); } return weaponStates; diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs index db8350844..15c1af826 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs @@ -693,7 +693,10 @@ namespace GameCult.Aetheria.State.Verse ("reloadProgress", FormatNumber(value.ReloadProgress)), ("lockProgress", FormatNumber(value.LockProgress)), ("targetEntityId", targetEntityId), - ("lastRefusalReason", value.LastRefusalReason) + ("lastRefusalReason", value.LastRefusalReason), + ("chargeHoldSeconds", FormatNumber(value.ChargeHoldSeconds)), + ("chargeRiskChecks", value.ChargeRiskChecks.ToString(CultureInfo.InvariantCulture)), + ("chargeMalfunctionRisk", FormatNumber(value.ChargeMalfunctionRisk)) }); }) .ToArray(); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs index 9425db197..7a0654a6e 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs @@ -240,6 +240,8 @@ namespace GameCult.Aetheria.State.Verse foreach (var attacker in entities) { var weaponGroup = ResolveFireGroup(run, zone, attacker, intents); + StepChargedWeapons(run, zone, attacker, byIndex, weaponGroup, deltaSeconds, + settings, catalog, frameId); StepConstantWeapons(run, zone, entities, byIndex, attacker, weaponGroup, deltaSeconds, settings, projectilePhysics, catalog, frameId); var weapons = ResolveWeapons(attacker, weaponGroup, catalog, settings); @@ -362,6 +364,202 @@ namespace GameCult.Aetheria.State.Verse } } + private static void StepChargedWeapons( + AetheriaRuntimeRunCheckpointCommit run, + AetheriaRuntimeZoneSnapshotCommit zone, + AetheriaRuntimeEntitySnapshotCommit attacker, + IReadOnlyDictionary byIndex, + int requestedWeaponGroup, + double deltaSeconds, + AetheriaRuntimeDaemonSimulationSettings settings, + AetheriaRuntimeCatalogSnapshot? catalog, + long frameId) + { + foreach (var weapon in ResolveChargedWeapons(attacker, requestedWeaponGroup, catalog, settings)) + { + var state = weapon.Base.State; + state.Firing = false; + state.CooldownProgress = Math.Max(0, state.CooldownProgress - deltaSeconds); + state.CoolingDown = state.CooldownProgress > 0; + if (state.Reloading) + { + state.ReloadProgress = Math.Max(0, state.ReloadProgress - deltaSeconds); + if (state.ReloadProgress <= 0) + { + state.Reloading = false; + state.Ammo = weapon.Base.MagazineSize; + AppendChargedEvent(run, zone, attacker, weapon, frameId, "weapon.reload.completed", "", state.Ammo); + } + } + + if (weapon.Requested && IsAlive(attacker) && !state.Charging && !state.CoolingDown && + !state.Reloading && state.BurstRemaining <= 0) + { + state.Charging = true; + state.Charged = false; + state.Charge = 0; + state.ChargeHoldSeconds = 0; + state.ChargeRiskChecks = 0; + state.ChargeMalfunctionRisk = 0; + state.LockTargetEntityIndex = -1; + state.LastRefusalReason = ""; + AppendChargedEvent(run, zone, attacker, weapon, frameId, "weapon.charge.started", "committed", 0); + } + + byIndex.TryGetValue(attacker.TargetEntityIndex, out var solutionTarget); + var hasSolution = solutionTarget != null && IsAlive(solutionTarget) && Hostile(attacker, solutionTarget) && + DistanceSq(attacker, solutionTarget) <= weapon.Base.Range * weapon.Base.Range; + if (state.Charging) + { + var step = deltaSeconds / weapon.ChargeTime; + if (!state.Charged) + { + var energy = weapon.ChargeEnergy * step; + if (!CanSupplyEnergy(attacker, energy)) + { + state.Charging = false; + state.Charge = 0; + PublishChargedRefusal(run, zone, attacker, weapon, frameId, "insufficient-charge-energy"); + continue; + } + CommitEnergy(attacker, energy); + AetheriaRuntimeThermalSimulation.AddHeat(attacker, weapon.ChargeHeat * step); + } + state.Charge += step; + if (!state.Charged && state.Charge >= 1) + { + state.Charged = true; + state.ChargeHoldSeconds = 0; + AppendChargedEvent(run, zone, attacker, weapon, frameId, "weapon.charge.ready", "holding", state.Charge); + } + if (state.Charged && hasSolution) + { + state.LockTargetEntityIndex = solutionTarget!.EntityIndex; + state.Charging = false; + state.ChargeHoldSeconds = 0; + state.ChargeRiskChecks = 0; + state.ChargeMalfunctionRisk = 0; + TriggerChargedShot(run, zone, attacker, weapon, frameId); + } + else if (state.Charged) + { + state.ChargeHoldSeconds += deltaSeconds; + var grace = Math.Max(0, weapon.FailureCharge - 1) * weapon.ChargeTime; + var overdue = Math.Max(0, state.ChargeHoldSeconds - grace); + var dueChecks = (int)Math.Floor(overdue); + while (state.ChargeRiskChecks < dueChecks && state.Charging) + { + state.ChargeRiskChecks++; + state.ChargeMalfunctionRisk = Clamp01(state.ChargeRiskChecks / weapon.ChargeTime); + if (ChargedMalfunctionRoll(run.GenerationSeed, attacker.EntityIndex, + state.OwnerIndex, state.BehaviorIndex, state.ChargeRiskChecks) < state.ChargeMalfunctionRisk) + { + state.Charging = false; + state.Charged = false; + state.Charge = 0; + state.CoolingDown = true; + state.CooldownProgress = weapon.Base.Cooldown; + weapon.Item.Durability = Math.Max(0, weapon.Item.Durability - weapon.FailureDamage); + AppendChargedEvent(run, zone, attacker, weapon, frameId, + "weapon.charge.malfunctioned", "hold-risk", state.ChargeMalfunctionRisk); + } + } + } + } + + if (state.BurstRemaining > 0) + byIndex.TryGetValue(state.LockTargetEntityIndex, out solutionTarget); + if (state.BurstRemaining <= 0 || solutionTarget == null || !IsAlive(solutionTarget)) + continue; + var shot = weapon.CommittedShot(); + state.BurstTimer += deltaSeconds; + while (state.BurstRemaining > 0 && state.BurstTimer > 0) + { + if (!shot.SingleAmmoBurst) + { + var result = CommitWeaponRound(attacker, shot); + PublishWeaponRoundResult(run, zone, attacker, shot, frameId, result); + if (result == WeaponRoundResult.ReloadStarted) + AppendWeaponEvent(run, zone, attacker, shot, frameId, "weapon.reload.started"); + if (result != WeaponRoundResult.Fired) { state.BurstRemaining = 0; break; } + } + state.BurstRemaining--; + state.BurstTimer -= state.BurstInterval; + var projectile = SpawnProjectile(zone, attacker, solutionTarget, shot, settings); + AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit + { + EventId = $"projectile:{projectile.ProjectileId}:launched", Kind = "projectile.launched", + FrameId = frameId, ZoneIndex = zone.ZoneIndex, SourceEntityIndex = attacker.EntityIndex, + TargetEntityIndex = solutionTarget.EntityIndex, SubjectKey = projectile.ProjectileId, + ItemKey = projectile.WeaponKind, ScalarValue = projectile.Damage, + PositionX = projectile.PositionX, PositionZ = projectile.PositionZ + }); + state.Firing = true; + AetheriaRuntimeThermalSimulation.AddHeat(attacker, shot.Heat); + } + if (state.BurstRemaining <= 0) + { + state.Charged = false; state.Charge = 0; state.ChargeHoldSeconds = 0; + state.ChargeRiskChecks = 0; state.ChargeMalfunctionRisk = 0; + } + } + } + + private static void TriggerChargedShot(AetheriaRuntimeRunCheckpointCommit run, + AetheriaRuntimeZoneSnapshotCommit zone, AetheriaRuntimeEntitySnapshotCommit attacker, + ResolvedChargedWeapon weapon, long frameId) + { + var shot = weapon.CommittedShot(); + if (shot.SingleAmmoBurst) + { + var result = CommitWeaponRound(attacker, shot); + PublishWeaponRoundResult(run, zone, attacker, shot, frameId, result); + if (result == WeaponRoundResult.ReloadStarted) + AppendWeaponEvent(run, zone, attacker, shot, frameId, "weapon.reload.started"); + if (result != WeaponRoundResult.Fired) { weapon.Base.State.Charged = false; weapon.Base.State.Charge = 0; return; } + } + weapon.Base.State.BurstRemaining = shot.BurstCount; + weapon.Base.State.BurstInterval = shot.BurstTime / shot.BurstCount; + weapon.Base.State.BurstTimer = 0; + weapon.Base.State.CoolingDown = true; + weapon.Base.State.CooldownProgress = shot.Cooldown; + AppendChargedEvent(run, zone, attacker, weapon, frameId, "weapon.charge.committed", "solution-acquired", 1); + } + + private static void PublishChargedRefusal(AetheriaRuntimeRunCheckpointCommit run, + AetheriaRuntimeZoneSnapshotCommit zone, AetheriaRuntimeEntitySnapshotCommit entity, + ResolvedChargedWeapon weapon, long frameId, string reason) + { + if (string.Equals(weapon.Base.State.LastRefusalReason, reason, StringComparison.Ordinal)) return; + weapon.Base.State.LastRefusalReason = reason; + AppendChargedEvent(run, zone, entity, weapon, frameId, "weapon.fire.refused", reason, weapon.Base.State.Ammo); + } + + private static void AppendChargedEvent(AetheriaRuntimeRunCheckpointCommit run, + AetheriaRuntimeZoneSnapshotCommit zone, AetheriaRuntimeEntitySnapshotCommit entity, + ResolvedChargedWeapon weapon, long frameId, string kind, string subject, double scalar) + { + AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit + { + EventId = $"frame:{frameId}:zone:{zone.ZoneIndex}:entity:{entity.EntityIndex}:weapon:{weapon.Base.State.OwnerIndex}:{weapon.Base.State.BehaviorIndex}:{kind}", + Kind = kind, FrameId = frameId, ZoneIndex = zone.ZoneIndex, + SourceEntityIndex = entity.EntityIndex, TargetEntityIndex = entity.TargetEntityIndex, + SubjectKey = subject, ItemKey = weapon.Base.ItemKey, ScalarValue = scalar + }); + } + + private static double ChargedMalfunctionRoll(uint seed, int entityIndex, + int ownerIndex, int behaviorIndex, int check) + { + unchecked + { + uint hash = seed ^ (uint)entityIndex * 2246822519u ^ (uint)ownerIndex * 3266489917u ^ + (uint)behaviorIndex * 668265263u ^ (uint)check * 374761393u; + hash ^= hash >> 16; hash *= 2246822519u; hash ^= hash >> 13; + return (hash + 1.0) / (uint.MaxValue + 2.0); + } + } + private static void StepConstantWeapons( AetheriaRuntimeRunCheckpointCommit run, AetheriaRuntimeZoneSnapshotCommit zone, @@ -702,6 +900,25 @@ namespace GameCult.Aetheria.State.Verse .ToArray(); } + private static IReadOnlyList ResolveChargedWeapons( + AetheriaRuntimeEntitySnapshotCommit entity, int requestedWeaponGroup, + AetheriaRuntimeCatalogSnapshot? catalog, AetheriaRuntimeDaemonSimulationSettings settings) + { + var requestedEquipment = requestedWeaponGroup >= 0 && requestedWeaponGroup < + (entity.WeaponGroups ?? Array.Empty>()).Count + ? entity.WeaponGroups[requestedWeaponGroup] ?? Array.Empty() : Array.Empty(); + return AetheriaRuntimeEquippedBehaviorQueries.Find(entity, catalog, AetheriaRuntimeBehaviorKinds.ChargedWeapon) + .Where(value => string.Equals(value.Payload.Kind, AetheriaRuntimeBehaviorKinds.ChargedWeapon, StringComparison.Ordinal)) + .Select(value => new ResolvedChargedWeapon( + ResolveAuthoredWeapon(entity, value, settings), value.Item, + requestedEquipment.Contains(value.EquipmentIndex), PositiveOr(value.EvaluateStat(21), 1), + Math.Max(0, value.EvaluateStat(22)), Math.Max(0, value.EvaluateStat(23)), + ReadNumber(value.Payload, 25), PositiveOr(ReadNumber(value.Payload, 26), 1), + PositiveOr(ReadNumber(value.Payload, 27), 1), PositiveOr(ReadNumber(value.Payload, 29), 1), + PositiveOr(ReadNumber(value.Payload, 31), 1), PositiveOr(ReadNumber(value.Payload, 32), 1))) + .ToArray(); + } + private static IReadOnlyList ResolveWeapons( AetheriaRuntimeEntitySnapshotCommit entity, int weaponGroup, @@ -1007,6 +1224,43 @@ namespace GameCult.Aetheria.State.Verse public double AmmoIntervalDuration { get; } } + private sealed class ResolvedChargedWeapon + { + public ResolvedChargedWeapon(ResolvedWeapon baseWeapon, AetheriaRuntimeLoadoutItemCommit item, + bool requested, double chargeTime, double chargeEnergy, double chargeHeat, + double failureCharge, double failureDamage, double damageMultiplier, + double burstMultiplier, double velocityMultiplier, double heatMultiplier) + { + Base = baseWeapon; Item = item; Requested = requested; ChargeTime = chargeTime; + ChargeEnergy = chargeEnergy; ChargeHeat = chargeHeat; FailureCharge = failureCharge; + FailureDamage = failureDamage; DamageMultiplier = damageMultiplier; + BurstMultiplier = burstMultiplier; VelocityMultiplier = velocityMultiplier; + HeatMultiplier = heatMultiplier; + } + public ResolvedWeapon CommittedShot() + { + var count = Math.Max(1, (int)Math.Round(Base.BurstCount * BurstMultiplier)); + return new ResolvedWeapon(Base.State, Base.ItemKey, + Base.Damage * Base.BurstCount * DamageMultiplier / count, Base.Range, Base.Cooldown, + Base.ProjectileSpeed * VelocityMultiplier, Base.Heat * Base.BurstCount * HeatMultiplier / count, + Base.Energy * Base.BurstCount / count, Base.AmmoItemKey, Base.MagazineSize, Base.ReloadTime, + count, Base.BurstTime, Base.SingleAmmoBurst, Base.LockSpeed, Base.LockSensorImpact, + Base.LockAngleDegrees, Base.LockDirectionImpact, Base.LockDecayPerSecond); + } + public ResolvedWeapon Base { get; } + public AetheriaRuntimeLoadoutItemCommit Item { get; } + public bool Requested { get; } + public double ChargeTime { get; } + public double ChargeEnergy { get; } + public double ChargeHeat { get; } + public double FailureCharge { get; } + public double FailureDamage { get; } + public double DamageMultiplier { get; } + public double BurstMultiplier { get; } + public double VelocityMultiplier { get; } + public double HeatMultiplier { get; } + } + private static void RefreshContacts( IReadOnlyList entities, AetheriaRuntimeDaemonSimulationSettings settings) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeGameViewportDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeGameViewportDocuments.cs index 17b6a3f7e..d8901b0af 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeGameViewportDocuments.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeGameViewportDocuments.cs @@ -1078,7 +1078,10 @@ namespace GameCult.Aetheria.State.Verse state.ReloadProgress, state.AmmoIntervalProgress, state.LockProgress, - state.LockTargetEntityIndex < 0 ? "" : EntityRecordKey(runId, zoneIndex, state.LockTargetEntityIndex))) + state.LockTargetEntityIndex < 0 ? "" : EntityRecordKey(runId, zoneIndex, state.LockTargetEntityIndex), + state.ChargeHoldSeconds, + state.ChargeRiskChecks, + state.ChargeMalfunctionRisk)) .ToArray(); } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs index 080fe6145..161339c4b 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs @@ -1116,6 +1116,10 @@ namespace GameCult.Aetheria.State.Verse [Key(19)] public string LastRefusalReason { get; set; } = ""; + + [Key(20)] public double ChargeHoldSeconds { get; set; } + [Key(21)] public int ChargeRiskChecks { get; set; } + [Key(22)] public double ChargeMalfunctionRisk { get; set; } } [MessagePackObject]