Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Черты персонажа #202

Merged
merged 11 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Content.Client/ADT/Quirks/QuirksSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Content.Shared.ADT.Traits;
using Content.Client.Storage.Components;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Verbs;
using Content.Shared.Tools.Components;
using Content.Shared.Whitelist;
using Content.Shared.Lock;

namespace Content.Client.ADT.Traits;

public sealed class QuirksSystem : SharedQuirksSystem
{
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;

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

SubscribeLocalEvent<EntityStorageComponent, GetVerbsEvent<AlternativeVerb>>(OnGetHideVerbs);

}

private void OnGetHideVerbs(EntityUid uid, EntityStorageComponent comp, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanAccess || !args.CanInteract)
return;

if (!HasComp<FastLockersComponent>(args.User))
return;
if (TryComp<WeldableComponent>(uid, out var weldable) && weldable.IsWelded)
return;
if (_whitelist.IsWhitelistFail(comp.Whitelist, args.User))
return;
if (TryComp<LockComponent>(uid, out var lockComponent) && lockComponent.Locked)
return;

AlternativeVerb verb = new()
{
Act = () => TryHide(args.User, uid),
Text = Loc.GetString("quirk-fast-locker-hide-verb"),
};
args.Verbs.Add(verb);

}

}
46 changes: 46 additions & 0 deletions Content.Server/ADT/Quirks/QuirksSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Content.Shared.ADT.Traits;
using Content.Server.Storage.Components;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Verbs;
using Content.Shared.Tools.Components;
using Content.Shared.Whitelist;
using Content.Shared.Lock;

namespace Content.Server.ADT.Traits;

public sealed class QuirksSystem : SharedQuirksSystem
{
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<EntityStorageComponent, GetVerbsEvent<AlternativeVerb>>(OnGetHideVerbs);

}

private void OnGetHideVerbs(EntityUid uid, EntityStorageComponent comp, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanAccess || !args.CanInteract)
return;

if (!HasComp<FastLockersComponent>(args.User))
return;
if (TryComp<WeldableComponent>(uid, out var weldable) && weldable.IsWelded)
return;

if (_whitelist.IsWhitelistFail(comp.Whitelist, args.User))
return;
if (TryComp<LockComponent>(uid, out var lockComponent) && lockComponent.Locked)
return;

AlternativeVerb verb = new()
{
Act = () => TryHide(args.User, uid),
Text = Loc.GetString("quirk-fast-locker-hide-verb"),
};
args.Verbs.Add(verb);

}

}
9 changes: 9 additions & 0 deletions Content.Shared/ADT/Quirks/Components/FastLockersComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Robust.Shared.GameStates;

namespace Content.Shared.ADT.Traits;

[RegisterComponent]
[NetworkedComponent]
public sealed partial class FastLockersComponent : Component
{
}
14 changes: 14 additions & 0 deletions Content.Shared/ADT/Quirks/Components/FreerunningComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Shared.Tag;
using Robust.Shared.Prototypes;
using Robust.Shared.GameStates;

namespace Content.Shared.ADT.Traits;

[RegisterComponent]
[NetworkedComponent]
public sealed partial class FreerunningComponent : Component
{
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public float Modifier = 0.6f;
}
14 changes: 14 additions & 0 deletions Content.Shared/ADT/Quirks/Components/HardThrowerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Shared.Tag;
using Robust.Shared.Prototypes;
using Robust.Shared.GameStates;

namespace Content.Shared.ADT.Traits;

[RegisterComponent]
[NetworkedComponent]
public sealed partial class HardThrowerComponent : Component
{
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public float Modifier = 0.8f;
}
11 changes: 11 additions & 0 deletions Content.Shared/ADT/Quirks/Components/SoftWalkComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Content.Shared.Tag;
using Robust.Shared.Prototypes;
using Robust.Shared.GameStates;

namespace Content.Shared.ADT.Traits;

[RegisterComponent]
[NetworkedComponent]
public sealed partial class SoftWalkComponent : Component
{
}
14 changes: 14 additions & 0 deletions Content.Shared/ADT/Quirks/Components/SprinterComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Shared.Tag;
using Robust.Shared.Prototypes;
using Robust.Shared.GameStates;

namespace Content.Shared.ADT.Traits;

