Merge branch 'master' into replace-sounds-with-sound-specifier

# Conflicts:
#	Content.Server/Actions/Actions/DisarmAction.cs
#	Content.Server/Actions/Actions/ScreamAction.cs
#	Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs
#	Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs
#	Content.Server/Explosion/Components/FlashExplosiveComponent.cs
#	Content.Server/Physics/Controllers/MoverController.cs
#	Content.Server/Portal/Components/PortalComponent.cs
#	Content.Server/Portal/Components/TeleporterComponent.cs
#	Content.Server/Projectiles/Components/ProjectileComponent.cs
#	Content.Server/Singularity/Components/EmitterComponent.cs
#	Content.Server/Sound/EmitSoundSystem.cs
#	Content.Server/Stunnable/Components/StunbatonComponent.cs
#	Content.Server/Tools/Components/MultitoolComponent.cs
#	Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs
#	Content.Shared/Gravity/GravityComponent.cs
#	Content.Shared/Light/Component/SharedExpendableLightComponent.cs
#	Content.Shared/Maps/ContentTileDefinition.cs
#	Content.Shared/Slippery/SlipperyComponent.cs
#	Content.Shared/Standing/StandingStateComponent.cs
#	Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml
This commit is contained in:
Galactic Chimp
2021-07-25 14:12:00 +02:00
4171 changed files with 15603 additions and 14404 deletions

View File

@@ -1,4 +1,3 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

View File

@@ -1,49 +0,0 @@
using System;
using Content.Server.Body.Circulatory;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Chemistry.Components
{
[RegisterComponent]
public class ChemicalInjectionProjectileComponent : Component, IStartCollide
{
public override string Name => "ChemicalInjectionProjectile";
[ViewVariables]
private SolutionContainerComponent _solutionContainer = default!;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("transferAmount")]
public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(1);
[ViewVariables(VVAccess.ReadWrite)]
public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); }
[DataField("transferEfficiency")]
private float _transferEfficiency = 1f;
protected override void Initialize()
{
base.Initialize();
_solutionContainer = Owner.EnsureComponent<SolutionContainerComponent>();
}
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (!otherFixture.Body.Owner.TryGetComponent<BloodstreamComponent>(out var bloodstream))
return;
var solution = _solutionContainer.Solution;
var solRemoved = solution.SplitSolution(TransferAmount);
var solRemovedVol = solRemoved.TotalVolume;
var solToInject = solRemoved.SplitSolution(solRemovedVol * TransferEfficiency);
bloodstream.TryTransferSolution(solToInject);
}
}
}

View File

@@ -1,5 +1,4 @@
#nullable enable
using Content.Server.Body.Circulatory;
using Content.Server.Body.Circulatory;
using Content.Server.Inventory.Components;
using Content.Server.Items;
using Content.Shared.Chemistry.Reagent;

View File

@@ -1,4 +1,3 @@
#nullable enable
using System;
using System.Threading.Tasks;
using Content.Server.Body.Circulatory;

View File

@@ -1,4 +1,3 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;

View File

@@ -3,7 +3,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
#nullable enable
namespace Content.Server.Chemistry.Components
{

View File

@@ -1,4 +1,3 @@
#nullable enable
using Content.Server.Notification;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reagent;

View File

@@ -1,5 +1,4 @@
#nullable enable
using System.Linq;
using System.Linq;
using Content.Server.Body.Circulatory;
using Content.Server.Body.Respiratory;
using Content.Shared.Chemistry;

View File

@@ -1,4 +1,3 @@
#nullable enable
using System;
using System.Linq;
using Content.Server.Atmos.Components;

View File

@@ -1,5 +1,4 @@
#nullable enable
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Robust.Shared.GameObjects;
using Robust.Shared.ViewVariables;

View File

@@ -1,5 +1,4 @@
#nullable enable
using Content.Shared.Chemistry.Solution.Components;
using Content.Shared.Chemistry.Solution.Components;
using Robust.Shared.GameObjects;
namespace Content.Server.Chemistry.Components

View File

@@ -0,0 +1,27 @@
using System;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Chemistry.Components
{
/// <summary>
/// On colliding with an entity that has a bloodstream will dump its solution onto them.
/// </summary>
[RegisterComponent]
internal sealed class SolutionInjectOnCollideComponent : Component
{
public override string Name => "SolutionInjectOnCollide";
[ViewVariables(VVAccess.ReadWrite)]
[DataField("transferAmount")]
public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(1);
[ViewVariables(VVAccess.ReadWrite)]
public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); }
[DataField("transferEfficiency")]
private float _transferEfficiency = 1f;
}
}

