Merge remote-tracking branch 'upstream/master' into ups

This commit is contained in:
Jabak
2024-07-19 16:41:41 +03:00
101 changed files with 1154 additions and 182 deletions

View File

@@ -69,7 +69,8 @@ namespace Content.Shared.Alert
SuitPower,
BorgHealth,
BorgCrit,
BorgDead
BorgDead,
Offer // WD EDITS
}
}

View File

@@ -58,6 +58,7 @@ namespace Content.Shared.Input
public static readonly BoundKeyFunction ZoomIn = "ZoomIn";
public static readonly BoundKeyFunction ResetZoom = "ResetZoom";
public static readonly BoundKeyFunction LieDown = "LieDown"; // WD EDIT
public static readonly BoundKeyFunction OfferItem = "OfferItem"; // WD EDIT
public static readonly BoundKeyFunction ArcadeUp = "ArcadeUp";
public static readonly BoundKeyFunction ArcadeDown = "ArcadeDown";

View File

@@ -99,7 +99,7 @@ public sealed class PryingSystem : EntitySystem
// to be marked as handled.
return true;
return StartPry(target, user, null, 0.1f, out id); // hand-prying is much slower
return StartPry(target, user, null, 10f, out id); // hand-prying is much slower
}
private bool CanPry(EntityUid target, EntityUid user, out string? message, PryingComponent? comp = null)
@@ -133,7 +133,10 @@ public sealed class PryingSystem : EntitySystem
var modEv = new GetPryTimeModifierEvent(user);
RaiseLocalEvent(target, ref modEv);
var doAfterArgs = new DoAfterArgs(EntityManager, user, TimeSpan.FromSeconds(modEv.BaseTime * modEv.PryTimeModifier / toolModifier), new DoorPryDoAfterEvent(), target, target, tool)
var time = TimeSpan.FromSeconds(!TryComp<AirlockComponent>(target, out var airlock) || !airlock.Powered ? 0 : modEv.BaseTime * modEv.PryTimeModifier * toolModifier); // WD EDIT
var doAfterArgs = new DoAfterArgs(EntityManager, user, time, new DoorPryDoAfterEvent(), target, target, tool)
{
BreakOnDamage = true,
BreakOnMove = true,
@@ -166,7 +169,7 @@ public sealed class PryingSystem : EntitySystem
return;
}
if (args.Used != null && comp != null)
if (args.Used != null && comp != null && door.State is not DoorState.Closing and not DoorState.Opening)
{
_audioSystem.PlayPredicted(comp.UseSound, args.Used.Value, args.User);
}

View File

@@ -18,7 +18,7 @@ public sealed partial class ToolTileCompatibleComponent : Component
/// The time it takes to modify the tile.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan Delay = TimeSpan.FromSeconds(1);
public TimeSpan Delay = TimeSpan.FromSeconds(0);
/// <summary>
/// Whether or not the tile being modified must be unobstructed

View File

@@ -0,0 +1,26 @@
using Robust.Shared.GameStates;
namespace Content.Shared._White.OfferItem;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
[Access(typeof(SharedOfferItemSystem))]
public sealed partial class OfferItemComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public bool IsInOfferMode;
[DataField, AutoNetworkedField]
public bool IsInReceiveMode;
[DataField, AutoNetworkedField]
public string? Hand;
[DataField, AutoNetworkedField]
public EntityUid? Item;
[DataField, AutoNetworkedField]
public EntityUid? Target;
[DataField]
public float MaxOfferDistance = 2f;
}

View File

@@ -0,0 +1,74 @@
using Content.Shared.Popups;
using Content.Shared.ActionBlocker;
using Content.Shared.Input;
using Content.Shared.Hands.Components;
using Robust.Shared.Input.Binding;
using Robust.Shared.Player;
namespace Content.Shared._White.OfferItem;
public abstract partial class SharedOfferItemSystem
{
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
private void InitializeInteractions()
{
CommandBinds.Builder
.Bind(ContentKeyFunctions.OfferItem, InputCmdHandler.FromDelegate(SetInOfferMode, handle: false, outsidePrediction: false))
.Register<SharedOfferItemSystem>();
}
public override void Shutdown()
{
base.Shutdown();
CommandBinds.Unregister<SharedOfferItemSystem>();
}
private void SetInOfferMode(ICommonSession? session)
{
if (session is not { } playerSession)
return;
if ((playerSession.AttachedEntity is not { Valid: true } uid || !Exists(uid)) ||
!_actionBlocker.CanInteract(uid, null))
return;
if (!TryComp<OfferItemComponent>(uid, out var offerItem))
return;
if (!TryComp<HandsComponent>(uid, out var hands) || hands.ActiveHand == null)
return;
offerItem.Item = hands.ActiveHand.HeldEntity;
if (offerItem.IsInOfferMode == false)
{
if (offerItem.Item == null)
{
_popup.PopupEntity(Loc.GetString("offer-item-empty-hand"), uid, uid);
return;
}
if (offerItem.Hand == null || offerItem.Target == null)
{
offerItem.IsInOfferMode = true;
offerItem.Hand = hands.ActiveHand.Name;
Dirty(uid, offerItem);
return;
}
}
if (offerItem.Target != null)
{
UnReceive(offerItem.Target.Value, offerItem: offerItem);
offerItem.IsInOfferMode = false;
Dirty(uid, offerItem);
return;
}
UnOffer(uid, offerItem);
}
}

View File

