Skip to content

Commit

Permalink
Merge pull request #398 from formlessnameless/dev
Browse files Browse the repository at this point in the history
Upstream merge
  • Loading branch information
formlessnameless authored Oct 2, 2024
2 parents 1615820 + 748077a commit 810b6fd
Show file tree
Hide file tree
Showing 132 changed files with 1,438 additions and 427 deletions.
2 changes: 2 additions & 0 deletions Content.Client/Paper/UI/PaperWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ protected override DragMode GetDragModeFor(Vector2 relativeMousePos)

private void RunOnSaved()
{
// Prevent further saving while text processing still in
SaveButton.Disabled = true;
OnSaved?.Invoke(Rope.Collapse(Input.TextRope));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Content.Server.CartridgeLoader.Cartridges;

[RegisterComponent]
public sealed partial class MedTekCartridgeComponent : Component
{
}
31 changes: 31 additions & 0 deletions Content.Server/CartridgeLoader/Cartridges/MedTekCartridgeSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Server.Medical.Components;
using Content.Shared.CartridgeLoader;

namespace Content.Server.CartridgeLoader.Cartridges;

public sealed class MedTekCartridgeSystem : EntitySystem
{
[Dependency] private readonly CartridgeLoaderSystem _cartridgeLoaderSystem = default!;

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

SubscribeLocalEvent<MedTekCartridgeComponent, CartridgeAddedEvent>(OnCartridgeAdded);
SubscribeLocalEvent<MedTekCartridgeComponent, CartridgeRemovedEvent>(OnCartridgeRemoved);
}

private void OnCartridgeAdded(Entity<MedTekCartridgeComponent> ent, ref CartridgeAddedEvent args)
{
var healthAnalyzer = EnsureComp<HealthAnalyzerComponent>(args.Loader);
}

private void OnCartridgeRemoved(Entity<MedTekCartridgeComponent> ent, ref CartridgeRemovedEvent args)
{
// only remove when the program itself is removed
if (!_cartridgeLoaderSystem.HasProgram<MedTekCartridgeComponent>(args.Loader))
{
RemComp<HealthAnalyzerComponent>(args.Loader);
}
}
}
48 changes: 33 additions & 15 deletions Content.Server/Fluids/EntitySystems/SpraySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Robust.Shared.Physics.Components;
using Robust.Shared.Prototypes;
using System.Numerics;
using Robust.Shared.Map;

namespace Content.Server.Fluids.EntitySystems;

Expand All @@ -35,6 +36,19 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<SprayComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<SprayComponent, UserActivateInWorldEvent>(OnActivateInWorld);
}

private void OnActivateInWorld(Entity<SprayComponent> entity, ref UserActivateInWorldEvent args)
{
if (args.Handled)
return;

args.Handled = true;

var targetMapPos = _transform.GetMapCoordinates(GetEntityQuery<TransformComponent>().GetComponent(args.Target));

Spray(entity, args.User, targetMapPos);
}

private void OnAfterInteract(Entity<SprayComponent> entity, ref AfterInteractEvent args)
Expand All @@ -44,29 +58,36 @@ private void OnAfterInteract(Entity<SprayComponent> entity, ref AfterInteractEve

args.Handled = true;

var clickPos = _transform.ToMapCoordinates(args.ClickLocation);

Spray(entity, args.User, clickPos);
}

