Files
Delta-v/Content.Shared/DeltaV/Storage/EntitySystems/SharedMouthStorageSystem.cs
T
portfiendandDEATHB4DEFEAT 690cbe995a Rodentia Species (#1511)
* add: basic rodent species

* add: rodentia base sprites

* add: basic rodent hand/foot markings

* add: ears i got em

* add: tail markings

* add: big ears

by request

* tweak: default markings, coloration

everything uses skin color by default when added except for these new "default" markings which use tattoo

* add: the rest of the basic body part markings

* add: snout textures

* add: pattern markings

* add: cheek detail

* add: sex variations for chest marking

* add: give rodentia the generic markings

* add: rodentia names

* add: damage, voice, mass, emotes to rodentia

* add: rummager ability for rodentia

* remove: temperature protection from rodentia

* add: some makeup markings for rodentia

* add: include rodentia in misc pools

* add: rodentia guidebook entries

* tweak: adjust rodentia marking points

* add: rodentia pie sprite

* tweak desc

* tweak: change rodentia name scheme

* tweak: adjust damage modifiers for rodentia

* add: rodentia always trigger mouse traps

* tweak: rodentia have unique speech verbs

* tweak: change rodentia inventory shape

* tweak: rodentia take more phys dmg overall

* tweak: made rodentia hungry

* add: mouth storage component on rodents

* add: server mouthstoragesystem

* add: force-dump mouth storage on trip

hmm the networking on this is a little ehh. but watever

* add: rodentia drop mouth items on damage

* add: blocked interactions if mouth is full

* fix: corrected accent oops

* tweak: tense

* fuck this import in particular

* tweak: spit damage threshold

* fix: no redundant open actions

* refactor: move this action into the types file

* add: rodentia get ability to hide under tables etc.

* tweak: change rodentia action icons

* refactor: im renaming this component and system lol

* refactor: rename this event too

i was gonna refactor the whole system to be more like climbing, but the climbing system is convoluted so im just gonna do this and put it aside

* tweak: fix the mouth storage icon
the number covers it

* tweak: check if colliding with table before un-sneaking

* fix: crawl action cooldown and popup text

* add: slowdown to sneak ability

* refactor: fix this namespace

* tweak: rummageable objects now use a cooldown

* fix: newlines

* Apply suggestions from code review

Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
Signed-off-by: portfiend <109661617+portfiend@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
Signed-off-by: portfiend <109661617+portfiend@users.noreply.github.com>

* fix: collision group variavbles

* add: proper "full body" sprite

* add: move blaze to head folder, "round face" marking

* add: whisker markings

* tweal: rodentia are 50% -> 33% hungrier

1.5x seemed excessive

* refactor(mouthStorage): move OnExamined from server to shared

* refactor(mousetrap): use HasComp

* refactor(mouthStorage): use a public api instead of event here

* refactor(yml): KILL REPETITION

* refactor(parts/rodentia): KILL REPETITION

---------

Signed-off-by: portfiend <109661617+portfiend@users.noreply.github.com>
Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
2024-09-07 23:04:34 -03:00

85 lines
3.2 KiB
C#

using Content.Shared.Actions;
using Content.Shared.CombatMode;
using Content.Shared.Damage;
using Content.Shared.DeltaV.Storage.Components;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Standing;
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Robust.Shared.Containers;
using Robust.Shared.Map;
namespace Content.Shared.DeltaV.Storage.EntitySystems;
public abstract class SharedMouthStorageSystem : EntitySystem
{
[Dependency] private readonly DumpableSystem _dumpableSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MouthStorageComponent, MapInitEvent>(OnMouthStorageInit);
SubscribeLocalEvent<MouthStorageComponent, DownedEvent>(DropAllContents);
SubscribeLocalEvent<MouthStorageComponent, DisarmedEvent>(DropAllContents);
SubscribeLocalEvent<MouthStorageComponent, DamageChangedEvent>(OnDamageModified);
SubscribeLocalEvent<MouthStorageComponent, ExaminedEvent>(OnExamined);
}
protected bool IsMouthBlocked(MouthStorageComponent component)
{
if (!TryComp<StorageComponent>(component.MouthId, out var storage))
return false;
return storage.Container.ContainedEntities.Count > 0;
}
private void OnMouthStorageInit(EntityUid uid, MouthStorageComponent component, MapInitEvent args)
{
if (string.IsNullOrWhiteSpace(component.MouthProto))
return;
component.Mouth = _containerSystem.EnsureContainer<Container>(uid, MouthStorageComponent.MouthContainerId);
component.Mouth.ShowContents = false;
component.Mouth.OccludesLight = false;
var mouth = Spawn(component.MouthProto, new EntityCoordinates(uid, 0, 0));
_containerSystem.Insert(mouth, component.Mouth);
component.MouthId = mouth;
if (!string.IsNullOrWhiteSpace(component.OpenStorageAction) && component.Action == null)
_actionsSystem.AddAction(uid, ref component.Action, component.OpenStorageAction, mouth);
}
private void DropAllContents(EntityUid uid, MouthStorageComponent component, EntityEventArgs args)
{
if (component.MouthId == null)
return;
_dumpableSystem.DumpContents(component.MouthId.Value, uid, uid);
}
private void OnDamageModified(EntityUid uid, MouthStorageComponent component, DamageChangedEvent args)
{
if (args.DamageDelta == null
|| !args.DamageIncreased
|| args.DamageDelta.GetTotal() < component.SpitDamageThreshold)
return;
DropAllContents(uid, component, args);
}
// Other people can see if this person has items in their mouth.
private void OnExamined(EntityUid uid, MouthStorageComponent component, ExaminedEvent args)
{
if (IsMouthBlocked(component))
{
var subject = Identity.Entity(uid, EntityManager);
args.PushMarkup(Loc.GetString("mouth-storage-examine-condition-occupied", ("entity", subject)));
}
}
}