@@ -0,0 +1,158 @@
using Content.Shared.Interaction;
using Content.Shared.IdentityManagement;
using Content.Shared.Hands.Components;
namespace Content.Shared._White.OfferItem;
public abstract partial class SharedOfferItemSystem : EntitySystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
SubscribeLocalEvent<OfferItemComponent, InteractUsingEvent>(SetInReceiveMode);
SubscribeLocalEvent<OfferItemComponent, MoveEvent>(OnMove);
InitializeInteractions();
}
private void SetInReceiveMode(EntityUid uid, OfferItemComponent component, InteractUsingEvent args)
{
if (!TryComp<OfferItemComponent>(args.User, out var offerItem))
return;
if (args.User == uid || component.IsInReceiveMode || !offerItem.IsInOfferMode ||
(offerItem.IsInReceiveMode && offerItem.Target != uid))
return;
component.IsInReceiveMode = true;
component.Target = args.User;
Dirty(uid, component);
offerItem.Target = uid;
offerItem.IsInOfferMode = false;
Dirty(args.User, offerItem);
if (offerItem.Item == null)
return;
_popup.PopupEntity(Loc.GetString("offer-item-try-give",
("item", Identity.Entity(offerItem.Item.Value, EntityManager)),
("target", Identity.Entity(uid, EntityManager))), component.Target.Value, component.Target.Value);
_popup.PopupEntity(Loc.GetString("offer-item-try-give-target",
("user", Identity.Entity(component.Target.Value, EntityManager)),
("item", Identity.Entity(offerItem.Item.Value, EntityManager))), component.Target.Value, uid);
args.Handled = true;
}
private void OnMove(EntityUid uid, OfferItemComponent component, MoveEvent args)
{
if (component.Target == null ||
args.NewPosition.InRange(EntityManager, _transform,
Transform(component.Target.Value).Coordinates, component.MaxOfferDistance))
return;
UnOffer(uid, component);
}
/// <summary>
/// Resets the <see cref="OfferItemComponent"/> of the user and the target
/// </summary>
protected void UnOffer(EntityUid uid, OfferItemComponent component)
{
if (!TryComp<HandsComponent>(uid, out var hands) || hands.ActiveHand == null)
return;
if (TryComp<OfferItemComponent>(component.Target, out var offerItem) && component.Target != null)
{
if (component.Item != null)
{
_popup.PopupEntity(Loc.GetString("offer-item-no-give",
("item", Identity.Entity(component.Item.Value, EntityManager)),
("target", Identity.Entity(component.Target.Value, EntityManager))), uid, uid);
_popup.PopupEntity(Loc.GetString("offer-item-no-give-target",
("user", Identity.Entity(uid, EntityManager)),
("item", Identity.Entity(component.Item.Value, EntityManager))), uid, component.Target.Value);
}
else if (offerItem.Item != null)
{
_popup.PopupEntity(Loc.GetString("offer-item-no-give",
("item", Identity.Entity(offerItem.Item.Value, EntityManager)),
("target", Identity.Entity(uid, EntityManager))), component.Target.Value, component.Target.Value);
_popup.PopupEntity(Loc.GetString("offer-item-no-give-target",
("user", Identity.Entity(component.Target.Value, EntityManager)),
("item", Identity.Entity(offerItem.Item.Value, EntityManager))), component.Target.Value, uid);
}
offerItem.IsInOfferMode = false;
offerItem.IsInReceiveMode = false;
offerItem.Hand = null;
offerItem.Target = null;
offerItem.Item = null;
Dirty(component.Target.Value, offerItem);
}
component.IsInOfferMode = false;
component.IsInReceiveMode = false;
component.Hand = null;
component.Target = null;
component.Item = null;
Dirty(uid, component);
}
/// <summary>
/// Cancels the transfer of the item
/// </summary>
protected void UnReceive(EntityUid uid, OfferItemComponent? component = null, OfferItemComponent? offerItem = null)
{
if (component == null && !TryComp(uid, out component))
return;
if (offerItem == null && !TryComp(component.Target, out offerItem))
return;
if (!TryComp<HandsComponent>(uid, out var hands) || hands.ActiveHand == null ||
component.Target == null)
return;
if (offerItem.Item != null)
{
_popup.PopupEntity(Loc.GetString("offer-item-no-give",
("item", Identity.Entity(offerItem.Item.Value, EntityManager)),
("target", Identity.Entity(uid, EntityManager))), component.Target.Value, component.Target.Value);
_popup.PopupEntity(Loc.GetString("offer-item-no-give-target",
("user", Identity.Entity(component.Target.Value, EntityManager)),
("item", Identity.Entity(offerItem.Item.Value, EntityManager))), component.Target.Value, uid);
}
if (!offerItem.IsInReceiveMode)
{
offerItem.Target = null;
component.Target = null;
}
offerItem.Item = null;
offerItem.Hand = null;
component.IsInReceiveMode = false;
Dirty(uid, component);
}
/// <summary>
/// Returns true if <see cref="OfferItemComponent.IsInOfferMode"/> = true
/// </summary>
protected bool IsInOfferMode(EntityUid? entity, OfferItemComponent? component = null)
{
return entity != null && Resolve(entity.Value, ref component, false) && component.IsInOfferMode;
}
}

View File

@@ -19,6 +19,13 @@ public sealed class WhiteCVars
public static readonly CVarDef<bool> ShowTrails =
CVarDef.Create("white.show_trails", true, CVar.CLIENTONLY | CVar.ARCHIVE);
/*
* Offer Indicator
*/
public static readonly CVarDef<bool> OfferModeIndicatorsPointShow =
CVarDef.Create("white.offer_mode_indicators_point_show", true, CVar.ARCHIVE | CVar.CLIENTONLY);
/*
* Wiki rules
*/