public void Spray(Entity<SprayComponent> entity, EntityUid user, MapCoordinates mapcoord)
{
if (!_solutionContainer.TryGetSolution(entity.Owner, SprayComponent.SolutionName, out var soln, out var solution))
return;

var ev = new SprayAttemptEvent(args.User);
var ev = new SprayAttemptEvent(user);
RaiseLocalEvent(entity, ref ev);
if (ev.Cancelled)
return;

if (!TryComp<UseDelayComponent>(entity, out var useDelay)
|| _useDelay.IsDelayed((entity, useDelay)))
if (TryComp<UseDelayComponent>(entity, out var useDelay)
&& _useDelay.IsDelayed((entity, useDelay)))
return;

if (solution.Volume <= 0)
{
_popupSystem.PopupEntity(Loc.GetString("spray-component-is-empty-message"), entity.Owner, args.User);
_popupSystem.PopupEntity(Loc.GetString("spray-component-is-empty-message"), entity.Owner, user);
return;
}

var xformQuery = GetEntityQuery<TransformComponent>();
var userXform = xformQuery.GetComponent(args.User);
var userXform = xformQuery.GetComponent(user);

var userMapPos = _transform.GetMapCoordinates(userXform);
var clickMapPos = args.ClickLocation.ToMap(EntityManager, _transform);
var clickMapPos = mapcoord;

var diffPos = clickMapPos.Position - userMapPos.Position;
if (diffPos == Vector2.Zero || diffPos == Vector2Helpers.NaN)
Expand All @@ -88,8 +109,6 @@ private void OnAfterInteract(Entity<SprayComponent> entity, ref AfterInteractEve

var amount = Math.Max(Math.Min((solution.Volume / entity.Comp.TransferAmount).Int(), entity.Comp.VaporAmount), 1);
var spread = entity.Comp.VaporSpread / amount;
// TODO: Just use usedelay homie.
var cooldownTime = 0f;

for (var i = 0; i < amount; i++)
{
Expand Down Expand Up @@ -131,20 +150,19 @@ private void OnAfterInteract(Entity<SprayComponent> entity, ref AfterInteractEve
// impulse direction is defined in world-coordinates, not local coordinates
var impulseDirection = rotation.ToVec();
var time = diffLength / entity.Comp.SprayVelocity;
cooldownTime = MathF.Max(time, cooldownTime);

_vapor.Start(ent, vaporXform, impulseDirection * diffLength, entity.Comp.SprayVelocity, target, time, args.User);
_vapor.Start(ent, vaporXform, impulseDirection * diffLength, entity.Comp.SprayVelocity, target, time, user);

if (TryComp<PhysicsComponent>(args.User, out var body))
if (TryComp<PhysicsComponent>(user, out var body))
{
if (_gravity.IsWeightless(args.User, body))
_physics.ApplyLinearImpulse(args.User, -impulseDirection.Normalized() * entity.Comp.PushbackAmount, body: body);
if (_gravity.IsWeightless(user, body))
_physics.ApplyLinearImpulse(user, -impulseDirection.Normalized() * entity.Comp.PushbackAmount, body: body);
}
}

_audio.PlayPvs(entity.Comp.SpraySound, entity, entity.Comp.SpraySound.Params.WithVariation(0.125f));

_useDelay.SetLength(entity.Owner, TimeSpan.FromSeconds(cooldownTime));
_useDelay.TryResetDelay((entity, useDelay));
if (useDelay != null)
_useDelay.TryResetDelay((entity, useDelay));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public sealed partial class HealthAnalyzerComponent : Component
/// Sound played on scanning end
/// </summary>
[DataField]
public SoundSpecifier? ScanningEndSound;
public SoundSpecifier ScanningEndSound = new SoundPathSpecifier("/Audio/Items/Medical/healthscanner.ogg");

/// <summary>
/// Whether to show up the popup
Expand Down
5 changes: 2 additions & 3 deletions Content.Server/Medical/HealthAnalyzerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
using Content.Shared.MedicalScanner;
using Content.Shared.Mobs.Components;
using Content.Shared.Popups;
using Content.Shared.PowerCell;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Robust.Shared.Timing;

namespace Content.Server.Medical;
Expand Down Expand Up @@ -104,7 +102,8 @@ private void OnDoAfter(Entity<HealthAnalyzerComponent> uid, ref HealthAnalyzerDo
if (args.Handled || args.Cancelled || args.Target == null || !_cell.HasDrawCharge(uid, user: args.User))
return;

_audio.PlayPvs(uid.Comp.ScanningEndSound, uid);
if (!uid.Comp.Silent)
_audio.PlayPvs(uid.Comp.ScanningEndSound, uid);

OpenUserInterface(args.User, uid);
BeginAnalyzingEntity(uid, args.Target.Value);
Expand Down
9 changes: 9 additions & 0 deletions Content.Server/NPC/Queries/Considerations/TargetOnFireCon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Content.Server.NPC.Queries.Considerations;

/// <summary>
/// Returns 1f if the target is on fire or 0f if not.
/// </summary>
public sealed partial class TargetOnFireCon : UtilityConsideration
{

}
7 changes: 7 additions & 0 deletions Content.Server/NPC/Systems/NPCUtilitySystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.Atmos.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Server.NPC.Queries;
using Content.Server.NPC.Queries.Considerations;
Expand Down Expand Up @@ -364,6 +365,12 @@ private float GetScore(NPCBlackboard blackboard, EntityUid targetUid, UtilityCon
}
return 0f;
}
case TargetOnFireCon:
{
if (TryComp(targetUid, out FlammableComponent? fire) && fire.OnFire)
return 1f;
return 0f;
}
default:
throw new NotImplementedException();
}
Expand Down
3 changes: 1 addition & 2 deletions Content.Shared/Doors/Systems/SharedDoorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,7 @@ public IEnumerable<EntityUid> GetColliding(EntityUid uid, PhysicsComponent? phys
var tileRef = _mapSystem.GetTileRef(xform.GridUid.Value, mapGridComp, xform.Coordinates);

_doorIntersecting.Clear();

_entityLookup.GetLocalEntitiesIntersecting(xform.GridUid.Value, tileRef.GridIndices, _doorIntersecting, gridComp: mapGridComp);
_entityLookup.GetLocalEntitiesIntersecting(xform.GridUid.Value, tileRef.GridIndices, _doorIntersecting, gridComp: mapGridComp, flags: (LookupFlags.All & ~LookupFlags.Sensors));

// TODO SLOTH fix electro's code.
// ReSharper disable once InconsistentNaming
Expand Down
10 changes: 8 additions & 2 deletions Content.Shared/Interaction/SmartEquipSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared.Input;
using Content.Shared.Inventory;
using Content.Shared.Popups;
using Content.Shared.Stacks;
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Whitelist;
Expand Down Expand Up @@ -151,8 +152,13 @@ private void HandleSmartEquip(ICommonSession? session, string equipmentSlot)
_hands.TryDrop(uid, hands.ActiveHand, handsComp: hands);
_storage.Insert(slotItem, handItem.Value, out var stacked, out _);

if (stacked != null)
_hands.TryPickup(uid, stacked.Value, handsComp: hands);
// if the hand item stacked with the things in inventory, but there's no more space left for the rest
// of the stack, place the stack back in hand rather than dropping it on the floor
if (stacked != null && !_storage.CanInsert(slotItem, handItem.Value, out _))
{
if (TryComp<StackComponent>(handItem.Value, out var handStack) && handStack.Count > 0)
_hands.TryPickup(uid, handItem.Value, handsComp: hands);
}

return;
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Item/ItemToggle/ItemToggleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void OnUseInHand(Entity<ItemToggleComponent> ent, ref UseInHandEvent arg

private void OnActivateVerb(Entity<ItemToggleComponent> ent, ref GetVerbsEvent<ActivationVerb> args)
{
if (!args.CanAccess || !args.CanInteract)
if (!args.CanAccess || !args.CanInteract || !ent.Comp.OnActivate)
return;

var user = args.User;
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/Materials/SharedMaterialStorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Content.Shared.Research.Components;

namespace Content.Shared.Materials;

Expand All @@ -34,6 +35,7 @@ public override void Initialize()

SubscribeLocalEvent<MaterialStorageComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<MaterialStorageComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<MaterialStorageComponent, TechnologyDatabaseModifiedEvent>(OnDatabaseModified);
}

public override void Update(float frameTime)
Expand Down Expand Up @@ -312,6 +314,11 @@ private void OnInteractUsing(EntityUid uid, MaterialStorageComponent component,
args.Handled = TryInsertMaterialEntity(args.User, args.Used, uid, component);
}

private void OnDatabaseModified(Entity<MaterialStorageComponent> ent, ref TechnologyDatabaseModifiedEvent args)
{
UpdateMaterialWhitelist(ent);
}

public int GetSheetVolume(MaterialPrototype material)
{
if (material.StackEntity == null)
Expand Down
Loading

0 comments on commit 810b6fd

Please sign in to comment.