Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ngines into ee-merge-several-times-yes
  • Loading branch information
sleepyyapril committed Jan 23, 2025
2 parents 9cd98c3 + 9816bd2 commit e1a8481
Show file tree
Hide file tree
Showing 55 changed files with 599 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/no-submodule-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
this_aint_right:
if: github.actor != 'sleepyyapril'
if: github.actor != 'sleepyyapril' && github.actor != 'VMSolidus' && github.actor != 'DEATHB4DEFEAT'
name: Submodule update in pr found
runs-on: ubuntu-latest
steps:
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ await server.WaitPost(() =>
Assert.That(entityManager.TryGetComponent<MaxTimeRestartRuleComponent>(ruleEntity, out maxTime));
});

Assert.That(server.EntMan.Count<GameRuleComponent>(), Is.EqualTo(1));
Assert.That(server.EntMan.Count<ActiveGameRuleComponent>(), Is.EqualTo(1));
// Assert.That(server.EntMan.Count<GameRuleComponent>(), Is.EqualTo(1));
// Assert.That(server.EntMan.Count<ActiveGameRuleComponent>(), Is.EqualTo(1));

await server.WaitAssertion(() =>
{
Expand All @@ -44,8 +44,8 @@ await server.WaitAssertion(() =>
sGameTicker.StartRound();
});

Assert.That(server.EntMan.Count<GameRuleComponent>(), Is.EqualTo(1));
Assert.That(server.EntMan.Count<ActiveGameRuleComponent>(), Is.EqualTo(1));
// Assert.That(server.EntMan.Count<GameRuleComponent>(), Is.EqualTo(1));
// Assert.That(server.EntMan.Count<ActiveGameRuleComponent>(), Is.EqualTo(1));

await server.WaitAssertion(() =>
{
Expand Down
7 changes: 5 additions & 2 deletions Content.Server/Cloning/CloningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Content.Server.Materials;
using Content.Server.Popups;
using Content.Server.Power.EntitySystems;
using Content.Server.Traits.Assorted;
using Content.Shared.Silicon.Components; // Goobstation
using Content.Shared.Atmos;
using Content.Shared.CCVar;
using Content.Shared.Chemistry.Components;
Expand Down Expand Up @@ -204,13 +204,16 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponen
|| !_playerManager.TryGetSessionById(mind.UserId.Value, out var client)
|| !CheckBiomassCost(uid, physics, clonePod, cloningCostMultiplier))
return false;

// Special handling for humanoid data related to metempsychosis. This function is needed for Paradox Anomaly code to play nice with reincarnated people
var pref = humanoid.LastProfileLoaded;
if (pref == null
|| !_prototypeManager.TryIndex(humanoid.Species, out var speciesPrototype))
return false;

if (HasComp<SiliconComponent>(bodyToClone))
return false; // Goobstation: Don't clone IPCs.

// Yes, this can return true without making a body. If it returns true, we're making clone soup instead.
if (CheckGeneticDamage(uid, bodyToClone, clonePod, out var geneticDamage, failChanceModifier))
return true;
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/GameTicking/GameTicker.GamePreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private bool StartPreset(ICommonSession[] origReadyPlayers, bool force)
return true;

var presetTitle = CurrentPreset != null ? Loc.GetString(CurrentPreset.ModeTitle) : string.Empty;
_sawmill.Info($"Round starting with preset {presetTitle}");

void FailedPresetRestart()
{
Expand Down Expand Up @@ -82,6 +83,8 @@ void FailedPresetRestart()

if (startFailed)
{
var mapName = _gameMapManager.GetSelectedMap()?.MapName ?? "Unknown";
_sawmill.Info($"Failed starting preset {presetTitle} on map {mapName}");
FailedPresetRestart();
return false;
}
Expand Down
2 changes: 0 additions & 2 deletions Content.Server/Mech/Systems/MechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ private void OnMechEntry(EntityUid uid, MechComponent component, MechEntryEvent

TryInsert(uid, args.Args.User, component);
_actionBlocker.UpdateCanMove(uid);

args.Handled = true;
}

Expand All @@ -244,7 +243,6 @@ private void OnMechExit(EntityUid uid, MechComponent component, MechExitEvent ar
return;

TryEject(uid, component);

args.Handled = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ namespace Content.Server.Objectives.Components;
[RegisterComponent, Access(typeof(KillPersonConditionSystem))]
public sealed partial class PickRandomPersonComponent : Component
{
[DataField]
public bool NeedsOrganic; // Goobstation: Only pick non-silicon players.
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void OnPersonAssigned(EntityUid uid, PickRandomPersonComponent comp, ref
return;

// no other humans to kill
var allHumans = _mind.GetAliveHumansExcept(args.MindId);
var allHumans = _mind.GetAliveHumans(args.MindId, comp.NeedsOrganic);
if (allHumans.Count == 0)
{
args.Cancelled = true;
Expand Down Expand Up @@ -101,7 +101,7 @@ private void OnHeadAssigned(EntityUid uid, PickRandomHeadComponent comp, ref Obj
return;

// no other humans to kill
var allHumans = _mind.GetAliveHumansExcept(args.MindId);
var allHumans = _mind.GetAliveHumans(args.MindId);
if (allHumans.Count == 0)
{
args.Cancelled = true;
Expand All @@ -117,7 +117,7 @@ private void OnHeadAssigned(EntityUid uid, PickRandomHeadComponent comp, ref Obj
}

if (allHeads.Count == 0)
allHeads = allHumans; // fallback to non-head target
allHeads = allHumans.Select(human => human.Owner).ToList(); // fallback to non-head target

_target.SetTarget(uid, _random.Pick(allHeads), target);
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/PowerCell/PowerCellSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ private void OnCellEmpAttempt(EntityUid uid, PowerCellComponent component, EmpAt

private void OnCellSlotExamined(EntityUid uid, PowerCellSlotComponent component, ExaminedEvent args)
{
TryGetBatteryFromSlot(uid, out var battery);
OnBatteryExamined(uid, battery, args);
TryGetBatteryFromSlot(uid, out var batteryEnt, out var battery); // Goobstation
OnBatteryExamined(batteryEnt.GetValueOrDefault(uid), battery, args); // Goobstation
}

private void OnBatteryExamined(EntityUid uid, BatteryComponent? component, ExaminedEvent args)
Expand Down
5 changes: 3 additions & 2 deletions Content.Server/Silicon/Charge/Systems/SiliconChargeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ private float SiliconHeatEffects(EntityUid silicon, SiliconComponent siliconComp
if (!_random.Prob(Math.Clamp(temperComp.CurrentTemperature / (upperThresh * 5), 0.001f, 0.9f)))
return hotTempMulti;

_flammable.AdjustFireStacks(silicon, Math.Clamp(siliconComp.FireStackMultiplier, -10, 10), flamComp);
_flammable.Ignite(silicon, silicon, flamComp);
// Goobstation: Replaced by KillOnOverheatSystem
//_flammable.AdjustFireStacks(silicon, Math.Clamp(siliconComp.FireStackMultiplier, -10, 10), flamComp);
//_flammable.Ignite(silicon, silicon, flamComp);
return hotTempMulti;
}

Expand Down
30 changes: 22 additions & 8 deletions Content.Server/Silicon/WeldingHealable/WeldingHealableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using Content.Shared.Damage;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Tools;
using Content.Shared._Shitmed.Targeting;
using Content.Shared.Body.Systems;
using Content.Shared.Tools.Components;
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;

Expand All @@ -17,7 +20,7 @@ public sealed class WeldingHealableSystem : SharedWeldingHealableSystem
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;

[Dependency] private readonly SharedBodySystem _bodySystem = default!;
public override void Initialize()
{
SubscribeLocalEvent<WeldingHealableComponent, InteractUsingEvent>(Repair);
Expand All @@ -31,7 +34,7 @@ private void OnRepairFinished(EntityUid uid, WeldingHealableComponent healableCo
|| !TryComp<WeldingHealingComponent>(args.Used, out var component)
|| damageable.DamageContainerID is null
|| !component.DamageContainers.Contains(damageable.DamageContainerID)
|| !HasDamage(damageable, component)
|| !HasDamage((args.Target.Value, damageable), component, args.User)
|| !TryComp<WelderComponent>(args.Used, out var welder)
|| !TryComp<SolutionContainerManagerComponent>(args.Used, out var solutionContainer))
return;
Expand Down Expand Up @@ -70,7 +73,7 @@ private async void Repair(EntityUid uid, WeldingHealableComponent healableCompon
|| !EntityManager.TryGetComponent(args.Target, out DamageableComponent? damageable)
|| damageable.DamageContainerID is null
|| !component.DamageContainers.Contains(damageable.DamageContainerID)
|| !HasDamage(damageable, component)
|| !HasDamage((args.Target, damageable), component, args.User)
|| !_toolSystem.HasQuality(args.Used, component.QualityNeeded)
|| args.User == args.Target && !component.AllowSelfHeal)
return;
Expand All @@ -79,8 +82,8 @@ private async void Repair(EntityUid uid, WeldingHealableComponent healableCompon
? component.DoAfterDelay * component.SelfHealPenalty
: component.DoAfterDelay;

args.Handled = _toolSystem.UseTool
(args.Used,
args.Handled = _toolSystem.UseTool(
args.Used,
args.User,
args.Target,
delay,
Expand All @@ -91,15 +94,26 @@ private async void Repair(EntityUid uid, WeldingHealableComponent healableCompon
});
}

private bool HasDamage(DamageableComponent component, WeldingHealingComponent healable)
private bool HasDamage(Entity<DamageableComponent> damageable, WeldingHealingComponent healable, EntityUid user)
{
if (healable.Damage.DamageDict is null)
return false;

foreach (var type in healable.Damage.DamageDict)
if (component.Damage.DamageDict[type.Key].Value > 0)
if (damageable.Comp.Damage.DamageDict[type.Key].Value > 0)
return true;

// In case the healer is a humanoid entity with targeting, we run the check on the targeted parts.
if (!TryComp(user, out TargetingComponent? targeting))
return false;

var (targetType, targetSymmetry) = _bodySystem.ConvertTargetBodyPart(targeting.Target);
foreach (var part in _bodySystem.GetBodyChildrenOfType(damageable, targetType, symmetry: targetSymmetry))
if (TryComp<DamageableComponent>(part.Id, out var damageablePart))
foreach (var type in healable.Damage.DamageDict)
if (damageablePart.Damage.DamageDict[type.Key].Value > 0)
return true;

return false;
}
}

25 changes: 12 additions & 13 deletions Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem
[Dependency] private readonly TagSystem _tagSystem = default!;
#endregion Dependencies

private EntityQuery<PhysicsComponent> _physicsQuery;

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

_physicsQuery = GetEntityQuery<PhysicsComponent>();

SubscribeLocalEvent<MapGridComponent, EventHorizonAttemptConsumeEntityEvent>(PreventConsume);
SubscribeLocalEvent<GhostComponent, EventHorizonAttemptConsumeEntityEvent>(PreventConsume);
SubscribeLocalEvent<TelegnosticProjectionComponent, EventHorizonAttemptConsumeEntityEvent>(PreventConsume); ///Nyano - Summary: the telegnositic projection has the same trait as ghosts.
Expand Down Expand Up @@ -171,24 +175,19 @@ public bool CanConsumeEntity(EntityUid hungry, EntityUid uid, EventHorizonCompon
/// Attempts to consume all entities within a given distance of an entity;
/// Excludes the center entity.
/// </summary>
public void ConsumeEntitiesInRange(EntityUid uid, float range, TransformComponent? xform = null, EventHorizonComponent? eventHorizon = null)
public void ConsumeEntitiesInRange(EntityUid uid, float range, PhysicsComponent? body = null, EventHorizonComponent? eventHorizon = null)
{
if (!Resolve(uid, ref xform, ref eventHorizon))
if (!Resolve(uid, ref body, ref eventHorizon))
return;

var range2 = range * range;
var xformQuery = EntityManager.GetEntityQuery<TransformComponent>();
var epicenter = _xformSystem.GetWorldPosition(xform, xformQuery);
foreach (var entity in _lookup.GetEntitiesInRange(_xformSystem.GetMapCoordinates(uid, xform), range, flags: LookupFlags.Uncontained))
// TODO: Should be sundries + static-sundries but apparently this is load-bearing for SpawnAndDeleteAllEntitiesInTheSameSpot so go figure.
foreach (var entity in _lookup.GetEntitiesInRange(uid, range, flags: LookupFlags.Uncontained))
{
if (entity == uid)
continue;
if (!xformQuery.TryGetComponent(entity, out var entityXform))
continue;

// GetEntitiesInRange gets everything in a _square_ centered on the given position, but we are a _circle_. If we don't have this check and the station is rotated it is possible for the singularity to reach _outside of the containment field_ and eat the emitters.
var displacement = _xformSystem.GetWorldPosition(entityXform, xformQuery) - epicenter;
if (displacement.LengthSquared() > range2)
// See TODO above
if (_physicsQuery.TryComp(entity, out var otherBody) && !_physics.IsHardCollidable((uid, null, body), (entity, null, otherBody)))
continue;

AttemptConsumeEntity(uid, entity, eventHorizon);
Expand Down Expand Up @@ -330,11 +329,11 @@ public void ConsumeTilesInRange(EntityUid uid, float range, TransformComponent?
/// </summary>
public void ConsumeEverythingInRange(EntityUid uid, float range, TransformComponent? xform = null, EventHorizonComponent? eventHorizon = null)
{
if (!Resolve(uid, ref xform, ref eventHorizon))
if (!Resolve(uid, ref eventHorizon))
return;

if (eventHorizon.ConsumeEntities)
ConsumeEntitiesInRange(uid, range, xform, eventHorizon);
ConsumeEntitiesInRange(uid, range, null, eventHorizon);
if (eventHorizon.ConsumeTiles)
ConsumeTilesInRange(uid, range, xform, eventHorizon);
}
Expand Down
24 changes: 19 additions & 5 deletions Content.Server/Singularity/EntitySystems/GravityWellSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Singularity.Components;
using Content.Shared.Atmos.Components;
using Content.Shared.Ghost;
using Content.Shared.Physics;
using Content.Shared.Singularity.EntitySystems;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
Expand Down Expand Up @@ -33,9 +34,18 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
/// </summary>
public const float MinGravPulseRange = 0.00001f;

private EntityQuery<GravityWellComponent> _wellQuery;
private EntityQuery<MapComponent> _mapQuery;
private EntityQuery<MapGridComponent> _gridQuery;
private EntityQuery<PhysicsComponent> _physicsQuery;

public override void Initialize()
{
base.Initialize();
_wellQuery = GetEntityQuery<GravityWellComponent>();
_mapQuery = GetEntityQuery<MapComponent>();
_gridQuery = GetEntityQuery<MapGridComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<GravityWellComponent, ComponentStartup>(OnGravityWellStartup);

var vvHandle = _vvManager.GetTypeHandler<GravityWellComponent>();
Expand Down Expand Up @@ -114,11 +124,15 @@ private void Update(EntityUid uid, TimeSpan frameTime, GravityWellComponent? gra
/// <param name="entity">The entity to check.</param>
private bool CanGravPulseAffect(EntityUid entity)
{
return !(
EntityManager.HasComponent<GhostComponent>(entity) ||
EntityManager.HasComponent<MapGridComponent>(entity) ||
EntityManager.HasComponent<MapComponent>(entity) ||
EntityManager.HasComponent<GravityWellComponent>(entity)
if (_physicsQuery.TryComp(entity, out var physics))
{
if (physics.CollisionLayer == (int) CollisionGroup.GhostImpassable)
return false;
}

return !(_gridQuery.HasComp(entity) ||
_mapQuery.HasComp(entity) ||
_wellQuery.HasComp(entity)
);
}

Expand Down
8 changes: 5 additions & 3 deletions Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using System.Numerics;
using Content.Server.Cargo.Systems;
using Content.Shared.Contests;
using Content.Server.Power.EntitySystems;
using Content.Server.Weapons.Ranged.Components;
using Content.Shared.Damage;
Expand Down Expand Up @@ -35,6 +36,7 @@ public sealed partial class GunSystem : SharedGunSystem
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly StaminaSystem _stamina = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly ContestsSystem _contests = default!;

private const float DamagePitchVariation = 0.05f;

Expand Down Expand Up @@ -80,7 +82,7 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid?
var toMap = toCoordinates.ToMapPos(EntityManager, TransformSystem);
var mapDirection = toMap - fromMap.Position;
var mapAngle = mapDirection.ToAngle();
var angle = GetRecoilAngle(Timing.CurTime, gun, mapDirection.ToAngle());
var angle = GetRecoilAngle(Timing.CurTime, gun, mapDirection.ToAngle(), user);

// If applicable, this ensures the projectile is parented to grid on spawn, instead of the map.
var fromEnt = MapManager.TryFindGridAt(fromMap, out var gridUid, out var grid)
Expand Down Expand Up @@ -334,15 +336,15 @@ private Angle[] LinearSpread(Angle start, Angle end, int intervals)
return angles;
}

private Angle GetRecoilAngle(TimeSpan curTime, GunComponent component, Angle direction)
private Angle GetRecoilAngle(TimeSpan curTime, GunComponent component, Angle direction, EntityUid? user)
{
var timeSinceLastFire = (curTime - component.LastFire).TotalSeconds;
var newTheta = MathHelper.Clamp(component.CurrentAngle.Theta + component.AngleIncreaseModified.Theta - component.AngleDecayModified.Theta * timeSinceLastFire, component.MinAngleModified.Theta, component.MaxAngleModified.Theta);
component.CurrentAngle = new Angle(newTheta);
component.LastFire = component.NextFire;

// Convert it so angle can go either side.
var random = Random.NextFloat(-0.5f, 0.5f);
var random = Random.NextFloat(-0.5f, 0.5f) / _contests.MassContest(user);
var spread = component.CurrentAngle.Theta * random;
var angle = new Angle(direction.Theta + component.CurrentAngle.Theta * random);
DebugTools.Assert(spread <= component.MaxAngleModified.Theta);
Expand Down
Loading

0 comments on commit e1a8481

Please sign in to comment.