Skip to content

Commit

Permalink
Merge pull request #468 from Fansana/master
Browse files Browse the repository at this point in the history
Floofstation Release V11
  • Loading branch information
Fansana authored Jan 9, 2025
2 parents 2894449 + a625a1f commit 9693186
Show file tree
Hide file tree
Showing 557 changed files with 1,440,235 additions and 1,088,760 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Floofstation CODEOWNERS

* @Fansana @Memeji @FoxxoTrystan
* @Fansana @Memeji @FoxxoTrystan @Mnemotechnician
13 changes: 8 additions & 5 deletions Content.Client/Effects/ColorFlashEffectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ private void OnEffectAnimationCompleted(EntityUid uid, ColorFlashEffectComponent
sprite.Color = component.Color;
}

RemCompDeferred<ColorFlashEffectComponent>(uid);
// Floof - commented this out due to a race condition. It's quite complicated to explain;
// in short terms, don't do deferred component removal when dealing with concurrent tasks concerning the same component.
// RemCompDeferred<ColorFlashEffectComponent>(uid);
}

private Animation? GetDamageAnimation(EntityUid uid, Color color, SpriteComponent? sprite = null)
Expand Down Expand Up @@ -107,10 +109,11 @@ private void OnColorFlashEffect(ColorFlashEffectEvent ev)
continue;
}

if (TryComp<ColorFlashEffectComponent>(ent, out var effect))
{
sprite.Color = effect.Color;
}
// Floof - commented out. This is handled by the animation complete event.
// if (TryComp<ColorFlashEffectComponent>(ent, out var effect))
// {
// sprite.Color = effect.Color;
// }

var animation = GetDamageAnimation(ent, color, sprite);

Expand Down
82 changes: 82 additions & 0 deletions Content.Client/Shuttles/FtlArrivalOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System.Numerics;
using Content.Shared.Shuttles.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Client.Shuttles;