[RegisterComponent]
[NetworkedComponent]
public sealed partial class SprinterComponent : Component
{
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public float Modifier = 1.1f;
}
69 changes: 69 additions & 0 deletions Content.Shared/ADT/Quirks/EntitySystems/SharedQuirksSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Content.Shared.Climbing.Events;
using Robust.Shared.Network;
using Content.Shared.Throwing;
using Content.Shared.Verbs;
using Content.Shared.Tools.Components;
using Content.Shared.StepTrigger.Systems;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.Tag;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.StepTrigger.Components;

namespace Content.Shared.ADT.Traits;

public abstract class SharedQuirksSystem : EntitySystem
{
[Dependency] private readonly SharedEntityStorageSystem _storage = default!;
[Dependency] protected readonly IRobustRandom _random = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly TagSystem _tag = default!;

public override void Initialize()
{
SubscribeLocalEvent<FreerunningComponent, CheckClimbSpeedModifiersEvent>(OnFreerunningClimbTimeModify);

SubscribeLocalEvent<SprinterComponent, MapInitEvent>(OnSprinterMapInit);
SubscribeLocalEvent<SprinterComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);

SubscribeLocalEvent<HardThrowerComponent, CheckThrowRangeModifiersEvent>(OnThrowerRangeModify);
}

public void TryHide(EntityUid uid, EntityUid closet)
{
if (_storage.Insert(uid, closet))
{
_popup.PopupClient(Loc.GetString("quirk-fast-locker-hide-success"), uid);
}
else
_popup.PopupCursor(Loc.GetString("quirk-fast-locker-hide-fail"), uid);
}

private void OnFreerunningClimbTimeModify(EntityUid uid, FreerunningComponent comp, ref CheckClimbSpeedModifiersEvent args)
{
if (args.User == args.Climber)
args.Time *= comp.Modifier;
}

private void OnSprinterMapInit(EntityUid uid, SprinterComponent comp, MapInitEvent args)
{
if (!TryComp<MovementSpeedModifierComponent>(uid, out var move))
return;
_movementSpeed.RefreshMovementSpeedModifiers(uid, move);
}
private void OnRefreshMovespeed(EntityUid uid, SprinterComponent component, RefreshMovementSpeedModifiersEvent args)
{
args.ModifySpeed(1f, component.Modifier);
}

private void OnThrowerRangeModify(EntityUid uid, HardThrowerComponent component, ref CheckThrowRangeModifiersEvent args)
{
args.SpeedMod = component.Modifier;
args.VectorMod = component.Modifier;
}

}
6 changes: 6 additions & 0 deletions Content.Shared/Climbing/Events/CheckClimbSpeedModifiers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Content.Shared.Climbing.Events; // ADT File

