Space Kudzu (#5472)
@@ -315,7 +315,9 @@ namespace Content.Client.Entry
|
|||||||
"GhostRadio",
|
"GhostRadio",
|
||||||
"Armor",
|
"Armor",
|
||||||
"Udder",
|
"Udder",
|
||||||
"PneumaticCannon"
|
"PneumaticCannon",
|
||||||
|
"Spreader",
|
||||||
|
"GrowingKudzu"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
Content.Client/Kudzu/KudzuVisualizer.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using Content.Shared.Kudzu;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
|
||||||
|
namespace Content.Client.Kudzu;
|
||||||
|
|
||||||
|
public class KudzuVisualizer : AppearanceVisualizer
|
||||||
|
{
|
||||||
|
[DataField("layer")]
|
||||||
|
private int Layer { get; } = 0;
|
||||||
|
|
||||||
|
public override void OnChangeData(AppearanceComponent component)
|
||||||
|
{
|
||||||
|
base.OnChangeData(component);
|
||||||
|
|
||||||
|
if (!component.Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.TryGetData(KudzuVisuals.Variant, out int var) && component.TryGetData(KudzuVisuals.GrowthLevel, out int level))
|
||||||
|
{
|
||||||
|
sprite.LayerMapReserveBlank(Layer);
|
||||||
|
sprite.LayerSetState(0, $"kudzu_{level}{var}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Server.Atmos.Components;
|
using Content.Server.Atmos.Components;
|
||||||
|
using Content.Server.Kudzu;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -13,6 +14,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
|
[Dependency] private readonly SpreaderSystem _spreaderSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -43,6 +45,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
SetAirblocked(airtight, false);
|
SetAirblocked(airtight, false);
|
||||||
|
|
||||||
InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum);
|
InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum);
|
||||||
|
RaiseLocalEvent(new AirtightChanged(airtight));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMapInit(EntityUid uid, AirtightComponent airtight, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, AirtightComponent airtight, MapInitEvent args)
|
||||||
@@ -69,12 +72,14 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
airtight.CurrentAirBlockedDirection = (int) Rotate((AtmosDirection)airtight.InitialAirBlockedDirection, ev.NewRotation);
|
airtight.CurrentAirBlockedDirection = (int) Rotate((AtmosDirection)airtight.InitialAirBlockedDirection, ev.NewRotation);
|
||||||
UpdatePosition(airtight);
|
UpdatePosition(airtight);
|
||||||
|
RaiseLocalEvent(uid, new AirtightChanged(airtight));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAirblocked(AirtightComponent airtight, bool airblocked)
|
public void SetAirblocked(AirtightComponent airtight, bool airblocked)
|
||||||
{
|
{
|
||||||
airtight.AirBlocked = airblocked;
|
airtight.AirBlocked = airblocked;
|
||||||
UpdatePosition(airtight);
|
UpdatePosition(airtight);
|
||||||
|
RaiseLocalEvent(airtight.OwnerUid, new AirtightChanged(airtight));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdatePosition(AirtightComponent airtight)
|
public void UpdatePosition(AirtightComponent airtight)
|
||||||
@@ -119,4 +124,14 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
return newAirBlockedDirs;
|
return newAirBlockedDirs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AirtightChanged : EntityEventArgs
|
||||||
|
{
|
||||||
|
public AirtightComponent Airtight;
|
||||||
|
|
||||||
|
public AirtightChanged(AirtightComponent airtight)
|
||||||
|
{
|
||||||
|
Airtight = airtight;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
Content.Server/Kudzu/GrowingKudzuComponent.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
|
namespace Content.Server.Kudzu;
|
||||||
|
|
||||||
|
[RegisterComponent]
|
||||||
|
public class GrowingKudzuComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "GrowingKudzu";
|
||||||
|
|
||||||
|
[DataField("growthLevel")]
|
||||||
|
public int GrowthLevel = 1;
|
||||||
|
|
||||||
|
[DataField("growthTickSkipChance")]
|
||||||
|
public float GrowthTickSkipChange = 0.0f;
|
||||||
|
}
|
||||||
56
Content.Server/Kudzu/GrowingKudzuSystem.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using Content.Shared.Kudzu;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Log;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
|
namespace Content.Server.Kudzu;
|
||||||
|
|
||||||
|
public class GrowingKudzuSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||||
|
|
||||||
|
private float _accumulatedFrameTime = 0.0f;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
SubscribeLocalEvent<GrowingKudzuComponent, ComponentAdd>(SetupKudzu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupKudzu(EntityUid uid, GrowingKudzuComponent component, ComponentAdd args)
|
||||||
|
{
|
||||||
|
if (!EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
appearance.SetData(KudzuVisuals.Variant, _robustRandom.Next(1, 3));
|
||||||
|
appearance.SetData(KudzuVisuals.GrowthLevel, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
_accumulatedFrameTime += frameTime;
|
||||||
|
|
||||||
|
if (!(_accumulatedFrameTime >= 0.5f))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_accumulatedFrameTime -= 0.5f;
|
||||||
|
|
||||||
|
foreach (var (kudzu, appearance) in EntityManager.EntityQuery<GrowingKudzuComponent, AppearanceComponent>())
|
||||||
|
{
|
||||||
|
if (kudzu.GrowthLevel >= 3 || !_robustRandom.Prob(kudzu.GrowthTickSkipChange)) continue;
|
||||||
|
kudzu.GrowthLevel += 1;
|
||||||
|
|
||||||
|
if (kudzu.GrowthLevel == 3 &&
|
||||||
|
EntityManager.TryGetComponent<SpreaderComponent>(kudzu.OwnerUid, out var spreader))
|
||||||
|
{
|
||||||
|
// why cache when you can simply cease to be? Also saves a bit of memory/time.
|
||||||
|
EntityManager.RemoveComponent<GrowingKudzuComponent>(kudzu.OwnerUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
appearance.SetData(KudzuVisuals.GrowthLevel, kudzu.GrowthLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Content.Server/Kudzu/SpreaderComponent.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Robust.Shared.Analyzers;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
|
namespace Content.Server.Kudzu;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Component for rapidly spreading objects, like Kudzu.
|
||||||
|
/// ONLY USE THIS FOR ANCHORED OBJECTS. An error will be logged if not anchored/static.
|
||||||
|
/// Currently does not support growing in space.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Friend(typeof(SpreaderSystem))]
|
||||||
|
public class SpreaderComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "Spreader";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Chance for it to grow on any given tick, after the normal growth rate-limit (if it doesn't grow, SpreaderSystem will pick another one.).
|
||||||
|
/// </summary>
|
||||||
|
[DataField("chance", required: true)]
|
||||||
|
public float Chance;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prototype spawned on growth success.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("growthResult", required: true)]
|
||||||
|
public string GrowthResult = default!;
|
||||||
|
|
||||||
|
[DataField("enabled")]
|
||||||
|
public bool Enabled = true;
|
||||||
|
}
|
||||||
133
Content.Server/Kudzu/SpreaderSystem.cs
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Content.Server.Atmos.Components;
|
||||||
|
using Content.Server.Atmos.EntitySystems;
|
||||||
|
using Content.Server.Temperature.Systems;
|
||||||
|
using Content.Shared.Atmos;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
|
namespace Content.Server.Kudzu;
|
||||||
|
|
||||||
|
// Future work includes making the growths per interval thing not global, but instead per "group"
|
||||||
|
public class SpreaderSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||||
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Maximum number of edges that can grow out every interval.
|
||||||
|
/// </summary>
|
||||||
|
private const int GrowthsPerInterval = 1;
|
||||||
|
|
||||||
|
private float _accumulatedFrameTime = 0.0f;
|
||||||
|
|
||||||
|
private readonly HashSet<EntityUid> _edgeGrowths = new ();
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
SubscribeLocalEvent<SpreaderComponent, ComponentAdd>(SpreaderAddHandler);
|
||||||
|
SubscribeLocalEvent<AirtightChanged>(e => UpdateNearbySpreaders(e.Airtight.OwnerUid, e.Airtight));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SpreaderAddHandler(EntityUid uid, SpreaderComponent component, ComponentAdd args)
|
||||||
|
{
|
||||||
|
if (component.Enabled)
|
||||||
|
_edgeGrowths.Add(uid); // ez
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateNearbySpreaders(EntityUid blocker, AirtightComponent comp)
|
||||||
|
{
|
||||||
|
if (!EntityManager.TryGetComponent<TransformComponent>(blocker, out var transform))
|
||||||
|
return; // how did we get here?
|
||||||
|
|
||||||
|
if (!_mapManager.TryGetGrid(transform.GridID, out var grid)) return;
|
||||||
|
|
||||||
|
for (var i = 0; i < Atmospherics.Directions; i++)
|
||||||
|
{
|
||||||
|
var direction = (AtmosDirection) (1 << i);
|
||||||
|
if (!comp.AirBlockedDirection.IsFlagSet(direction)) continue;
|
||||||
|
|
||||||
|
foreach (var ent in grid.GetInDir(transform.Coordinates, direction.ToDirection()))
|
||||||
|
{
|
||||||
|
if (EntityManager.TryGetComponent<SpreaderComponent>(ent, out var s) && s.Enabled)
|
||||||
|
_edgeGrowths.Add(ent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
_accumulatedFrameTime += frameTime;
|
||||||
|
|
||||||
|
if (!(_accumulatedFrameTime >= 1.0f))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_accumulatedFrameTime -= 1.0f;
|
||||||
|
|
||||||
|
var growthList = _edgeGrowths.ToList();
|
||||||
|
_robustRandom.Shuffle(growthList);
|
||||||
|
|
||||||
|
var successes = 0;
|
||||||
|
foreach (var entity in growthList)
|
||||||
|
{
|
||||||
|
if (!TryGrow(entity)) continue;
|
||||||
|
|
||||||
|
successes += 1;
|
||||||
|
if (successes >= GrowthsPerInterval)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryGrow(EntityUid ent, TransformComponent? transform = null, SpreaderComponent? spreader = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(ent, ref transform, ref spreader, false))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (spreader.Enabled == false) return false;
|
||||||
|
|
||||||
|
if (!_mapManager.TryGetGrid(transform.GridID, out var grid)) return false;
|
||||||
|
|
||||||
|
var didGrow = false;
|
||||||
|
|
||||||
|
for (var i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
var direction = (DirectionFlag) (1 << i);
|
||||||
|
var coords = transform.Coordinates.Offset(direction.AsDir().ToVec());
|
||||||
|
if (grid.GetTileRef(coords).Tile.IsEmpty || _robustRandom.Prob(spreader.Chance)) continue;
|
||||||
|
var ents = grid.GetLocal(coords);
|
||||||
|
|
||||||
|
if (ents.Any(x => IsTileBlockedFrom(x, direction))) continue;
|
||||||
|
|
||||||
|
// Ok, spawn a plant
|
||||||
|
didGrow = true;
|
||||||
|
EntityManager.SpawnEntity(spreader.GrowthResult, transform.Coordinates.Offset(direction.AsDir().ToVec()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return didGrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnableSpreader(EntityUid ent, SpreaderComponent? component = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(ent, ref component))
|
||||||
|
return;
|
||||||
|
component.Enabled = true;
|
||||||
|
_edgeGrowths.Add(ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsTileBlockedFrom(EntityUid ent, DirectionFlag dir)
|
||||||
|
{
|
||||||
|
if (EntityManager.TryGetComponent<SpreaderComponent>(ent, out _))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!EntityManager.TryGetComponent<AirtightComponent>(ent, out var airtight))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var oppositeDir = dir.AsDir().GetOpposite().ToAtmosDirection();
|
||||||
|
|
||||||
|
return airtight.AirBlocked && airtight.AirBlockedDirection.IsFlagSet(oppositeDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -92,7 +92,7 @@ namespace Content.Server.StationEvents.Events
|
|||||||
base.Startup();
|
base.Startup();
|
||||||
|
|
||||||
// Essentially we'll pick out a target amount of gas to leak, then a rate to leak it at, then work out the duration from there.
|
// Essentially we'll pick out a target amount of gas to leak, then a rate to leak it at, then work out the duration from there.
|
||||||
if (TryFindRandomTile(out _targetTile))
|
if (TryFindRandomTile(out _targetTile, out _targetStation, out _targetGrid, out _targetCoords))
|
||||||
{
|
{
|
||||||
_foundTile = true;
|
_foundTile = true;
|
||||||
|
|
||||||
@@ -168,40 +168,5 @@ namespace Content.Server.StationEvents.Events
|
|||||||
SoundSystem.Play(Filter.Pvs(_targetCoords), "/Audio/Effects/sparks4.ogg", _targetCoords);
|
SoundSystem.Play(Filter.Pvs(_targetCoords), "/Audio/Effects/sparks4.ogg", _targetCoords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryFindRandomTile(out Vector2i tile)
|
|
||||||
{
|
|
||||||
tile = default;
|
|
||||||
|
|
||||||
_targetStation = _robustRandom.Pick(_entityManager.EntityQuery<StationComponent>().ToArray()).Station;
|
|
||||||
var possibleTargets = _entityManager.EntityQuery<StationComponent>()
|
|
||||||
.Where(x => x.Station == _targetStation).ToArray();
|
|
||||||
_targetGrid = _robustRandom.Pick(possibleTargets).Owner;
|
|
||||||
|
|
||||||
if (!_entityManager.TryGetComponent<IMapGridComponent>(_targetGrid!.Uid, out var gridComp))
|
|
||||||
return false;
|
|
||||||
var grid = gridComp.Grid;
|
|
||||||
|
|
||||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
|
||||||
var found = false;
|
|
||||||
var gridBounds = grid.WorldBounds;
|
|
||||||
var gridPos = grid.WorldPosition;
|
|
||||||
|
|
||||||
for (var i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
var randomX = _robustRandom.Next((int) gridBounds.Left, (int) gridBounds.Right);
|
|
||||||
var randomY = _robustRandom.Next((int) gridBounds.Bottom, (int) gridBounds.Top);
|
|
||||||
|
|
||||||
tile = new Vector2i(randomX - (int) gridPos.X, randomY - (int) gridPos.Y);
|
|
||||||
if (atmosphereSystem.IsTileSpace(grid, tile) || atmosphereSystem.IsTileAirBlocked(grid, tile)) continue;
|
|
||||||
found = true;
|
|
||||||
_targetCoords = grid.GridTileToLocal(tile);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
55
Content.Server/StationEvents/Events/KudzuGrowth.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using Content.Shared.Station;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Log;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
|
namespace Content.Server.StationEvents.Events;
|
||||||
|
|
||||||
|
public class KudzuGrowth : StationEvent
|
||||||
|
{
|
||||||
|
[Dependency] private IRobustRandom _robustRandom = default!;
|
||||||
|
[Dependency] private IEntityManager _entityManager = default!;
|
||||||
|
|
||||||
|
public override string Name => "KudzuGrowth";
|
||||||
|
|
||||||
|
public override string? StartAnnouncement =>
|
||||||
|
Loc.GetString("station-event-kudzu-growth-start-announcement");
|
||||||
|
|
||||||
|
public override string? StartAudio => "/Audio/Announcements/bloblarm.ogg";
|
||||||
|
|
||||||
|
public override int EarliestStart => 15;
|
||||||
|
|
||||||
|
public override int MinimumPlayers => 15;
|
||||||
|
|
||||||
|
// Get players to scatter a bit looking for it.
|
||||||
|
protected override float StartAfter => 50f;
|
||||||
|
|
||||||
|
// Give crew at least 9 minutes to either have it gone, or to suffer another event. Kudzu is not actually required to be dead for another event to roll.
|
||||||
|
protected override float EndAfter => 60*4;
|
||||||
|
|
||||||
|
private IEntity? _targetGrid;
|
||||||
|
|
||||||
|
private Vector2i _targetTile;
|
||||||
|
|
||||||
|
private EntityCoordinates _targetCoords;
|
||||||
|
|
||||||
|
public override void Startup()
|
||||||
|
{
|
||||||
|
base.Startup();
|
||||||
|
|
||||||
|
// Pick a place to plant the kudzu.
|
||||||
|
if (TryFindRandomTile(out _targetTile, out _, out _targetGrid, out _targetCoords, _robustRandom, _entityManager))
|
||||||
|
{
|
||||||
|
_entityManager.SpawnEntity("Kudzu", _targetCoords);
|
||||||
|
Logger.InfoS("stationevents", $"Spawning a Kudzu at {_targetTile} on {_targetGrid}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the kudzu tile selection fails we just let the announcement happen anyways because it's funny and people
|
||||||
|
// will be hunting the non-existent, dangerous plant.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
|
using System.Linq;
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
|
using Content.Server.Atmos.EntitySystems;
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
|
using Content.Server.Station;
|
||||||
using Content.Shared.Administration.Logs;
|
using Content.Shared.Administration.Logs;
|
||||||
|
using Content.Shared.Station;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
namespace Content.Server.StationEvents.Events
|
namespace Content.Server.StationEvents.Events
|
||||||
{
|
{
|
||||||
@@ -178,5 +185,45 @@ namespace Content.Server.StationEvents.Events
|
|||||||
Running = false;
|
Running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static bool TryFindRandomTile(out Vector2i tile, out StationId targetStation, out IEntity? targetGrid, out EntityCoordinates targetCoords, IRobustRandom? robustRandom = null, IEntityManager? entityManager = null)
|
||||||
|
{
|
||||||
|
tile = default;
|
||||||
|
robustRandom ??= IoCManager.Resolve<IRobustRandom>();
|
||||||
|
entityManager ??= IoCManager.Resolve<IEntityManager>();
|
||||||
|
|
||||||
|
targetCoords = EntityCoordinates.Invalid;
|
||||||
|
targetStation = robustRandom.Pick(entityManager.EntityQuery<StationComponent>().ToArray()).Station;
|
||||||
|
var t = targetStation; // thanks C#
|
||||||
|
var possibleTargets = entityManager.EntityQuery<StationComponent>()
|
||||||
|
.Where(x => x.Station == t).ToArray();
|
||||||
|
targetGrid = robustRandom.Pick(possibleTargets).Owner;
|
||||||
|
|
||||||
|
if (!entityManager.TryGetComponent<IMapGridComponent>(targetGrid!.Uid, out var gridComp))
|
||||||
|
return false;
|
||||||
|
var grid = gridComp.Grid;
|
||||||
|
|
||||||
|
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||||
|
var found = false;
|
||||||
|
var gridBounds = grid.WorldBounds;
|
||||||
|
var gridPos = grid.WorldPosition;
|
||||||
|
|
||||||
|
for (var i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
var randomX = robustRandom.Next((int) gridBounds.Left, (int) gridBounds.Right);
|
||||||
|
var randomY = robustRandom.Next((int) gridBounds.Bottom, (int) gridBounds.Top);
|
||||||
|
|
||||||
|
tile = new Vector2i(randomX - (int) gridPos.X, randomY - (int) gridPos.Y);
|
||||||
|
if (atmosphereSystem.IsTileSpace(grid, tile) || atmosphereSystem.IsTileAirBlocked(grid, tile)) continue;
|
||||||
|
found = true;
|
||||||
|
targetCoords = grid.GridTileToLocal(tile);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Content.Server.Temperature.Components
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent<IPhysBody>(out var physics))
|
if (Owner.TryGetComponent<IPhysBody>(out var physics) && physics.Mass != 0)
|
||||||
{
|
{
|
||||||
return SpecificHeat * physics.Mass;
|
return SpecificHeat * physics.Mass;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,17 +71,22 @@ namespace Content.Shared.DrawDepth
|
|||||||
|
|
||||||
Doors = DrawDepthTag.Default + 5,
|
Doors = DrawDepthTag.Default + 5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stuff that needs to draw over most things, but not effects, like Kudzu.
|
||||||
|
/// </summary>
|
||||||
|
Overdoors = DrawDepthTag.Default + 6,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Explosions, fire, melee swings. Whatever.
|
/// Explosions, fire, melee swings. Whatever.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Effects = DrawDepthTag.Default + 6,
|
Effects = DrawDepthTag.Default + 7,
|
||||||
|
|
||||||
Ghosts = DrawDepthTag.Default + 7,
|
Ghosts = DrawDepthTag.Default + 8,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use this selectively if it absolutely needs to be drawn above (almost) everything else. Examples include
|
/// Use this selectively if it absolutely needs to be drawn above (almost) everything else. Examples include
|
||||||
/// the pointing arrow, the drag & drop ghost-entity, and some debug tools.
|
/// the pointing arrow, the drag & drop ghost-entity, and some debug tools.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Overlays = DrawDepthTag.Default + 8,
|
Overlays = DrawDepthTag.Default + 9,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
Content.Shared/Kudzu/KudzuVisuals.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
namespace Content.Shared.Kudzu;
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum KudzuVisuals
|
||||||
|
{
|
||||||
|
GrowthLevel,
|
||||||
|
Variant
|
||||||
|
}
|
||||||
18
Content.Shared/Movement/Components/SlowContactsComponent.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
|
namespace Content.Shared.Movement.Components;
|
||||||
|
|
||||||
|
[NetworkedComponent, RegisterComponent]
|
||||||
|
public class SlowContactsComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "SlowContacts";
|
||||||
|
|
||||||
|
[ViewVariables, DataField("walkSpeedModifier")]
|
||||||
|
public float WalkSpeedModifier { get; private set; } = 1.0f;
|
||||||
|
|
||||||
|
[ViewVariables, DataField("sprintSpeedModifier")]
|
||||||
|
public float SprintSpeedModifier { get; private set; } = 1.0f;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Movement.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Exists just to listen to a single event. What a life.
|
||||||
|
/// </summary>
|
||||||
|
[NetworkedComponent, RegisterComponent]
|
||||||
|
public class SlowsOnContactComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "SlowsOnContact";
|
||||||
|
}
|
||||||
77
Content.Shared/Movement/EntitySystems/SlowContactsSystem.cs
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Content.Shared.Movement.Components;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Log;
|
||||||
|
using Robust.Shared.Physics.Dynamics;
|
||||||
|
|
||||||
|
namespace Content.Shared.Movement.EntitySystems;
|
||||||
|
|
||||||
|
public class SlowContactsSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
|
[Dependency] private readonly MovementSpeedModifierSystem _speedModifierSystem = default!;
|
||||||
|
|
||||||
|
private readonly Dictionary<EntityUid, int> _statusCapableInContact = new();
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<SlowContactsComponent, StartCollideEvent>(OnEntityEnter);
|
||||||
|
SubscribeLocalEvent<SlowContactsComponent, EndCollideEvent>(OnEntityExit);
|
||||||
|
SubscribeLocalEvent<SlowsOnContactComponent, RefreshMovementSpeedModifiersEvent>(MovementSpeedCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MovementSpeedCheck(EntityUid uid, SlowsOnContactComponent component, RefreshMovementSpeedModifiersEvent args)
|
||||||
|
{
|
||||||
|
if (!_statusCapableInContact.ContainsKey(uid) || _statusCapableInContact[uid] <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!EntityManager.TryGetComponent<PhysicsComponent>(uid, out var physicsComponent))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var walkSpeed = 1.0f;
|
||||||
|
var sprintSpeed = 1.0f;
|
||||||
|
|
||||||
|
foreach (var colliding in _physics.GetCollidingEntities(physicsComponent))
|
||||||
|
{
|
||||||
|
var ent = colliding.OwnerUid;
|
||||||
|
if (!EntityManager.TryGetComponent<SlowContactsComponent>(ent, out var slowContactsComponent))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
walkSpeed = Math.Min(walkSpeed, slowContactsComponent.WalkSpeedModifier);
|
||||||
|
sprintSpeed = Math.Min(sprintSpeed, slowContactsComponent.SprintSpeedModifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
args.ModifySpeed(walkSpeed, sprintSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEntityExit(EntityUid uid, SlowContactsComponent component, EndCollideEvent args)
|
||||||
|
{
|
||||||
|
var otherUid = args.OtherFixture.Body.OwnerUid;
|
||||||
|
if (!EntityManager.HasComponent<MovementSpeedModifierComponent>(otherUid)
|
||||||
|
|| !EntityManager.HasComponent<SlowsOnContactComponent>(otherUid))
|
||||||
|
return;
|
||||||
|
if (!_statusCapableInContact.ContainsKey(otherUid))
|
||||||
|
Logger.ErrorS("slowscontacts", $"The entity {otherUid} left a body ({uid}) it was never in.");
|
||||||
|
_statusCapableInContact[otherUid]--;
|
||||||
|
if (_statusCapableInContact[otherUid] == 0)
|
||||||
|
EntityManager.RemoveComponent<SlowsOnContactComponent>(otherUid);
|
||||||
|
_speedModifierSystem.RefreshMovementSpeedModifiers(otherUid);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEntityEnter(EntityUid uid, SlowContactsComponent component, StartCollideEvent args)
|
||||||
|
{
|
||||||
|
var otherUid = args.OtherFixture.Body.OwnerUid;
|
||||||
|
if (!EntityManager.HasComponent<MovementSpeedModifierComponent>(otherUid))
|
||||||
|
return;
|
||||||
|
if (!_statusCapableInContact.ContainsKey(otherUid))
|
||||||
|
_statusCapableInContact[otherUid] = 0;
|
||||||
|
_statusCapableInContact[otherUid]++;
|
||||||
|
if (!EntityManager.HasComponent<SlowsOnContactComponent>(otherUid))
|
||||||
|
EntityManager.AddComponent<SlowsOnContactComponent>(otherUid);
|
||||||
|
_speedModifierSystem.RefreshMovementSpeedModifiers(otherUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
station-event-kudzu-growth-start-announcement = Attention crew, we have detected a Type 2 Biological Invader on-station, that poses potentially serious threat to crew productivity. We advise you to exterminate it.
|
||||||
@@ -290,7 +290,6 @@
|
|||||||
proper: true
|
proper: true
|
||||||
- type: StandingState
|
- type: StandingState
|
||||||
- type: DoorBumpOpener
|
- type: DoorBumpOpener
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
save: false
|
save: false
|
||||||
name: Urist McHands
|
name: Urist McHands
|
||||||
|
|||||||
62
Resources/Prototypes/Entities/Objects/Misc/kudzu.yml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
- type: entity
|
||||||
|
id: Kudzu
|
||||||
|
name: kudzu
|
||||||
|
description: A rapidly growing, dangerous plant. WHY ARE YOU STOPPING TO LOOK AT IT?!
|
||||||
|
placement:
|
||||||
|
mode: SnapgridCenter
|
||||||
|
snap:
|
||||||
|
- Wall
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Misc/kudzu.rsi
|
||||||
|
state: kudzu_11
|
||||||
|
drawdepth: Overdoors
|
||||||
|
netsync: false
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: KudzuVisualizer
|
||||||
|
- type: Clickable
|
||||||
|
- type: Transform
|
||||||
|
anchored: true
|
||||||
|
- type: Physics
|
||||||
|
fixtures:
|
||||||
|
- hard: false
|
||||||
|
mass: 7
|
||||||
|
shape:
|
||||||
|
!type:PhysShapeAabb
|
||||||
|
bounds: "-0.5,-0.5,0.5,0.5"
|
||||||
|
layer:
|
||||||
|
- MobImpassable
|
||||||
|
- type: Damageable
|
||||||
|
damageModifierSet: Wood
|
||||||
|
- type: Destructible
|
||||||
|
thresholds:
|
||||||
|
- trigger:
|
||||||
|
!type:DamageTrigger
|
||||||
|
damage: 10
|
||||||
|
behaviors:
|
||||||
|
- !type:DoActsBehavior
|
||||||
|
acts: [ "Destruction" ]
|
||||||
|
- type: Temperature
|
||||||
|
heatDamage:
|
||||||
|
types:
|
||||||
|
Heat: 5
|
||||||
|
- type: Flammable
|
||||||
|
fireSpread: true #If you walk into incredibly dense, flaming vines, you can expect to burn.
|
||||||
|
cold:
|
||||||
|
types: {}
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Heat: 1
|
||||||
|
- type: Reactive
|
||||||
|
groups:
|
||||||
|
Flammable: [Touch]
|
||||||
|
Extinguish: [Touch]
|
||||||
|
- type: AtmosExposed
|
||||||
|
- type: Spreader
|
||||||
|
growthResult: Kudzu
|
||||||
|
- type: GrowingKudzu
|
||||||
|
growthTickSkipChance: 0.1666
|
||||||
|
- type: SlowContacts
|
||||||
|
walkSpeedModifier: 0.2
|
||||||
|
sprintSpeedModifier: 0.2
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
damage:
|
damage:
|
||||||
types:
|
types:
|
||||||
Blunt: 10
|
Blunt: 10
|
||||||
|
Heat: 10 # Hotfix to make kudzu die.
|
||||||
- type: ItemStatus
|
- type: ItemStatus
|
||||||
- type: RefillableSolution
|
- type: RefillableSolution
|
||||||
solution: Welder
|
solution: Welder
|
||||||
|
|||||||
BIN
Resources/Textures/Objects/Misc/kudzu.rsi/kudzu_11.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Resources/Textures/Objects/Misc/kudzu.rsi/kudzu_12.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Resources/Textures/Objects/Misc/kudzu.rsi/kudzu_13.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
Resources/Textures/Objects/Misc/kudzu.rsi/kudzu_21.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
Resources/Textures/Objects/Misc/kudzu.rsi/kudzu_22.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
Resources/Textures/Objects/Misc/kudzu.rsi/kudzu_23.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Resources/Textures/Objects/Misc/kudzu.rsi/kudzu_31.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Resources/Textures/Objects/Misc/kudzu.rsi/kudzu_32.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Resources/Textures/Objects/Misc/kudzu.rsi/kudzu_33.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
38
Resources/Textures/Objects/Misc/kudzu.rsi/meta.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC-BY-SA-3.0",
|
||||||
|
"copyright": "https://github.com/tgstation/tgstation/commit/15bf91049e33979a855995579b48592e34bcdd8c",
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "kudzu_33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kudzu_32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kudzu_31"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kudzu_23"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kudzu_22"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kudzu_21"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kudzu_13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kudzu_12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kudzu_11"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||