Skip to content

Commit

Permalink
anom_run (#461)
Browse files Browse the repository at this point in the history
* anom_run

* anom_run_fix1

* anom_run_fix2
  • Loading branch information
ZoNeSRuS authored Oct 23, 2023
1 parent 0e907d3 commit c007c4f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Content.Server/Physics/Components/RandomWalkComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public sealed partial class RandomWalkComponent : Component
[ViewVariables(VVAccess.ReadOnly)]
public bool StepOnStartup = false;

/// <summary>
/// Speed modifier for each tick
/// </summary>
[DataField("change")]
[ViewVariables(VVAccess.ReadWrite)]
public float Сhange = 1f;

#region Update Timing

/// <summary>
Expand Down
32 changes: 32 additions & 0 deletions Content.Server/Physics/Controllers/RandomWalkController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
using Content.Shared.Follower.Components;
using Content.Shared.Throwing;

using Content.Shared.Anomaly.Components;
using Content.Shared.Anomaly.Effects.Components;

namespace Content.Server.Physics.Controllers;

/// <summary>
Expand All @@ -27,6 +30,7 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<RandomWalkComponent, ComponentStartup>(OnRandomWalkStartup);
SubscribeLocalEvent<RandomWalkComponent, AnomalyPulseEvent>(OnPulse);
}

/// <summary>
Expand Down Expand Up @@ -73,6 +77,15 @@ public void Update(EntityUid uid, RandomWalkComponent? randomWalk = null, Physic

_physics.SetLinearVelocity(uid, physics.LinearVelocity * randomWalk.AccumulatorRatio, body: physics);
_physics.ApplyLinearImpulse(uid, pushAngle.ToVec() * (pushStrength * physics.Mass), body: physics);

randomWalk.MinSpeed*=randomWalk.Сhange;
randomWalk.MaxSpeed*=randomWalk.Сhange;
if (randomWalk.MaxSpeed < 0.1)
{
randomWalk.MinSpeed=0;
randomWalk.MaxSpeed=0;
randomWalk.Сhange=1;
}
}

/// <summary>
Expand All @@ -88,4 +101,23 @@ private void OnRandomWalkStartup(EntityUid uid, RandomWalkComponent comp, Compon
else
comp.NextStepTime = _timing.CurTime + TimeSpan.FromSeconds(_random.NextDouble(comp.MinStepCooldown.TotalSeconds, comp.MaxStepCooldown.TotalSeconds));
}


/// <summary>
/// Random movement of the anomaly at the pulse
/// </summary>

private void OnPulse(EntityUid uid, RandomWalkComponent? randomWalk, ref AnomalyPulseEvent args)
{
TryComp<AnomalyComponent>(uid, out var anomaly);

if (randomWalk != null && anomaly !=null && anomaly.PulseRun == true)
{
randomWalk.MinStepCooldown=TimeSpan.FromSeconds(1.0);
randomWalk.MaxStepCooldown=TimeSpan.FromSeconds(1.0);
randomWalk.MinSpeed=10;
randomWalk.MaxSpeed=15;
randomWalk.Сhange=0.8f;
}
}
}
6 changes: 6 additions & 0 deletions Content.Shared/Anomaly/Components/AnomalyComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ public sealed partial class AnomalyComponent : Component
/// </summary>
[DataField]
public SoundSpecifier? SupercriticalSound = new SoundCollectionSpecifier("explosion");

/// <summary>
/// Will the anomaly randomly move with a pulse
/// </summary>
[DataField]
public Boolean PulseRun = true;
#endregion

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
anomalyContactDamage:
types:
Radiation: 10
pulseRun: True
- type: AmbientSound
range: 5
volume: -5
Expand All @@ -20,7 +21,7 @@
- type: Transform
anchored: false
- type: Physics
bodyType: Static
bodyType: KinematicController
- type: Fixtures
fixtures:
fix1:
Expand Down Expand Up @@ -50,6 +51,9 @@
- type: RadiationSource
intensity: 4
slope: 0.7
- type: RandomWalk
minSpeed: 0
maxSpeed: 0

- type: entity
id: AnomalyPyroclastic
Expand Down Expand Up @@ -295,7 +299,7 @@
types:
Slash: 1
- type: EntitySpawnAnomaly
superCriticalSpawns:
superCriticalSpawns:
- ReagentSlimeSpawner
spawns:
- PuddleSparkle
Expand Down

0 comments on commit c007c4f

Please sign in to comment.