Move tractor force into Ymir world physics
This commit is contained in:
parent
31c1dc71b4
commit
e4bd62c1c1
6 changed files with 49 additions and 30 deletions
|
|
@ -13,6 +13,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
DaemonSimulationAppliesYmirHit();
|
||||
MissingPhysicsOwnerCannotAdvanceProjectiles();
|
||||
MissingWorldPhysicsOwnerCannotAdvanceShips();
|
||||
TractorRampsAndPullsThroughYmirWithoutTeleportingCargo();
|
||||
ThermalCellsUseFossilConductionAndRadiation();
|
||||
MultipleActorsUseTheSameMovementLever();
|
||||
AgentClaimsAndCompletesExploreTaskThroughCommands();
|
||||
|
|
@ -797,6 +798,23 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
throw new InvalidOperationException("daemon advanced a ship without an authoritative world physics owner");
|
||||
}
|
||||
|
||||
private static void TractorRampsAndPullsThroughYmirWithoutTeleportingCargo()
|
||||
{
|
||||
var ship = Entity(0, 0, "player");
|
||||
var wreck = Entity(1, 60, "wreck");
|
||||
wreck.CargoContents = [Cargo(("salvage", 1, 0, 0))];
|
||||
ship.TargetEntityIndex = 1;
|
||||
var run = new AetheriaRuntimeRunCheckpointCommit { CurrentZoneIndex = 0, CurrentEntityKey = "zone.0.entity.0", Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [ship, wreck] }] };
|
||||
var command = AetheriaRuntimeDaemonCommandDocument.Create(AetheriaRuntimeDaemonCommandKinds.SetTractorPower, "pilot", "tractor-smoke", 0, "zone.0.entity.0");
|
||||
command.CommandId = "tractor-on"; command.ScalarValue = 1;
|
||||
AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-tractor-smoke.cc"), run,
|
||||
new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 1, FixedDeltaSeconds = 0.25, SimulationTimeSeconds = 0.25, ObservedCommands = [command], ProjectilePhysics = AetheriaRuntimeProjectilePhysicsUnavailable.Instance, BuildPublications = false });
|
||||
RequireNear(0.5, ship.TractorPower, 0.000001, "tractor power must use the fossil two-per-second ramp");
|
||||
Require(wreck.VelocityX < 0 && wreck.PositionX < 60, "Ymir must pull the targeted body toward the tractor source");
|
||||
RequireEqual(1, CargoQuantity(wreck, "salvage"), "tractor force must not teleport target cargo");
|
||||
RequireEqual(0, CargoQuantity(ship, "salvage"), "scooping must remain a separate capacity-checked transaction");
|
||||
}
|
||||
|
||||
private static (AetheriaRuntimeRunCheckpointCommit Run, AetheriaRuntimeZoneSnapshotCommit Zone, AetheriaRuntimeEntitySnapshotCommit Target) Scenario()
|
||||
{
|
||||
var source = Entity(1, -100, "player");
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ namespace Aetheria.State.Daemon;
|
|||
|
||||
public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics
|
||||
{
|
||||
public const double TractorRadius = 25;
|
||||
public const double TractorTraction = 25;
|
||||
public const double TractorDistance = 75;
|
||||
private const string Prefix = "aetheria.daemon.entity.";
|
||||
private readonly YmirSimulator _simulator;
|
||||
public AetheriaYmirWorldPhysics(YmirSimulator? simulator = null) => _simulator = simulator ?? new YmirSimulator();
|
||||
|
|
@ -15,8 +18,21 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics
|
|||
ArgumentNullException.ThrowIfNull(zone);
|
||||
if (deltaSeconds <= 0) throw new ArgumentOutOfRangeException(nameof(deltaSeconds));
|
||||
var attached = (entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>()).SelectMany(entity => entity.ChildEntityIndices ?? Array.Empty<int>()).ToHashSet();
|
||||
var bodies = (entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>()).Where(entity => entity.IsActive && !attached.Contains(entity.EntityIndex))
|
||||
.Select(entity => new PhysicsBody(Prefix + entity.EntityIndex, new Vec2((float)entity.PositionX, (float)entity.PositionZ), new Vec2((float)entity.VelocityX, (float)entity.VelocityY),
|
||||
var active = (entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>()).Where(entity => entity.IsActive && !attached.Contains(entity.EntityIndex)).ToArray();
|
||||
var velocity = active.ToDictionary(entity => entity.EntityIndex, entity => new Vec2((float)entity.VelocityX, (float)entity.VelocityY));
|
||||
foreach (var actor in active.Where(entity => entity.TractorPower > 0 && entity.TargetEntityIndex >= 0))
|
||||
{
|
||||
var target = active.FirstOrDefault(entity => entity.EntityIndex == actor.TargetEntityIndex);
|
||||
if (target == null) continue;
|
||||
var dx = actor.PositionX - target.PositionX; var dz = actor.PositionZ - target.PositionZ;
|
||||
var distance = Math.Sqrt(dx * dx + dz * dz);
|
||||
if (distance <= 0.001 || distance > TractorDistance + TractorRadius) continue;
|
||||
var impulse = TractorTraction * actor.TractorPower * deltaSeconds;
|
||||
var current = velocity[target.EntityIndex];
|
||||
velocity[target.EntityIndex] = new Vec2(current.X + (float)(dx / distance * impulse), current.Y + (float)(dz / distance * impulse));
|
||||
}
|
||||
var bodies = active
|
||||
.Select(entity => new PhysicsBody(Prefix + entity.EntityIndex, new Vec2((float)entity.PositionX, (float)entity.PositionZ), velocity[entity.EntityIndex],
|
||||
string.Equals(entity.Kind, "station", StringComparison.OrdinalIgnoreCase) ? 48 : 20, 1,
|
||||
IsStatic: string.Equals(entity.Kind, "station", StringComparison.OrdinalIgnoreCase), Restitution: 0.2f,
|
||||
Direction: new Vec2((float)entity.DirectionX, (float)entity.DirectionY))).ToArray();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return false;
|
||||
|
||||
return ApplyCurrentEntity(run, command, entity =>
|
||||
entity.TractorPower = command.ScalarValue);
|
||||
entity.TractorTargetPower = command.ScalarValue);
|
||||
case AetheriaRuntimeDaemonCommandKinds.SetHeatsinksEnabled:
|
||||
return ApplyCurrentEntity(run, command, entity =>
|
||||
entity.HeatsinksEnabled = command.ScalarValue > 0.5);
|
||||
|
|
|
|||
|
|
@ -46,43 +46,25 @@ namespace GameCult.Aetheria.State.Verse
|
|||
AetheriaRuntimeThermalSimulation.EnsureState(entity);
|
||||
foreach (var movement in intents?.Movements ?? Enumerable.Empty<AetheriaRuntimeDaemonMovementIntent>())
|
||||
ApplyMovementIntent(run, entities, movement, settings);
|
||||
StepTractorPower(entities, deltaSeconds);
|
||||
StepRaiderAi(entities);
|
||||
StepTargetPursuit(entities, settings);
|
||||
StepWorldPhysics(zone, entities, deltaSeconds, worldPhysics);
|
||||
StepCombat(run, zone, entities, intents, deltaSeconds, settings, projectilePhysics);
|
||||
AetheriaRuntimeMiningSimulation.Step(run, zone, entities, intents, catalog, frameId, simulationTimeSeconds, deltaSeconds);
|
||||
AetheriaRuntimeSurveySimulation.Step(run, zone, entities, intents, catalog, frameId, simulationTimeSeconds, deltaSeconds);
|
||||
StepTractorSalvage(run, zone, entities, settings);
|
||||
RefreshContacts(entities, settings);
|
||||
}
|
||||
}
|
||||
|
||||
private static void StepTractorSalvage(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeZoneSnapshotCommit zone,
|
||||
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
|
||||
AetheriaRuntimeDaemonSimulationSettings settings)
|
||||
private static void StepTractorPower(IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities, double deltaSeconds)
|
||||
{
|
||||
if (!TryParseEntityIndex(run.CurrentEntityKey, out var actorIndex))
|
||||
return;
|
||||
var actor = entities.FirstOrDefault(entity => entity.EntityIndex == actorIndex && IsAlive(entity));
|
||||
if (actor == null || actor.TractorPower <= 0 || actor.TargetEntityIndex < 0)
|
||||
return;
|
||||
var wreck = entities.FirstOrDefault(entity => entity.EntityIndex == actor.TargetEntityIndex && !IsAlive(entity));
|
||||
if (wreck == null || DistanceSq(actor, wreck) > settings.AttackRange * settings.AttackRange)
|
||||
return;
|
||||
|
||||
var loot = (wreck.CargoContents ?? Array.Empty<AetheriaRuntimeCargoBayLoadoutCommit>())
|
||||
.SelectMany(bay => bay?.Items ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>())
|
||||
.ToArray();
|
||||
if (loot.Length == 0)
|
||||
return;
|
||||
var bays = (actor.CargoContents ?? Array.Empty<AetheriaRuntimeCargoBayLoadoutCommit>()).ToList();
|
||||
if (bays.Count == 0)
|
||||
bays.Add(new AetheriaRuntimeCargoBayLoadoutCommit());
|
||||
bays[0].Items = (bays[0].Items ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>()).Concat(loot).ToArray();
|
||||
actor.CargoContents = bays.ToArray();
|
||||
wreck.CargoContents = Array.Empty<AetheriaRuntimeCargoBayLoadoutCommit>();
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var delta = entity.TractorTargetPower - entity.TractorPower;
|
||||
entity.TractorPower += Math.Sign(delta) * Math.Min(Math.Abs(delta), deltaSeconds * 2.0);
|
||||
entity.TractorPower = Clamp01(entity.TractorPower);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyMovementIntent(
|
||||
|
|
|
|||
|
|
@ -925,6 +925,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
[Key(40)]
|
||||
public string OrbitKey { get; set; } = "";
|
||||
|
||||
[Key(41)]
|
||||
public double TractorTargetPower { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
|
|||
| Thermal/energy | cell conduction and capacitor/reactor/radiator network | daemon | ship/equipment status and warnings | schematic/post effects | cell conduction/radiation wired; energy network and medical thresholds remain reference | capacitor/reactor/radiator ordering, shared energy and medical timelines |
|
||||
| Weapons | ServerShared behaviors + Unity effects | daemon + Ymir where spatial | action capability, weapon state, attack events | effects/audio/HUD | one synthetic weapon wired; original engine reference-only | each weapon family |
|
||||
| Destruction/drops | entity death and pickup paths | daemon | death/drop events and world entities | effects and pickups | fragments wired; chronology and original drop transaction absent | exactly-once drops and cleanup |
|
||||
| Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor intent, pickup entity and receipt | beam/interaction feedback | command wired; spatial/original pickup semantics absent | ramp, range, failed capacity, lifetime and pickup once |
|
||||
| Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor power, target, pickup entity and receipt | beam/interaction feedback | fossil 2/s power ramp and authored radius/traction/distance move targets through Ymir; instant cargo teleport deleted; pickup transaction remains partial | sphere-cast filtering, failed capacity, pickup lifetime and exactly-once receipt |
|
||||
| Dock/undock | wormhole-first interact; first eligible bay; component prerequisites | daemon + Ymir placement | dock commands/context | camera/UI transition | daemon path wired/projected; Ymir placement and parity unproven | priority, eligibility, placement and reconnect |
|
||||
| Inventory/equipment | inventory panels + ServerShared | daemon | inventory/equipment surfaces | generic UI | owner-exists; wired/projected in fragments; not proven | all transfer directions and rejection |
|
||||
| Trade | trade UI/economy | daemon | stock, quote, purchase commands | generic UI | purchase owner wired/projected; not proven | atomic purchase and capacity |
|
||||
|
|
|
|||
Loading…
Reference in a new issue