View File

@@ -1,10 +1,15 @@
#nullable enable
using System;
using System.Threading.Tasks;
using Content.Server.UserInterface;
using Content.Shared.ActionBlocker;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Solution.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification.Managers;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -32,6 +37,35 @@ namespace Content.Server.Chemistry.Components
[ViewVariables(VVAccess.ReadWrite)]
public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(5);
/// <summary>
/// The minimum amount of solution that can be transferred at once from this solution.
/// </summary>
[DataField("minTransferAmount")]
[ViewVariables(VVAccess.ReadWrite)]
public ReagentUnit MinimumTransferAmount { get; set; } = ReagentUnit.New(5);
/// <summary>
/// The maximum amount of solution that can be transferred at once from this solution.
/// </summary>
[DataField("maxTransferAmount")]
[ViewVariables(VVAccess.ReadWrite)]
public ReagentUnit MaximumTransferAmount { get; set; } = ReagentUnit.New(50);
/// <summary>
/// Subjectively, which transfer amount would be best for most activities given the maximum
/// transfer amount.
/// </summary>
public ReagentUnit SubjectiveBestTransferAmount() =>
MaximumTransferAmount.Int() switch
{
<= 5 => ReagentUnit.New(1),
(> 5) and (<= 25) => ReagentUnit.New(5),
(> 25) and (<= 50) => ReagentUnit.New(10),
(> 50) and (<= 100) => ReagentUnit.New(20),
(> 100) and (<= 500) => ReagentUnit.New(50),
(> 500) => ReagentUnit.New(100)
};
/// <summary>
/// Can this entity take reagent from reagent tanks?
/// </summary>
@@ -46,6 +80,46 @@ namespace Content.Server.Chemistry.Components
[ViewVariables(VVAccess.ReadWrite)]
public bool CanSend { get; set; } = true;
/// <summary>
/// Whether you're allowed to change the transfer amount.
/// </summary>
[DataField("canChangeTransferAmount")]
[ViewVariables(VVAccess.ReadWrite)]
public bool CanChangeTransferAmount { get; set; } = false;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(TransferAmountUiKey.Key);
protected override void Initialize()
{
base.Initialize();
if (UserInterface != null)
{
UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
}
}
public void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage serverMsg)
{
switch (serverMsg.Message)
{
case TransferAmountSetValueMessage svm:
var sval = svm.Value.Float();
var amount = Math.Clamp(sval, MinimumTransferAmount.Float(),
MaximumTransferAmount.Float());
serverMsg.Session.AttachedEntity?.PopupMessage(Loc.GetString("comp-solution-transfer-set-amount", ("amount", amount)));
SetTransferAmount(ReagentUnit.New(amount));
break;
}
}
public void SetTransferAmount(ReagentUnit amount)
{
amount = ReagentUnit.New(Math.Clamp(amount.Int(), MinimumTransferAmount.Int(), MaximumTransferAmount.Int()));
TransferAmount = amount;
}
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
{
if (!eventArgs.InRangeUnobstructed() || eventArgs.Target == null)
@@ -68,8 +142,8 @@ namespace Content.Server.Chemistry.Components
{
var toTheBrim = ownerSolution.RefillSpaceAvailable == 0;
var msg = toTheBrim
? "solution-transfer-component-fill-to-brim-message"
: "solution-transfer-component-fill--message";
? "comp-solution-transfer-fill-fully"
: "comp-solution-transfer-fill-normal";
target.PopupMessage(eventArgs.User, Loc.GetString(msg,("owner", Owner),("amount", transferred),("target", target)));
return true;
@@ -83,7 +157,7 @@ namespace Content.Server.Chemistry.Components
if (transferred > 0)
{
Owner.PopupMessage(eventArgs.User,
Loc.GetString("solution-transfer-component-transfer-success-message",
Loc.GetString("comp-solution-transfer-transfer-solution",
("amount",transferred),
("target",target)));
@@ -103,13 +177,13 @@ namespace Content.Server.Chemistry.Components
{
if (source.DrainAvailable == 0)
{
source.Owner.PopupMessage(user, Loc.GetString("solution-transfer-component-do-transfer-component-is-empty", ("entity",source.Owner)));
source.Owner.PopupMessage(user, Loc.GetString("comp-solution-transfer-is-empty", ("target", source.Owner)));
return ReagentUnit.Zero;
}
if (target.RefillSpaceAvailable == 0)
{
target.Owner.PopupMessage(user, Loc.GetString("solution-transfer-component-do-transfer-component-is-full", ("entity", target.Owner)));
target.Owner.PopupMessage(user, Loc.GetString("comp-solution-transfer-is-full", ("target", target.Owner)));
return ReagentUnit.Zero;
}
@@ -121,5 +195,114 @@ namespace Content.Server.Chemistry.Components
return actualAmount;
}
// TODO refactor when dynamic verbs are a thing
[Verb]
public sealed class MinimumTransferVerb : Verb<SolutionTransferComponent>
{
protected override void GetData(IEntity user, SolutionTransferComponent component, VerbData data)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(user) || !component.CanChangeTransferAmount)
{
data.Visibility = VerbVisibility.Invisible;
return;
}
data.Visibility = VerbVisibility.Visible;
data.Text = Loc.GetString("comp-solution-transfer-verb-transfer-amount-min",
("amount", component.MinimumTransferAmount.Int()));
data.CategoryData = VerbCategories.SetTransferAmount;
}
protected override void Activate(IEntity user, SolutionTransferComponent component)
{
component.TransferAmount = component.MinimumTransferAmount;
user.PopupMessage(Loc.GetString("comp-solution-transfer-set-amount",
("amount", component.TransferAmount.Int())));
}
}
[Verb]
public sealed class DefaultTransferVerb : Verb<SolutionTransferComponent>
{
protected override void GetData(IEntity user, SolutionTransferComponent component, VerbData data)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(user) || !component.CanChangeTransferAmount)
{
data.Visibility = VerbVisibility.Invisible;
return;
}
var amt = component.SubjectiveBestTransferAmount();
if (amt > component.MinimumTransferAmount && amt < component.MaximumTransferAmount)
{
data.Visibility = VerbVisibility.Visible;
data.Text = Loc.GetString("comp-solution-transfer-verb-transfer-amount-ideal",
("amount", amt.Int()));
data.CategoryData = VerbCategories.SetTransferAmount;
}
else
{
data.Visibility = VerbVisibility.Invisible;
}
}
protected override void Activate(IEntity user, SolutionTransferComponent component)
{
component.TransferAmount = component.SubjectiveBestTransferAmount();
user.PopupMessage(Loc.GetString("comp-solution-transfer-set-amount", ("amount", component.TransferAmount.Int())));
}
}
[Verb]
public sealed class MaximumTransferVerb : Verb<SolutionTransferComponent>
{
protected override void GetData(IEntity user, SolutionTransferComponent component, VerbData data)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(user) || !component.CanChangeTransferAmount)
{
data.Visibility = VerbVisibility.Invisible;
return;
}
data.Visibility = VerbVisibility.Visible;
data.Text = Loc.GetString("comp-solution-transfer-verb-transfer-amount-max",
("amount", component.MaximumTransferAmount));
data.CategoryData = VerbCategories.SetTransferAmount;
}
protected override void Activate(IEntity user, SolutionTransferComponent component)
{
component.TransferAmount = component.MaximumTransferAmount;
user.PopupMessage(Loc.GetString("comp-solution-transfer-set-amount", ("amount", component.TransferAmount.Int())));
}
}
[Verb]
public sealed class CustomTransferVerb : Verb<SolutionTransferComponent>
{
protected override void GetData(IEntity user, SolutionTransferComponent component, VerbData data)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(user) || !component.CanChangeTransferAmount)
{
data.Visibility = VerbVisibility.Invisible;
return;
}
data.Visibility = VerbVisibility.Visible;
data.Text = Loc.GetString("comp-solution-transfer-verb-transfer-amount-custom");
data.CategoryData = VerbCategories.SetTransferAmount;
}
protected override void Activate(IEntity user, SolutionTransferComponent component)
{
if (!user.TryGetComponent<ActorComponent>(out var actor))
{
return;
}
component.UserInterface?.Open(actor.PlayerSession);
}
}
}
}

