Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ngines into merge-of-the-e-and-the-e
  • Loading branch information
sleepyyapril committed Feb 14, 2025
2 parents 76356bc + 21500f3 commit 250b59c
Show file tree
Hide file tree
Showing 48 changed files with 1,017 additions and 366 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Content.Server.Botany.Systems;
using Content.Shared.EntityEffects;

namespace Content.Server.EntityEffects.Effects.PlantMetabolism;

/// <summary>
/// Handles increase or decrease of plant potency.
/// </summary>

public sealed partial class PlantAdjustPotency : PlantAdjustAttribute
{
public override string GuidebookAttributeName { get; set; } = "plant-attribute-potency";

public override void Effect(EntityEffectBaseArgs args)
{
if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager))
return;

if (plantHolderComp.Seed == null)
return;

var plantHolder = args.EntityManager.System<PlantHolderSystem>();

plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp);

plantHolderComp.Seed.Potency = Math.Max(plantHolderComp.Seed.Potency + Amount, 1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Content.Server.Botany.Components;
using Content.Server.Botany.Systems;
using Content.Shared.EntityEffects;
using Content.Shared.Popups;
using Robust.Shared.Prototypes;

namespace Content.Server.EntityEffects.Effects.PlantMetabolism;

/// <summary>
/// Handles removal of seeds on a plant.
/// </summary>

public sealed partial class PlantDestroySeeds : EntityEffect
{
public override void Effect(EntityEffectBaseArgs args)
{
if (
!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp)
|| plantHolderComp.Seed == null
|| plantHolderComp.Dead
|| plantHolderComp.Seed.Immutable
)
return;

var plantHolder = args.EntityManager.System<PlantHolderSystem>();
var popupSystem = args.EntityManager.System<SharedPopupSystem>();

if (plantHolderComp.Seed.Seedless == false)
{
plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp);
popupSystem.PopupEntity(
Loc.GetString("botany-plant-seedsdestroyed"),
args.TargetEntity,
PopupType.SmallCaution
);
plantHolderComp.Seed.Seedless = true;
}
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
Loc.GetString("reagent-effect-guidebook-plant-seeds-remove", ("chance", Probability));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Server.Botany.Components;
using Content.Server.Botany.Systems;
using Content.Shared.EntityEffects;
using Content.Shared.Popups;
using Robust.Shared.Prototypes;

namespace Content.Server.EntityEffects.Effects.PlantMetabolism;

/// <summary>
/// Handles restoral of seeds on a plant.
/// </summary>

public sealed partial class PlantRestoreSeeds : EntityEffect
{
public override void Effect(EntityEffectBaseArgs args)
{
if (
!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp)
|| plantHolderComp.Seed == null
|| plantHolderComp.Dead
|| plantHolderComp.Seed.Immutable
)
return;

var plantHolder = args.EntityManager.System<PlantHolderSystem>();
var popupSystem = args.EntityManager.System<SharedPopupSystem>();

if (plantHolderComp.Seed.Seedless)
{
plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp);
popupSystem.PopupEntity(Loc.GetString("botany-plant-seedsrestored"), args.TargetEntity);
plantHolderComp.Seed.Seedless = false;
}
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
Loc.GetString("reagent-effect-guidebook-plant-seeds-add", ("chance", Probability));
}
12 changes: 12 additions & 0 deletions Content.Server/Shuttles/Components/ShuttleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,17 @@ public sealed partial class ShuttleComponent : Component

[DataField("angularDamping"), ViewVariables(VVAccess.ReadWrite)]
public float AngularDamping = 0.05f;

/// <summary>
/// How far from the shuttle's bounding box will it crush and destroy things?
/// </summary>
[DataField]
public float SmimshDistance = 0.2f;

/// <summary>
/// Whether or not the shuttle calls the DoTheDinosaur function upon FTL'ing. I'm not explaining this, you owe it to yourself to do a code search for it.
/// </summary>
[DataField]
public bool DoTheDinosaur = true;
}
}
30 changes: 30 additions & 0 deletions Content.Server/Shuttles/Components/ShuttleConsoleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,35 @@ public sealed partial class ShuttleConsoleComponent : SharedShuttleConsoleCompon
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("whitelistSpecific")]
public List<EntityUid> FTLWhitelist = new List<EntityUid>();

/// <summary>
/// How far the shuttle is allowed to jump(in meters).
/// TODO: This technically won't work until this component is migrated to Shared. The client console screen will only ever know the hardcoded 512 meter constant otherwise. Fix it in ShuttleMapControl.xaml.cs when that's done.
/// </summary>
[DataField]
public float FTLRange = 512f;

/// <summary>
/// If the shuttle is allowed to "Forcibly" land on planet surfaces, destroying anything it lands on. Used for SSTO capable shuttles.
/// </summary>
[DataField]
public bool FtlToPlanets;

/// <summary>
/// If the shuttle is allowed to forcibly land on stations, smimshing everything it lands on. This is where the hypothetical "Nukie drop pod" comes into play.
/// </summary>
[DataField]
public bool IgnoreExclusionZones;

