Skip to content

Commit

Permalink
Merge branch 'Language-Menu' of https://github.com/VMSolidus/Einstein…
Browse files Browse the repository at this point in the history
…-Engines into Language-Menu
  • Loading branch information
VMSolidus committed Sep 20, 2024
2 parents b1e1bfa + 14d842c commit a098076
Show file tree
Hide file tree
Showing 38 changed files with 237 additions and 132 deletions.
26 changes: 26 additions & 0 deletions Content.Client/Standing/LayingDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Timing;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;

namespace Content.Client.Standing;

Expand All @@ -20,6 +21,8 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<LayingDownComponent, MoveEvent>(OnMovementInput);
SubscribeNetworkEvent<DrawDownedEvent>(OnDowned);
SubscribeLocalEvent<LayingDownComponent, StoodEvent>(OnStood);

SubscribeNetworkEvent<CheckAutoGetUpEvent>(OnCheckAutoGetUp);
}
Expand Down Expand Up @@ -48,6 +51,29 @@ private void OnMovementInput(EntityUid uid, LayingDownComponent component, MoveE
sprite.Rotation = Angle.FromDegrees(90);
}

private void OnDowned(DrawDownedEvent args)
{
var uid = GetEntity(args.Uid);

if (!TryComp<SpriteComponent>(uid, out var sprite)
|| !TryComp<LayingDownComponent>(uid, out var component))
return;

if (!component.OriginalDrawDepth.HasValue)
component.OriginalDrawDepth = sprite.DrawDepth;

sprite.DrawDepth = (int) DrawDepth.SmallMobs;
}

private void OnStood(EntityUid uid, LayingDownComponent component, StoodEvent args)
{
if (!TryComp<SpriteComponent>(uid, out var sprite)
|| !component.OriginalDrawDepth.HasValue)
return;

sprite.DrawDepth = component.OriginalDrawDepth.Value;
}

private void OnCheckAutoGetUp(CheckAutoGetUpEvent ev, EntitySessionEventArgs args)
{
if (!_timing.IsFirstTimePredicted)
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Administration/Commands/SetOutfitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Robust.Shared.Prototypes;
using Content.Server.Silicon.IPC;
using Content.Shared.Radio.Components;
using Content.Shared.Cluwne;

namespace Content.Server.Administration.Commands
{
Expand Down Expand Up @@ -129,6 +130,8 @@ public static bool SetOutfit(EntityUid target, string gear, IEntityManager entit
}
}

if (entityManager.HasComponent<CluwneComponent>(target))
return true; //Fuck it, nuclear option for not Cluwning an IPC because that causes a crash that SOMEHOW ignores null checks.
if (entityManager.HasComponent<EncryptionKeyHolderComponent>(target))
{
var encryption = new InternalEncryptionKeySpawner();
Expand Down
18 changes: 18 additions & 0 deletions Content.Server/Flight/FlightSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Shared.Flight.Events;
using Content.Shared.Mobs;
using Content.Shared.Popups;
using Content.Shared.Standing;
using Content.Shared.Stunnable;
using Content.Shared.Zombies;
using Robust.Shared.Audio.Systems;
Expand All @@ -16,6 +17,7 @@ public sealed class FlightSystem : SharedFlightSystem
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly StandingStateSystem _standing = default!;

public override void Initialize()
{
Expand All @@ -27,6 +29,7 @@ public override void Initialize()
SubscribeLocalEvent<FlightComponent, EntityZombifiedEvent>(OnZombified);
SubscribeLocalEvent<FlightComponent, KnockedDownEvent>(OnKnockedDown);
SubscribeLocalEvent<FlightComponent, StunnedEvent>(OnStunned);
SubscribeLocalEvent<FlightComponent, DownedEvent>(OnDowned);
SubscribeLocalEvent<FlightComponent, SleepStateChangedEvent>(OnSleep);
}
public override void Update(float frameTime)
Expand Down Expand Up @@ -103,6 +106,13 @@ private bool CanFly(EntityUid uid, FlightComponent component)
_popupSystem.PopupEntity(Loc.GetString("no-flight-while-zombified"), uid, uid, PopupType.Medium);
return false;
}

if (HasComp<StandingStateComponent>(uid) && _standing.IsDown(uid))
{
_popupSystem.PopupEntity(Loc.GetString("no-flight-while-lying"), uid, uid, PopupType.Medium);
return false;
}

return true;
}

Expand Down Expand Up @@ -142,6 +152,14 @@ private void OnStunned(EntityUid uid, FlightComponent component, ref StunnedEven
ToggleActive(uid, false, component);
}

private void OnDowned(EntityUid uid, FlightComponent component, ref DownedEvent args)
{
if (!component.On)
return;

ToggleActive(uid, false, component);
}

