-using Content.Server.Singularity.Components;
+using Content.Server.Physics.Components;
+using Content.Server.Singularity.Components;
using Content.Shared.Anomaly.Components;
using Content.Shared.Anomaly.Effects;
using Content.Shared.Anomaly.Effects.Components;
SubscribeLocalEvent<GravityAnomalyComponent, AnomalyStabilityChangedEvent>(OnStabilityChanged);
}
- private void OnSeverityChanged(EntityUid uid, GravityAnomalyComponent component, ref AnomalySeverityChangedEvent args)
+ private void OnSeverityChanged(Entity<GravityAnomalyComponent> anomaly, ref AnomalySeverityChangedEvent args)
{
- if (TryComp<RadiationSourceComponent>(uid, out var radSource))
- radSource.Intensity = component.MaxRadiationIntensity * args.Severity;
+ if (TryComp<RadiationSourceComponent>(anomaly, out var radSource))
+ radSource.Intensity = anomaly.Comp.MaxRadiationIntensity * args.Severity;
- if (!TryComp<GravityWellComponent>(uid, out var gravityWell))
- return;
- var accel = (component.MaxAccel - component.MinAccel) * args.Severity + component.MinAccel;
- gravityWell.BaseRadialAcceleration = accel;
- gravityWell.BaseTangentialAcceleration = accel * 0.2f;
+ if (TryComp<GravityWellComponent>(anomaly, out var gravityWell))
+ {
+ var accel = MathHelper.Lerp(anomaly.Comp.MinAccel, anomaly.Comp.MaxAccel, args.Severity);
+ gravityWell.BaseRadialAcceleration = accel;
+
+ var radialAccel = MathHelper.Lerp(anomaly.Comp.MinRadialAccel, anomaly.Comp.MaxRadialAccel, args.Severity);
+ gravityWell.BaseTangentialAcceleration = radialAccel;
+ }
+
+ if (TryComp<RandomWalkComponent>(anomaly, out var randomWalk))
+ {
+ var speed = MathHelper.Lerp(anomaly.Comp.MinSpeed, anomaly.Comp.MaxSpeed, args.Severity);
+ randomWalk.MinSpeed = speed - anomaly.Comp.SpeedVariation;
+ randomWalk.MaxSpeed = speed + anomaly.Comp.SpeedVariation;
+ }
}
- private void OnStabilityChanged(EntityUid uid, GravityAnomalyComponent component, ref AnomalyStabilityChangedEvent args)
+ private void OnStabilityChanged(Entity<GravityAnomalyComponent> anomaly, ref AnomalyStabilityChangedEvent args)
{
- if (TryComp<GravityWellComponent>(uid, out var gravityWell))
- gravityWell.MaxRange = component.MaxGravityWellRange * args.Stability;
+ if (TryComp<GravityWellComponent>(anomaly, out var gravityWell))
+ gravityWell.MaxRange = anomaly.Comp.MaxGravityWellRange * args.Stability;
}
}
-using Robust.Shared.GameStates;
+using Robust.Shared.GameStates;
namespace Content.Shared.Anomaly.Effects.Components;
/// The maximumum size the GravityWellComponent MaxRange can be.
/// Is scaled linearly with stability.
/// </summary>
- [DataField("maxGravityWellRange"), ViewVariables(VVAccess.ReadWrite)]
- public float MaxGravityWellRange = 8f;
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public float MaxGravityWellRange = 10f;
/// <summary>
/// The maximum distance from which the anomaly
/// can throw you via a pulse.
/// </summary>
- [DataField("maxThrowRange"), ViewVariables(VVAccess.ReadWrite)]
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxThrowRange = 5f;
/// <summary>
/// The maximum strength the anomaly
/// can throw you via a pulse
/// </summary>
- [DataField("maxThrowStrength"), ViewVariables(VVAccess.ReadWrite)]
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxThrowStrength = 10;
/// <summary>
/// The maximum Intensity of the RadiationSourceComponent.
/// Is scaled linearly with stability.
/// </summary>
- [DataField("maxRadiationIntensity"), ViewVariables(VVAccess.ReadWrite)]
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxRadiationIntensity = 3f;
/// <summary>
/// The minimum acceleration value for GravityWellComponent
/// Is scaled linearly with stability.
/// </summary>
- [DataField("minAccel"), ViewVariables(VVAccess.ReadWrite)]
- public float MinAccel = 1f;
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public float MinAccel = 0f;
/// <summary>
/// The maximum acceleration value for GravityWellComponent
/// Is scaled linearly with stability.
/// </summary>
- [DataField("maxAccel"), ViewVariables(VVAccess.ReadWrite)]
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxAccel = 5f;
+ /// <summary>
+ /// The minimum acceleration value for GravityWellComponent
+ /// Is scaled linearly with stability.
+ /// </summary>
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public float MinRadialAccel = 0f;
+
+ /// <summary>
+ /// The maximum acceleration value for GravityWellComponent
+ /// Is scaled linearly with stability.
+ /// </summary>
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public float MaxRadialAccel = 5f;
+
+ /// <summary>
+ /// The maximum speed for RandomWalkComponent
+ /// Is scaled linearly with severity.
+ /// </summary>
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public float MinSpeed = 0.1f;
+
+ /// <summary>
+ /// The maximum speed for RandomWalkComponent
+ /// Is scaled linearly with severity.
+ /// </summary>
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public float MaxSpeed = 1.0f;
+
+ /// <summary>
+ /// Random +- speed modifier
+ /// </summary>
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public float SpeedVariation = 0.1f;
+
/// <summary>
/// The range around the anomaly that will be spaced on supercritical.
/// </summary>
- [DataField("spaceRange"), ViewVariables(VVAccess.ReadWrite)]
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
public float SpaceRange = 3f;
}
(body.BodyType & (BodyType.Dynamic | BodyType.KinematicController)) == 0x0)
return;
+ comp.PreviousStatus = body.BodyStatus;
comp.ThrownEndTime = _timing.CurTime + TimeSpan.FromSeconds(comp.Lifetime);
comp.MinLifetimeTime = _timing.CurTime + TimeSpan.FromSeconds(comp.MinLifetime);
_physics.SetBodyStatus(body, BodyStatus.InAir);
private void OnThrownShutdown(Entity<MeleeThrownComponent> ent, ref ComponentShutdown args)
{
if (TryComp<PhysicsComponent>(ent, out var body))
- _physics.SetBodyStatus(body, BodyStatus.OnGround);
+ _physics.SetBodyStatus(body,ent.Comp.PreviousStatus);
var ev = new MeleeThrowOnHitEndEvent();
RaiseLocalEvent(ent, ref ev);
}