View File

@@ -1,4 +1,3 @@
#nullable enable
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Solution;

View File

@@ -1,131 +1,24 @@
using System.Linq;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Solution;
using Content.Shared.Physics;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Vapor;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Chemistry.Components
{
[RegisterComponent]
class VaporComponent : SharedVaporComponent, IStartCollide
internal sealed class VaporComponent : SharedVaporComponent
{
public const float ReactTime = 0.125f;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[ViewVariables]
[DataField("transferAmount")]
private ReagentUnit _transferAmount = ReagentUnit.New(0.5);
internal ReagentUnit TransferAmount = ReagentUnit.New(0.5);
private bool _reached;
private float _reactTimer;
private float _timer;
private EntityCoordinates _target;
private bool _running;
private float _aliveTime;
protected override void Initialize()
{
base.Initialize();
Owner.EnsureComponentWarn(out SolutionContainerComponent _);
}
public void Start(Vector2 dir, float speed, EntityCoordinates target, float aliveTime)
{
_running = true;
_target = target;
_aliveTime = aliveTime;
// Set Move
if (Owner.TryGetComponent(out PhysicsComponent? physics))
{
physics.BodyStatus = BodyStatus.InAir;
physics.ApplyLinearImpulse(dir * speed);
}
}
public void Update(float frameTime)
{
if (!Owner.TryGetComponent(out SolutionContainerComponent? contents))
return;
if (!_running)
return;
_timer += frameTime;
_reactTimer += frameTime;
if (_reactTimer >= ReactTime && Owner.Transform.GridID.IsValid())
{
_reactTimer = 0;
var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID);
var tile = mapGrid.GetTileRef(Owner.Transform.Coordinates.ToVector2i(Owner.EntityManager, _mapManager));
foreach (var reagentQuantity in contents.ReagentList.ToArray())
{
if (reagentQuantity.Quantity == ReagentUnit.Zero) continue;
var reagent = _prototypeManager.Index<ReagentPrototype>(reagentQuantity.ReagentId);
contents.TryRemoveReagent(reagentQuantity.ReagentId, reagent.ReactionTile(tile, (reagentQuantity.Quantity / _transferAmount) * 0.25f));
}
}
// Check if we've reached our target.
if(!_reached && _target.TryDistance(Owner.EntityManager, Owner.Transform.Coordinates, out var distance) && distance <= 0.5f)
{
_reached = true;
}
if (contents.CurrentVolume == 0 || _timer > _aliveTime)
{
// Delete this
Owner.Delete();
}
}
internal bool TryAddSolution(Solution solution)
{
if (solution.TotalVolume == 0)
{
return false;
}
if (!Owner.TryGetComponent(out SolutionContainerComponent? contents))
{
return false;
}
var result = contents.TryAddSolution(solution);
if (!result)
{
return false;
}
return true;
}
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (!Owner.TryGetComponent(out SolutionContainerComponent? contents))
return;
contents.Solution.DoEntityReaction(otherFixture.Body.Owner, ReactionMethod.Touch);
// Check for collision with a impassable object (e.g. wall) and stop
if ((otherFixture.CollisionLayer & (int) CollisionGroup.Impassable) != 0 && otherFixture.Hard)
{
Owner.QueueDelete();
}
}
internal bool Reached;
internal float ReactTimer;
internal float Timer;
internal EntityCoordinates Target;
internal bool Active;
internal float AliveTime;
}
}