private void OnSleep(EntityUid uid, FlightComponent component, ref SleepStateChangedEvent args)
{
if (!component.On
Expand Down
12 changes: 7 additions & 5 deletions Content.Server/NPC/Components/NPCJukeComponent.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
using Content.Server.NPC.HTN.PrimitiveTasks.Operators.Combat;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;

namespace Content.Server.NPC.Components;

[RegisterComponent, AutoGenerateComponentPause]
public sealed partial class NPCJukeComponent : Component
{
[DataField("jukeType")]
[DataField]
public JukeType JukeType = JukeType.Away;

[DataField("jukeDuration")]
[DataField]
public float JukeDuration = 0.5f;

[DataField("nextJuke", customTypeSerializer:typeof(TimeOffsetSerializer))]
[DataField]
public float JukeCooldown = 3f;

[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan NextJuke;

[DataField("targetTile")]
[DataField]
public Vector2i? TargetTile;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,31 @@ public sealed partial class JukeOperator : HTNOperator, IHtnConditionalShutdown
{
[Dependency] private readonly IEntityManager _entManager = default!;

[DataField("jukeType")]
[DataField]
public JukeType JukeType = JukeType.AdjacentTile;

[DataField("shutdownState")]
[DataField]
public HTNPlanState ShutdownState { get; private set; } = HTNPlanState.PlanFinished;

/// <summary>
/// Controls how long(in seconds) the NPC will move while juking.
/// </summary>
[DataField]
public float JukeDuration = 0.5f;

/// <summary>
/// Controls how often (in seconds) an NPC will try to juke.
/// </summary>
[DataField]
public float JukeCooldown = 3f;

public override void Startup(NPCBlackboard blackboard)
{
base.Startup(blackboard);
var juke = _entManager.EnsureComponent<NPCJukeComponent>(blackboard.GetValue<EntityUid>(NPCBlackboard.Owner));
juke.JukeType = JukeType;
juke.JukeDuration = JukeDuration;
juke.JukeCooldown = JukeCooldown;
}

public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime)
Expand Down
33 changes: 14 additions & 19 deletions Content.Server/NPC/Systems/NPCJukeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Server.NPC.Events;
using Content.Server.NPC.HTN.PrimitiveTasks.Operators.Combat;
using Content.Server.Weapons.Melee;
using Content.Shared.Coordinates.Helpers;
using Content.Shared.NPC;
using Content.Shared.Weapons.Melee;
using Robust.Shared.Collections;
Expand Down Expand Up @@ -38,22 +39,19 @@ public override void Initialize()

private void OnJukeSteering(EntityUid uid, NPCJukeComponent component, ref NPCSteeringEvent args)
{
if (component.JukeType == JukeType.AdjacentTile)
if (_timing.CurTime < component.NextJuke)
{
if (_npcRangedQuery.TryGetComponent(uid, out var ranged) &&
ranged.Status == CombatStatus.NotInSight)
{
component.TargetTile = null;
return;
}
component.TargetTile = null;
return;
}

if (_timing.CurTime < component.NextJuke)
{
component.TargetTile = null;
return;
}
component.NextJuke = _timing.CurTime + TimeSpan.FromSeconds(component.JukeCooldown);

if (!TryComp<MapGridComponent>(args.Transform.GridUid, out var grid))
if (component.JukeType == JukeType.AdjacentTile)
{
if (_npcRangedQuery.TryGetComponent(uid, out var ranged)
&& ranged.Status is CombatStatus.NotInSight
|| !TryComp<MapGridComponent>(args.Transform.GridUid, out var grid))
{
component.TargetTile = null;
return;
Expand Down Expand Up @@ -107,12 +105,11 @@ private void OnJukeSteering(EntityUid uid, NPCJukeComponent component, ref NPCSt

var elapsed = _timing.CurTime - component.NextJuke;

// Finished juke, reset timer.
if (elapsed.TotalSeconds > component.JukeDuration ||
currentTile == component.TargetTile)
// Finished juke.
if (elapsed.TotalSeconds > component.JukeDuration
|| currentTile == component.TargetTile)
{
component.TargetTile = null;
component.NextJuke = _timing.CurTime + TimeSpan.FromSeconds(component.JukeDuration);
return;
}

Expand Down Expand Up @@ -155,9 +152,7 @@ private void OnJukeSteering(EntityUid uid, NPCJukeComponent component, ref NPCSt
var obstacleDirection = _transform.GetWorldPosition(melee.Target) - args.WorldPosition;

if (obstacleDirection == Vector2.Zero)
{
obstacleDirection = _random.NextVector2();
}

// If they're moving away then pursue anyway.
// If just hit then always back up a bit.
Expand Down
12 changes: 10 additions & 2 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2470,9 +2470,16 @@ public static readonly CVarDef<float>

public static readonly CVarDef<bool> HoldLookUp =
CVarDef.Create("rest.hold_look_up", false, CVar.CLIENT | CVar.ARCHIVE);


/// <summary>
/// When true, entities that fall to the ground will be able to crawl under tables and
/// plastic flaps, allowing them to take cover from gunshots.
/// </summary>
public static readonly CVarDef<bool> CrawlUnderTables =
CVarDef.Create("rest.crawlundertables", false, CVar.REPLICATED);

#endregion

#region Material Reclaimer

/// <summary>
Expand All @@ -2498,5 +2505,6 @@ public static readonly CVarDef<float>
CVarDef.Create("jetpack.enable_in_no_gravity", true, CVar.REPLICATED);

#endregion

}
}
9 changes: 9 additions & 0 deletions Content.Shared/Standing/LayingDownComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public sealed partial class LayingDownComponent : Component

[DataField, AutoNetworkedField]
public bool AutoGetUp;

[DataField, AutoNetworkedField]
public int? OriginalDrawDepth { get; set; }
}

[Serializable, NetSerializable]
Expand All @@ -24,3 +27,9 @@ public sealed class CheckAutoGetUpEvent(NetEntity user) : CancellableEntityEvent
{
public NetEntity User = user;
}

[Serializable, NetSerializable]
public sealed class DrawDownedEvent(NetEntity uid) : EntityEventArgs
{
public NetEntity Uid = uid;
}
8 changes: 8 additions & 0 deletions Content.Shared/Standing/StandingStateSystem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using Content.Shared.Buckle;
using Content.Shared.Buckle.Components;
using Content.Shared.CCVar;
using Content.Shared.Hands.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Physics;
using Content.Shared.Rotation;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Serialization;

namespace Content.Shared.Standing;

Expand All @@ -17,6 +20,7 @@ public sealed class StandingStateSystem : EntitySystem
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
[Dependency] private readonly SharedBuckleSystem _buckle = default!;
[Dependency] private readonly IConfigurationManager _config = default!;

// If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited.
private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable;
Expand Down Expand Up @@ -64,6 +68,10 @@ public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true
Dirty(standingState);
RaiseLocalEvent(uid, new DownedEvent(), false);

// Raising this event will lower the entity's draw depth to the same as a small mob.
if (_config.GetCVar(CCVars.CrawlUnderTables))
RaiseNetworkEvent(new DrawDownedEvent(GetNetEntity(uid)));

// Seemed like the best place to put it
_appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Horizontal, appearance);

Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public sealed partial class MeleeWeaponComponent : Component
/// Total width of the angle for wide attacks.
/// </summary>
[DataField, AutoNetworkedField]
public Angle Angle = Angle.FromDegrees(45);
public Angle Angle = Angle.FromDegrees(60);

[DataField, AutoNetworkedField]
public EntProtoId Animation = "WeaponArcPunch";
Expand All @@ -129,10 +129,10 @@ public sealed partial class MeleeWeaponComponent : Component
public bool SwingLeft;

[DataField, AutoNetworkedField]
public float HeavyStaminaCost = 10f;
public float HeavyStaminaCost = 2.5f;

[DataField, AutoNetworkedField]
public int MaxTargets = 1;
public int MaxTargets = 3;

// Sounds

Expand Down
39 changes: 39 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6500,3 +6500,42 @@ Entries:
id: 6374
time: '2024-09-20T02:48:43.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/934
- author: gluesniffler
changes:
- type: Add
message: >-
Adds an optional server variable which allows entities to crawl under
tables.
- type: Tweak
message: >-
Tables and plastic flaps are less resistant to damage, and can now be
targeted by guns by aiming on top of them.
id: 6375
time: '2024-09-20T19:34:02.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/939
- author: ODJ
changes:
- type: Tweak
message: Tweaked melee; Less stamina usage on heavy attacks.
id: 6376
time: '2024-09-20T19:34:46.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/938
- author: VMSolidus
changes:
- type: Tweak
message: >-
JukeOperator now allows for JukeDuration and JukeCooldown arguments.
JukeCooldown is a new feature where enemies must wait an amount of time
in seconds equal to the JukeCooldown, before they are allowed to attempt
to dodge a melee attack.
- type: Tweak
message: >-
By default, NPCs will only attempt to dodge attacks once every 5
seconds.
- type: Fix
message: >-
JukeOperator now performs extremely expensive math 5000 times less
often. EXIT CONDITIONS PEOPLE!
id: 6377
time: '2024-09-20T20:05:31.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/935
Loading

0 comments on commit a098076

Please sign in to comment.