This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
forked from new-frontiers-14/frontier-station-14
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rodentia Code (new-frontiers-14#2009)
* Rats * Update NamingSystem.cs * Fixup * Update rodentia.yml * Update rodentia.yml * Update mouth_storage.yml * Update SharedRatKingSystem.cs * What rats? * Rummager cooldown (30s), goblin guidebook rewrite --------- Co-authored-by: portfiend <[email protected]> Co-authored-by: Whatstone <[email protected]>
- Loading branch information
1 parent
afb0237
commit 95cbf55
Showing
126 changed files
with
2,877 additions
and
54 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
Content.Client/DeltaV/Abilities/CrawlUnderObjectsSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Content.Shared.DeltaV.Abilities; | ||
using Content.Shared.Popups; | ||
using Robust.Client.GameObjects; | ||
using DrawDepth = Content.Shared.DrawDepth.DrawDepth; | ||
|
||
namespace Content.Client.DeltaV.Abilities; | ||
|
||
public sealed partial class HideUnderTableAbilitySystem : SharedCrawlUnderObjectsSystem | ||
{ | ||
[Dependency] private readonly AppearanceSystem _appearance = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<CrawlUnderObjectsComponent, AppearanceChangeEvent>(OnAppearanceChange); | ||
} | ||
|
||
private void OnAppearanceChange(EntityUid uid, | ||
CrawlUnderObjectsComponent component, | ||
AppearanceChangeEvent args) | ||
{ | ||
if (!TryComp<SpriteComponent>(uid, out var sprite)) | ||
return; | ||
|
||
_appearance.TryGetData(uid, SneakMode.Enabled, out bool enabled); | ||
if (enabled) | ||
{ | ||
if (component.OriginalDrawDepth != null) | ||
return; | ||
|
||
component.OriginalDrawDepth = sprite.DrawDepth; | ||
sprite.DrawDepth = (int) DrawDepth.SmallMobs; | ||
} | ||
else | ||
{ | ||
if (component.OriginalDrawDepth == null) | ||
return; | ||
|
||
sprite.DrawDepth = (int) component.OriginalDrawDepth; | ||
component.OriginalDrawDepth = null; | ||
} | ||
} | ||
} |
140 changes: 140 additions & 0 deletions
140
Content.Server/DeltaV/Abilities/CrawlUnderObjectsSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
using Content.Shared.Actions; | ||
using Content.Shared.Climbing.Components; | ||
using Content.Shared.Climbing.Events; | ||
using Content.Shared.DeltaV.Abilities; | ||
using Content.Shared.Maps; | ||
using Content.Shared.Movement.Systems; | ||
using Content.Shared.Physics; | ||
using Robust.Server.GameObjects; | ||
using Robust.Shared.Physics; | ||
using Robust.Shared.Physics.Systems; | ||
|
||
namespace Content.Server.DeltaV.Abilities; | ||
|
||
public sealed partial class CrawlUnderObjectsSystem : SharedCrawlUnderObjectsSystem | ||
{ | ||
[Dependency] private readonly AppearanceSystem _appearance = default!; | ||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!; | ||
[Dependency] private readonly MovementSpeedModifierSystem _movespeed = default!; | ||
[Dependency] private readonly SharedPhysicsSystem _physics = default!; | ||
[Dependency] private readonly TurfSystem _turf = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<CrawlUnderObjectsComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<CrawlUnderObjectsComponent, ToggleCrawlingStateEvent>(OnAbilityToggle); | ||
SubscribeLocalEvent<CrawlUnderObjectsComponent, AttemptClimbEvent>(OnAttemptClimb); | ||
SubscribeLocalEvent<CrawlUnderObjectsComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed); | ||
} | ||
|
||
private bool IsOnCollidingTile(EntityUid uid) | ||
{ | ||
var xform = Transform(uid); | ||
var tile = xform.Coordinates.GetTileRef(); | ||
if (tile == null) | ||
return false; | ||
|
||
return _turf.IsTileBlocked(tile.Value, CollisionGroup.MobMask); | ||
} | ||
|
||
private void OnInit(EntityUid uid, CrawlUnderObjectsComponent component, ComponentInit args) | ||
{ | ||
if (component.ToggleHideAction != null) | ||
return; | ||
|
||
_actionsSystem.AddAction(uid, ref component.ToggleHideAction, component.ActionProto); | ||
} | ||
|
||
private bool EnableSneakMode(EntityUid uid, CrawlUnderObjectsComponent component) | ||
{ | ||
if (component.Enabled | ||
|| (TryComp<ClimbingComponent>(uid, out var climbing) | ||
&& climbing.IsClimbing == true)) | ||
return false; | ||
|
||
component.Enabled = true; | ||
Dirty(uid, component); | ||
RaiseLocalEvent(uid, new CrawlingUpdatedEvent(component.Enabled)); | ||
|
||
if (TryComp(uid, out FixturesComponent? fixtureComponent)) | ||
{ | ||
foreach (var (key, fixture) in fixtureComponent.Fixtures) | ||
{ | ||
var newMask = (fixture.CollisionMask | ||
& (int)~CollisionGroup.HighImpassable | ||
& (int)~CollisionGroup.MidImpassable) | ||
| (int)CollisionGroup.InteractImpassable; | ||
if (fixture.CollisionMask == newMask) | ||
continue; | ||
|
||
component.ChangedFixtures.Add((key, fixture.CollisionMask)); | ||
_physics.SetCollisionMask(uid, | ||
key, | ||
fixture, | ||
newMask, | ||
manager: fixtureComponent); | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
private bool DisableSneakMode(EntityUid uid, CrawlUnderObjectsComponent component) | ||
{ | ||
if (!component.Enabled | ||
|| IsOnCollidingTile(uid) | ||
|| (TryComp<ClimbingComponent>(uid, out var climbing) | ||
&& climbing.IsClimbing == true)) | ||
return false; | ||
|
||
component.Enabled = false; | ||
Dirty(uid, component); | ||
RaiseLocalEvent(uid, new CrawlingUpdatedEvent(component.Enabled)); | ||
|
||
// Restore normal collision masks | ||
if (TryComp(uid, out FixturesComponent? fixtureComponent)) | ||
foreach (var (key, originalMask) in component.ChangedFixtures) | ||
if (fixtureComponent.Fixtures.TryGetValue(key, out var fixture)) | ||
_physics.SetCollisionMask(uid, key, fixture, originalMask, fixtureComponent); | ||
|
||
component.ChangedFixtures.Clear(); | ||
return true; | ||
} | ||
|
||
private void OnAbilityToggle(EntityUid uid, | ||
CrawlUnderObjectsComponent component, | ||
ToggleCrawlingStateEvent args) | ||
{ | ||
if (args.Handled) | ||
return; | ||
|
||
bool result; | ||
|
||
if (component.Enabled) | ||
result = DisableSneakMode(uid, component); | ||
else | ||
result = EnableSneakMode(uid, component); | ||
|
||
if (TryComp<AppearanceComponent>(uid, out var app)) | ||
_appearance.SetData(uid, SneakMode.Enabled, component.Enabled, app); | ||
|
||
_movespeed.RefreshMovementSpeedModifiers(uid); | ||
|
||
args.Handled = result; | ||
} | ||
|
||
private void OnAttemptClimb(EntityUid uid, | ||
CrawlUnderObjectsComponent component, | ||
AttemptClimbEvent args) | ||
{ | ||
if (component.Enabled == true) | ||
args.Cancelled = true; | ||
} | ||
|
||
private void OnRefreshMovespeed(EntityUid uid, CrawlUnderObjectsComponent component, RefreshMovementSpeedModifiersEvent args) | ||
{ | ||
if (component.Enabled) | ||
args.ModifySpeed(component.SneakSpeedModifier, component.SneakSpeedModifier); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Content.Server/DeltaV/Storage/EntitySystems/MouthStorageSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Content.Server.Nutrition; | ||
using Content.Server.Speech; | ||
using Content.Server.Speech.EntitySystems; | ||
using Content.Shared.DeltaV.Storage.Components; | ||
using Content.Shared.DeltaV.Storage.EntitySystems; | ||
using Content.Shared.Storage; | ||
|
||
namespace Content.Server.DeltaV.Storage.EntitySystems; | ||
|
||
public sealed class MouthStorageSystem : SharedMouthStorageSystem | ||
{ | ||
[Dependency] private readonly ReplacementAccentSystem _replacement = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<MouthStorageComponent, AccentGetEvent>(OnAccent); | ||
SubscribeLocalEvent<MouthStorageComponent, IngestionAttemptEvent>(OnIngestAttempt); | ||
} | ||
|
||
// Force you to mumble if you have items in your mouth | ||
private void OnAccent(EntityUid uid, MouthStorageComponent component, AccentGetEvent args) | ||
{ | ||
if (IsMouthBlocked(component)) | ||
args.Message = _replacement.ApplyReplacements(args.Message, "mumble"); | ||
} | ||
|
||
// Attempting to eat or drink anything with items in your mouth won't work | ||
private void OnIngestAttempt(EntityUid uid, MouthStorageComponent component, IngestionAttemptEvent args) | ||
{ | ||
if (!IsMouthBlocked(component)) | ||
return; | ||
|
||
if (!TryComp<StorageComponent>(component.MouthId, out var storage)) | ||
return; | ||
|
||
var firstItem = storage.Container.ContainedEntities[0]; | ||
args.Blocker = firstItem; | ||
args.Cancel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
Content.Shared/DeltaV/Abilities/AlwaysTriggerMousetrapComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using Robust.Shared.GameStates; | ||
namespace Content.Shared.Abilities; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class AlwaysTriggerMousetrapComponent : Component; |
47 changes: 47 additions & 0 deletions
47
Content.Shared/DeltaV/Abilities/CrawlUnderObjectsComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Content.Shared.Actions; | ||
using DrawDepth = Content.Shared.DrawDepth.DrawDepth; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.DeltaV.Abilities; | ||
|
||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
public sealed partial class CrawlUnderObjectsComponent : Component | ||
{ | ||
[DataField] | ||
public EntityUid? ToggleHideAction; | ||
|
||
[DataField] | ||
public EntProtoId? ActionProto; | ||
|
||
[DataField] | ||
public bool Enabled = false; | ||
|
||
/// <summary> | ||
/// List of fixtures that had their collision mask changed. | ||
/// Required for re-adding the collision mask. | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public List<(string key, int originalMask)> ChangedFixtures = new(); | ||
|
||
[DataField] | ||
public int? OriginalDrawDepth; | ||
|
||
[DataField] | ||
public float SneakSpeedModifier = 0.7f; | ||
} | ||
|
||
[Serializable, NetSerializable] | ||
public enum SneakMode : byte | ||
{ | ||
Enabled | ||
} | ||
|
||
public sealed partial class ToggleCrawlingStateEvent : InstantActionEvent { } | ||
|
||
[Serializable, NetSerializable] | ||
public sealed partial class CrawlingUpdatedEvent(bool enabled = false) : EventArgs | ||
{ | ||
public readonly bool Enabled = enabled; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Robust.Shared.GameStates; | ||
namespace Content.Shared.Abilities; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
[AutoGenerateComponentState] | ||
public sealed partial class RummagerComponent : Component | ||
{ | ||
// Frontier: cooldowns per-rummager | ||
/// <summary> | ||
/// Frontier: Last time this entity has rummaged, used to check if cooldown has expired | ||
/// </summary> | ||
[ViewVariables] | ||
public TimeSpan? LastRummaged; | ||
|
||
/// <summary> | ||
// Frontier: Minimum time between this entity's rummage attempts | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
[AutoNetworkedField] | ||
public TimeSpan Cooldown = TimeSpan.FromSeconds(30.0f); | ||
// End Frontier | ||
} |
25 changes: 25 additions & 0 deletions
25
Content.Shared/DeltaV/Abilities/SharedCrawlUnderObjectsSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
using Content.Shared.Popups; | ||
|
||
namespace Content.Shared.DeltaV.Abilities; | ||
public abstract class SharedCrawlUnderObjectsSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedPopupSystem _popup = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<CrawlUnderObjectsComponent, CrawlingUpdatedEvent>(OnCrawlingUpdated); | ||
} | ||
|
||
private void OnCrawlingUpdated(EntityUid uid, | ||
CrawlUnderObjectsComponent component, | ||
CrawlingUpdatedEvent args) | ||
{ | ||
if (args.Enabled) | ||
_popup.PopupEntity(Loc.GetString("crawl-under-objects-toggle-on"), uid); | ||
else | ||
_popup.PopupEntity(Loc.GetString("crawl-under-objects-toggle-off"), uid); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Content.Shared/DeltaV/Storage/Components/MouthStorageComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Content.Shared.DeltaV.Storage.EntitySystems; | ||
using Content.Shared.FixedPoint; | ||
using Robust.Shared.Containers; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Prototypes; | ||
namespace Content.Shared.DeltaV.Storage.Components; | ||
|
||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
[Access(typeof(SharedMouthStorageSystem))] | ||
public sealed partial class MouthStorageComponent : Component | ||
{ | ||
public const string MouthContainerId = "mouth"; | ||
|
||
[DataField, AutoNetworkedField] | ||
public EntProtoId? OpenStorageAction; | ||
|
||
[DataField, AutoNetworkedField] | ||
public EntityUid? Action; | ||
|
||
[DataField] | ||
public EntProtoId MouthProto = "ActionOpenMouthStorage"; | ||
|
||
[ViewVariables] | ||
public Container Mouth = default!; | ||
|
||
[DataField] | ||
public EntityUid? MouthId; | ||
|
||
// Mimimum inflicted damage on hit to spit out items | ||
[DataField] | ||
public FixedPoint2 SpitDamageThreshold = FixedPoint2.New(2); | ||
} |
Oops, something went wrong.