/// <summary>
/// Plays a visualization whenever a shuttle is arriving from FTL.
/// </summary>
public sealed class FtlArrivalOverlay : Overlay
{
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowEntities;

private EntityLookupSystem _lookups;
private SharedMapSystem _maps;
private SharedTransformSystem _transforms;
private SpriteSystem _sprites;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _protos = default!;

private readonly HashSet<Entity<FtlVisualizerComponent>> _visualizers = new();

private ShaderInstance _shader;

public FtlArrivalOverlay()
{
IoCManager.InjectDependencies(this);
_lookups = _entManager.System<EntityLookupSystem>();
_transforms = _entManager.System<SharedTransformSystem>();
_maps = _entManager.System<SharedMapSystem>();
_sprites = _entManager.System<SpriteSystem>();

_shader = _protos.Index<ShaderPrototype>("unshaded").Instance();
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
_visualizers.Clear();
_lookups.GetEntitiesOnMap(args.MapId, _visualizers);

return _visualizers.Count > 0;
}

protected override void Draw(in OverlayDrawArgs args)
{
args.WorldHandle.UseShader(_shader);

foreach (var (uid, comp) in _visualizers)
{
var grid = comp.Grid;

if (!_entManager.TryGetComponent(grid, out MapGridComponent? mapGrid))
continue;

var texture = _sprites.GetFrame(comp.Sprite, TimeSpan.FromSeconds(comp.Elapsed), loop: false);
comp.Elapsed += (float) _timing.FrameTime.TotalSeconds;

// Need to manually transform the viewport in terms of the visualizer entity as the grid isn't in position.
var (_, _, worldMatrix, invMatrix) = _transforms.GetWorldPositionRotationMatrixWithInv(uid);
args.WorldHandle.SetTransform(worldMatrix);
var localAABB = invMatrix.TransformBox(args.WorldBounds);

var tilesEnumerator = _maps.GetLocalTilesEnumerator(grid, mapGrid, localAABB);

while (tilesEnumerator.MoveNext(out var tile))
{
var bounds = _lookups.GetLocalBounds(tile, mapGrid.TileSize);

args.WorldHandle.DrawTextureRect(texture, bounds);
}
}

args.WorldHandle.UseShader(null);
args.WorldHandle.SetTransform(Matrix3x2.Identity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public bool EnableShuttlePosition
private bool _enableShuttlePosition;
private EmergencyShuttleOverlay? _overlay;

public override void Initialize()
private void InitializeEmergency()
{
base.Initialize();
SubscribeNetworkEvent<EmergencyShuttlePositionMessage>(OnShuttlePosMessage);
}

Expand Down
21 changes: 21 additions & 0 deletions Content.Client/Shuttles/Systems/ShuttleSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Robust.Client.Graphics;

namespace Content.Client.Shuttles.Systems;

public sealed partial class ShuttleSystem
{
[Dependency] private readonly IOverlayManager _overlays = default!;

public override void Initialize()
{
base.Initialize();
InitializeEmergency();
_overlays.AddOverlay(new FtlArrivalOverlay());
}

public override void Shutdown()
{
base.Shutdown();
_overlays.RemoveOverlay<FtlArrivalOverlay>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected async Task<EntityUid> SpawnEntity(EntitySpecifier spec, EntityCoordina
{
await Server.WaitPost(() =>
{
uid = SEntMan.SpawnEntity(stackProto.Spawn, coords);
uid = SEntMan.SpawnAtPosition(stackProto.Spawn, coords);
Stack.SetCount(uid, spec.Quantity);
});
return uid;
Expand All @@ -114,13 +114,13 @@ await Server.WaitPost(() =>
return await SpawnEntity((stack.StackTypeId, spec.Quantity), coords);

Assert.That(spec.Quantity, Is.EqualTo(1), "SpawnEntity only supports returning a singular entity");
await Server.WaitPost(() => uid = SEntMan.SpawnEntity(spec.Prototype, coords));
await Server.WaitPost(() => uid = SEntMan.SpawnAtPosition(spec.Prototype, coords));
return uid;
}

/// <summary>
/// Convert an entity-uid to a matching entity specifier. Useful when doing entity lookups & checking that the
/// right quantity of entities/materials werre produced. Returns null if passed an entity with a null prototype.
/// right quantity of entities/materials were produced. Returns null if passed an entity with a null prototype.
/// </summary>
protected EntitySpecifier? ToEntitySpecifier(EntityUid uid)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected async Task SpawnTarget(string prototype)
Target = NetEntity.Invalid;
await Server.WaitPost(() =>
{
Target = SEntMan.GetNetEntity(SEntMan.SpawnEntity(prototype, SEntMan.GetCoordinates(TargetCoords)));
Target = SEntMan.GetNetEntity(SEntMan.SpawnAtPosition(prototype, SEntMan.GetCoordinates(TargetCoords)));
});

await RunTicks(5);
Expand Down
3 changes: 2 additions & 1 deletion Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public sealed class PostMapInitTest
"Lighthouse", //DeltaV
"Submarine", //DeltaV
"Gax",
"Rad"
"Rad",
"Kettle"
};

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Carrying/CarryingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ private void Carry(EntityUid carrier, EntityUid carried)
if (TryComp<PullableComponent>(carried, out var pullable))
_pullingSystem.TryStopPull(carried, pullable);

EnsureComp<KnockedDownComponent>(carried); // Floof - moved this statement up because some systems can break carrying in response to knockdown
_transform.AttachToGridOrMap(carrier);
_transform.AttachToGridOrMap(carried);
_transform.SetCoordinates(carried, Transform(carrier).Coordinates);
Expand All @@ -282,7 +283,6 @@ private void Carry(EntityUid carrier, EntityUid carried)
var carryingComp = EnsureComp<CarryingComponent>(carrier);
ApplyCarrySlowdown(carrier, carried);
var carriedComp = EnsureComp<BeingCarriedComponent>(carried);
EnsureComp<KnockedDownComponent>(carried);

carryingComp.Carried = carried;
carriedComp.Carrier = carrier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Consent;


namespace Content.Server.DeltaV.ParadoxAnomaly.Systems;

Expand All @@ -26,6 +28,7 @@ namespace Content.Server.DeltaV.ParadoxAnomaly.Systems;
/// </summary>
public sealed class ParadoxAnomalySystem : EntitySystem
{
[Dependency] private readonly ConsentSystem _consent = default!;
[Dependency] private readonly GenericAntagSystem _genericAntag = default!;
[Dependency] private readonly GhostRoleSystem _ghostRole = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
Expand Down Expand Up @@ -81,6 +84,9 @@ private bool TrySpawnParadoxAnomaly(string rule, [NotNullWhen(true)] out EntityU
if (_role.MindIsAntagonist(mindId))
continue;

if (_consent.HasConsent(uid, "NoClone"))
continue;

// TODO: when metempsychosis real skip whoever has Karma

candidates.Add((uid, mindId, species, profile));
Expand Down
17 changes: 17 additions & 0 deletions Content.Server/FloofStation/HideoutGeneratorComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Robust.Shared.Map;


namespace Content.Server.FloofStation;


[RegisterComponent]
public sealed partial class HideoutGeneratorComponent : Component
{

/// <summary>
/// Maps we've generated.
/// </summary>
[DataField]
public List<MapId> Generated = new();

}
23 changes: 19 additions & 4 deletions Content.Server/FloofStation/TheDarkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ public sealed class TheDarkSystem : EntitySystem
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RoundStartingEvent>(SetupTheDark);
SubscribeLocalEvent<HideoutGeneratorComponent, MapInitEvent>(SetupTheDark);
SubscribeLocalEvent<HideoutGeneratorComponent, ComponentShutdown>(DestroyTheDark);
}

private void SetupTheDark(RoundStartingEvent ev)
private void SetupTheDark(EntityUid uid, HideoutGeneratorComponent component, MapInitEvent args)
{
Logger.Debug(uid.ToString());
var mapId = _mapManager.CreateMap();
_mapManager.AddUninitializedMap(mapId);

Expand All @@ -30,7 +31,21 @@ private void SetupTheDark(RoundStartingEvent ev)
{
EnsureComp<PreventPilotComponent>(id);
}

component.Generated.Add(mapId);
_mapManager.DoMapInitialize(mapId);
}

private void DestroyTheDark(EntityUid uid, HideoutGeneratorComponent component, ComponentShutdown args)
{

foreach (var mapId in component.Generated)
{
if (!_mapManager.MapExists(mapId))
continue;

_mapManager.DeleteMap(mapId);
}


}
}
46 changes: 46 additions & 0 deletions Content.Server/Fluids/EntitySystems/AbsorbentSystem.Footprints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Linq;
using Content.Shared.Chemistry.Components;
using Content.Shared.Fluids;
using Content.Shared.FootPrint;
using Content.Shared.Timing;


namespace Content.Server.Fluids.EntitySystems;


// Floof-specific
public sealed partial class AbsorbentSystem
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;

/// <summary>
/// Tries to clean a number of footprints in a range determined by the component. Returns the number of cleaned footprints.
/// </summary>
private int TryCleanNearbyFootprints(EntityUid user, EntityUid used, EntityUid target, AbsorbentComponent component, Entity<SolutionComponent> absorbentSoln)
{
var footprintQuery = GetEntityQuery<FootPrintComponent>();
var targetCoords = Transform(target).Coordinates;
var entities = _lookup.GetEntitiesInRange(targetCoords, component.FootprintCleaningRange, LookupFlags.Uncontained);

// Take up to [MaxCleanedFootprints] footprints closest to the target
var cleaned = entities.AsEnumerable()
.Where(footprintQuery.HasComp)
.Select(uid => (uid, dst: Transform(uid).Coordinates.TryDistance(EntityManager, _transform, targetCoords, out var dst) ? dst : 0f))
.Where(ent => ent.dst > 0f)
.OrderBy(ent => ent.dst)
.Select(ent => (ent.uid, comp: footprintQuery.GetComponent(ent.uid)));

// And try to interact with each one of them, ignoring useDelay
var processed = 0;
foreach (var (uid, footprintComp) in cleaned)
{
if (TryPuddleInteract(user, used, uid, component, useDelay: null, absorbentSoln))
processed++;

if (processed >= component.MaxCleanedFootprints)
break;
}

return processed;
}
}
4 changes: 3 additions & 1 deletion Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace Content.Server.Fluids.EntitySystems;

/// <inheritdoc/>
public sealed class AbsorbentSystem : SharedAbsorbentSystem
public sealed partial class AbsorbentSystem : SharedAbsorbentSystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly AudioSystem _audio = default!;
Expand Down Expand Up @@ -119,6 +119,8 @@ public void Mop(EntityUid user, EntityUid target, EntityUid used, AbsorbentCompo
if (!TryRefillableInteract(user, used, target, component, useDelay, absorberSoln.Value))
return;
}

TryCleanNearbyFootprints(user, used, target, component, absorberSoln.Value); // Floof
}

/// <summary>
Expand Down
Loading

0 comments on commit 9693186

Please sign in to comment.