/// <summary>
/// If the shuttle is only ever allowed to FTL once. Also used for the hypothetical "Nukie drop pod."
/// </summary>
[DataField]
public bool OneWayTrip;

/// <summary>
/// Tracks whether or not the above "One way trip" has been taken.
/// </summary>
public bool OneWayTripTaken;
}
}
10 changes: 9 additions & 1 deletion Content.Server/Shuttles/Systems/ShuttleConsoleSystem.FTL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ private void GetExclusions(ref List<ShuttleExclusionObject>? exclusions)
/// </summary>
private void ConsoleFTL(Entity<ShuttleConsoleComponent> ent, EntityCoordinates targetCoordinates, Angle targetAngle, MapId targetMap)
{
if (ent.Comp.OneWayTrip && ent.Comp.OneWayTripTaken)
{
// TODO: Play a popup and a message in chat explaining you've already taken the one way trip.
return;
}

var consoleUid = GetDroneConsole(ent.Owner);

if (consoleUid == null)
Expand Down Expand Up @@ -143,7 +149,7 @@ private void ConsoleFTL(Entity<ShuttleConsoleComponent> ent, EntityCoordinates t
List<ShuttleExclusionObject>? exclusions = null;
GetExclusions(ref exclusions);

if (!_shuttle.FTLFree(shuttleUid.Value, targetCoordinates, targetAngle, exclusions))
if (!_shuttle.FTLFree(shuttleUid.Value, targetCoordinates, targetAngle, exclusions, ent.Comp.FtlToPlanets, ent.Comp.IgnoreExclusionZones, ent.Comp.FTLRange))
{
return;
}
Expand All @@ -163,5 +169,7 @@ private void ConsoleFTL(Entity<ShuttleConsoleComponent> ent, EntityCoordinates t
RaiseLocalEvent(ref ev);

_shuttle.FTLToCoordinates(shuttleUid.Value, shuttleComp, adjustedCoordinates, targetAngle);
if (ent.Comp.OneWayTrip)
ent.Comp.OneWayTripTaken = true;
}
}
10 changes: 6 additions & 4 deletions Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ private void UpdateFTLStarting(Entity<FTLComponent, ShuttleComponent> entity)
var uid = entity.Owner;
var comp = entity.Comp1;
var xform = _xformQuery.GetComponent(entity);
DoTheDinosaur(xform);

if (entity.Comp2.DoTheDinosaur)
DoTheDinosaur(xform);

comp.State = FTLState.Travelling;
var fromMapUid = xform.MapUid;
Expand Down Expand Up @@ -558,7 +560,7 @@ private void UpdateFTLArriving(Entity<FTLComponent, ShuttleComponent> entity)
comp.StateTime = StartEndTime.FromCurTime(_gameTiming, FTLCooldown);
_console.RefreshShuttleConsoles(uid);
_mapManager.SetMapPaused(mapId, false);
Smimsh(uid, xform: xform);
Smimsh(uid, xform: xform, smimshDistance: entity.Comp2.SmimshDistance);

var ftlEvent = new FTLCompletedEvent(uid, _mapSystem.GetMap(mapId));
RaiseLocalEvent(uid, ref ftlEvent, true);
Expand Down Expand Up @@ -959,7 +961,7 @@ public bool TryFTLProximity(Entity<TransformComponent?> shuttle, EntityCoordinat
/// <summary>
/// Flattens / deletes everything under the grid upon FTL.
/// </summary>
private void Smimsh(EntityUid uid, FixturesComponent? manager = null, MapGridComponent? grid = null, TransformComponent? xform = null)
private void Smimsh(EntityUid uid, FixturesComponent? manager = null, MapGridComponent? grid = null, TransformComponent? xform = null, float smimshDistance = 0.2f)
{
if (!Resolve(uid, ref manager, ref grid, ref xform) || xform.MapUid == null)
return;
Expand All @@ -981,7 +983,7 @@ private void Smimsh(EntityUid uid, FixturesComponent? manager = null, MapGridCom

// Shift it slightly
// Create a small border around it.
aabb = aabb.Enlarged(0.2f);
aabb = aabb.Enlarged(smimshDistance);
aabbs.Add(aabb);

// Handle clearing biome stuff as relevant.
Expand Down
20 changes: 20 additions & 0 deletions Content.Server/Station/Components/StationBiomeComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Server.Station.Systems;
using Content.Shared.Parallax.Biomes;
using Content.Shared.Parallax.Biomes.Markers;
using Content.Shared.Procedural;
using Robust.Shared.Prototypes;

namespace Content.Server.Station.Components;
Expand All @@ -13,6 +15,24 @@ public sealed partial class StationBiomeComponent : Component
[DataField(required: true)]
public ProtoId<BiomeTemplatePrototype> Biome = "Grasslands";

/// <summary>
/// Adds a list of biome marker layers after creating the planet. Useful if you wish to make your planet station also have ores to mine.
/// </summary>
[DataField]
public List<ProtoId<BiomeMarkerLayerPrototype>> BiomeLayers;

/// <summary>
/// Whether your station comes with one or more complimentary dungeons somewhere in the world.
/// </summary>
[DataField]
public List<DungeonConfigPrototype> Dungeons;

[DataField]
public float DungeonMinDistance = 100f;

[DataField]
public float DungeonMaxDistance = 500f;

// If null, its random
[DataField]
public int? Seed = null;
Expand Down
39 changes: 34 additions & 5 deletions Content.Server/Station/Systems/StationBiomeSystem.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
using Content.Server.Parallax;
using Content.Server.Procedural;
using Content.Server.Station.Components;
using Content.Server.Station.Events;
using Content.Server.Station.Systems;
using Robust.Shared.Map;
using Content.Shared.Parallax.Biomes;
using Robust.Server.GameObjects;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

namespace Content.Server.Station.Systems;
public sealed partial class StationBiomeSystem : EntitySystem
{
[Dependency] private readonly BiomeSystem _biome = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly DungeonSystem _dungeon = default!;
[Dependency] private readonly IRobustRandom _random = default!;

public override void Initialize()
{
Expand All @@ -28,8 +33,32 @@ private void OnStationPostInit(Entity<StationBiomeComponent> map, ref StationPos
if (station == null) return;

var mapId = Transform(station.Value).MapID;
var mapUid = _mapManager.GetMapEntityId(mapId);
if (!_mapSystem.TryGetMap(mapId, out var mapUid)
|| mapUid is null) // WHAT, IT'S LITERALLY CALLED TRYGET. WHY DO I NEED TO CHECK NULL?
return;

_biome.EnsurePlanet(mapUid!.Value, _proto.Index(map.Comp.Biome), map.Comp.Seed, mapLight: map.Comp.MapLightColor);

if (!TryComp<BiomeComponent>(mapUid, out var biomeComp))
return; // Yea we JUST made a biome component one line above this trycomp. It turns out I need an engine PR to retrieve the component just added.
// Imagine my frustration. On the other hand AddComps like above aren't guaranteed to return a component anyway.

foreach (var layer in map.Comp.BiomeLayers)
{
if (biomeComp.MarkerLayers.Contains(layer))
continue;

biomeComp.MarkerLayers.Add(layer);
biomeComp.ForcedMarkerLayers.Add(layer);
}
if (!TryComp(mapUid, out MapGridComponent? mapGrid))
return;

_biome.EnsurePlanet(mapUid, _proto.Index(map.Comp.Biome), map.Comp.Seed, mapLight: map.Comp.MapLightColor);
foreach (var dungeonProto in map.Comp.Dungeons)
{
// TODO: Pester TCJ about adding a _random.NextVector2i to Supermatter Engine, as well as adding methods for "officially" casting vector 2s as integer vectors.
var distVector = (Vector2i) _random.NextVector2(map.Comp.DungeonMinDistance, map.Comp.DungeonMaxDistance).Rounded();
_dungeon.GenerateDungeon(dungeonProto, mapUid!.Value, mapGrid, distVector, _random.Next());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Damage;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;

namespace Content.Server.WhiteDream.BloodCult.Runes.Revive;
Expand All @@ -14,9 +14,12 @@ public sealed partial class CultRuneReviveComponent : Component
{
DamageDict = new Dictionary<string, FixedPoint2>
{
["Brute"] = -100,
["Burn"] = -100,
["Heat"] = -100,
["Blunt"] = -33,
["Slash"] = -33,
["Piercing"] = -33,
["Heat"] = -33,
["Cold"] = -33,
["Shock"] = -33,
["Asphyxiation"] = -100,
["Bloodloss"] = -100,
["Poison"] = -50,
Expand Down
16 changes: 16 additions & 0 deletions Content.Server/_EE/SpawnGasOnGib/SpawnGasOnGibComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Shared.Atmos;

namespace Content.Server._EE.SpawnGasOnGib;

// <summary>
// Spawns a gas mixture upon being gibbed.
// </summary>
[RegisterComponent]
public sealed partial class SpawnGasOnGibComponent : Component
{
// <summary>
// The gas mixture to spawn.
// </summary>
[DataField("gasMixture", required: true)]
public GasMixture Gas = new();
}
24 changes: 24 additions & 0 deletions Content.Server/_EE/SpawnGasOnGib/SpawnGasOnGibSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Components;

namespace Content.Server._EE.SpawnGasOnGib;

public sealed partial class SpawnGasOnGibSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmos = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SpawnGasOnGibComponent, BeingGibbedEvent>(OnBeingGibbed);
}

private void OnBeingGibbed(EntityUid uid, SpawnGasOnGibComponent comp, BeingGibbedEvent args)
{
if (_atmos.GetContainingMixture(uid, false, true) is not { } air)
return;

_atmos.Merge(air, comp.Gas);
}
}
Loading

0 comments on commit 250b59c

Please sign in to comment.