[ByRefEvent]
public record struct CheckClimbSpeedModifiersEvent(EntityUid User, EntityUid Climber, EntityUid Climbable, float Time)
{
}
8 changes: 6 additions & 2 deletions Content.Shared/Climbing/Systems/ClimbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,12 @@ public bool TryClimb(
RaiseLocalEvent(climbable, ref ev);
if (ev.Cancelled)
return false;
// ADT Quirks start
var speedEv = new CheckClimbSpeedModifiersEvent(user, entityToMove, climbable, comp.ClimbDelay);
RaiseLocalEvent(entityToMove, ref speedEv);
var delay = speedEv.Time;

var args = new DoAfterArgs(EntityManager, user, comp.ClimbDelay, new ClimbDoAfterEvent(),
var args = new DoAfterArgs(EntityManager, user, delay, new ClimbDoAfterEvent(),
FaDeOkno marked this conversation as resolved.
Show resolved Hide resolved
entityToMove,
target: climbable,
used: entityToMove)
Expand All @@ -226,7 +230,7 @@ public bool TryClimb(
BreakOnDamage = true,
DuplicateCondition = DuplicateConditions.SameTool | DuplicateConditions.SameTarget
};

// ADT Quirks end
_audio.PlayPredicted(comp.StartClimbSound, climbable, user);
return _doAfterSystem.TryStartDoAfter(args, out id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ namespace Content.Shared.StepTrigger.Components;
/// Grants the attached entity to step triggers.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class StepTriggerImmuneComponent : Component;
public sealed partial class StepTriggerImmuneComponent : Component {} // "{}" is ADT part
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Examine;
using Content.Shared.ADT.Traits;
using Content.Shared.Examine;
using Content.Shared.Inventory;
using Content.Shared.StepTrigger.Components;
using Content.Shared.Tag;
Expand All @@ -24,6 +25,9 @@ private void OnStepTriggerAttempt(Entity<StepTriggerImmuneComponent> ent, ref St

private void OnStepTriggerClothingAttempt(EntityUid uid, ClothingRequiredStepTriggerComponent component, ref StepTriggerAttemptEvent args)
{
if (HasComp<SoftWalkComponent>(args.Tripper)) // ADT Quirks
args.Cancelled = true;

if (_inventory.TryGetInventoryEntity<ClothingRequiredStepTriggerImmuneComponent>(args.Tripper, out _))
{
args.Cancelled = true;
Expand Down
9 changes: 9 additions & 0 deletions Content.Shared/Throwing/CheckThrowRangeModifiersEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Numerics; // ADT File

namespace Content.Shared.Throwing;

/// <summary>
/// Raised on thrown entity.
/// </summary>
[ByRefEvent]
public record struct CheckThrowRangeModifiersEvent(EntityUid? User, float VectorMod = 1f, float SpeedMod = 1f);
7 changes: 7 additions & 0 deletions Content.Shared/Throwing/ThrowingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ public void TryThrow(EntityUid uid,
// If someone changes how tile friction works at some point, this will have to be adjusted.
var throwSpeed = compensateFriction ? direction.Length() / (flyTime + 1 / tileFriction) : baseThrowSpeed;
var impulseVector = direction.Normalized() * throwSpeed * physics.Mass;
// ADT Quirks start
var modifiersEv = new CheckThrowRangeModifiersEvent(user);
RaiseLocalEvent(user ?? EntityUid.Invalid, ref modifiersEv);
throwSpeed *= modifiersEv.SpeedMod;
impulseVector *= modifiersEv.VectorMod;
// ADT Quirks end

_physics.ApplyLinearImpulse(uid, impulseVector, body: physics);

if (comp.LandTime == null || comp.LandTime <= TimeSpan.Zero)
Expand Down
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/ADT/Interaction/fast-hide-popups.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
quirk-fast-locker-hide-success = Вы успешно спрятались.
quirk-fast-locker-hide-fail = Вы не можете забраться сюда.
quirk-fast-locker-hide-verb = Спрятаться
4 changes: 3 additions & 1 deletion Resources/Locale/ru-RU/ADT/traits/categories.ftl
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
trait-category-height = Рост
trait-category-quirks = Особенности
trait-category-height = Рост

14 changes: 14 additions & 0 deletions Resources/Locale/ru-RU/ADT/traits/positive.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trait-soft-walk-name = Осторожный шаг
trait-soft-walk-desc = Вы достаточно осторожны, чтобы не наступать на опасные точки даже без обуви.

trait-freerunning-name = Паркурщик
trait-freerunning-desc = Вы гораздо быстрее забираетесь на столы.

trait-sprinter-name = Спринтер
trait-sprinter-desc = Вы бегаете чуть быстрее остальных представителей своего вида.

trait-fast-lockers-name = Ловкий
trait-fast-lockers-desc = Вы можете моментально и максимально незаметно забраться внутрь шкафа, или ящика.

trait-hard-thrower-name = Сильный бросок
trait-hard-thrower-desc = Вы бросаетесь вещами сильнее остальных.
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ humanoid-profile-editor-no-traits = Нет доступных черт
humanoid-profile-editor-trait-count-hint = Доступно очков: [{ $current }/{ $max }]
trait-category-disabilities = Ограничения
trait-category-speech = Черты речи
trait-category-quirks = Причуды
#trait-category-quirks = Причуды # Название фигня, в адт папке лучше
6 changes: 4 additions & 2 deletions Resources/Prototypes/ADT/Traits/disabilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
id: ADTHemophilia
name: trait-hemophilia-name
description: trait-hemophilia-desc
category: Disabilities
category: Quirks # ADT Quirks
components:
- type: Hemophilia
modifier: 0.01
cost: -2 # ADT Quirks

# Simple Station

- type: trait
id: ColorBlindnessMonochrome
name: trait-monochromacy-name
description: trait-monochromacy-description
category: Disabilities
category: Quirks # ADT Quirks
components:
- type: Monochromacy
cost: -1 # ADT Quirks
Loading
Loading