2024-07-13 14:05:22 -07:00
|
|
|
using System.Linq;
|
2024-06-02 05:07:41 +01:00
|
|
|
using System.Numerics;
|
2023-12-04 18:04:39 -05:00
|
|
|
using Content.Client.Animations;
|
2023-09-12 22:34:04 +10:00
|
|
|
using Content.Shared.Hands;
|
2022-08-08 12:35:57 +10:00
|
|
|
using Content.Shared.Storage;
|
2023-09-11 21:20:46 +10:00
|
|
|
using Content.Shared.Storage.EntitySystems;
|
2025-02-08 17:17:55 +11:00
|
|
|
using Robust.Client.Player;
|
|
|
|
|
using Robust.Shared.GameStates;
|
2023-09-12 22:34:04 +10:00
|
|
|
using Robust.Shared.Map;
|
2023-09-11 21:20:46 +10:00
|
|
|
using Robust.Shared.Timing;
|
2022-03-30 16:23:20 -07:00
|
|
|
|
2022-08-08 12:35:57 +10:00
|
|
|
namespace Content.Client.Storage.Systems;
|
2022-03-30 16:23:20 -07:00
|
|
|
|
2023-09-11 21:20:46 +10:00
|
|
|
public sealed class StorageSystem : SharedStorageSystem
|
2022-03-30 16:23:20 -07:00
|
|
|
{
|
2023-09-11 21:20:46 +10:00
|
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
2025-02-08 17:17:55 +11:00
|
|
|
[Dependency] private readonly IPlayerManager _player = default!;
|
2023-10-14 10:28:06 -07:00
|
|
|
[Dependency] private readonly EntityPickupAnimationSystem _entityPickupAnimation = default!;
|
2023-09-11 21:20:46 +10:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
private Dictionary<EntityUid, ItemStorageLocation> _oldStoredItems = new();
|
2023-09-11 21:20:46 +10:00
|
|
|
|
2025-02-17 19:24:34 +11:00
|
|
|
private List<(StorageBoundUserInterface Bui, bool Value)> _queuedBuis = new();
|
|
|
|
|
|
2022-03-30 16:23:20 -07:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
SubscribeLocalEvent<StorageComponent, ComponentHandleState>(OnStorageHandleState);
|
2023-09-12 22:34:04 +10:00
|
|
|
SubscribeNetworkEvent<PickupAnimationEvent>(HandlePickupAnimation);
|
2024-04-20 11:51:16 +10:00
|
|
|
SubscribeAllEvent<AnimateInsertingEntitiesEvent>(HandleAnimatingInsertingEntities);
|
2022-03-30 16:23:20 -07:00
|
|
|
}
|
|
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
private void OnStorageHandleState(EntityUid uid, StorageComponent component, ref ComponentHandleState args)
|
2023-09-11 21:20:46 +10:00
|
|
|
{
|
2025-02-08 17:17:55 +11:00
|
|
|
if (args.Current is not StorageComponentState state)
|
|
|
|
|
return;
|
2023-12-08 13:43:37 -05:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
component.Grid.Clear();
|
|
|
|
|
component.Grid.AddRange(state.Grid);
|
|
|
|
|
component.MaxItemSize = state.MaxItemSize;
|
|
|
|
|
component.Whitelist = state.Whitelist;
|
|
|
|
|
component.Blacklist = state.Blacklist;
|
Changeling devour and transform (#34002)
* Initial:
Create Devour componentry, preliminary identity storage and the systems
for Devouring
* I have genuinely no idea what i'm doing
- added the radial menu, it has nothing in it.
- trying to get it to populate. the event under the event is broken,
i don't know why, but apparently it's not typed right
- Added a placeholder transform
- oh also fixed up some devour stuff and moved some things around.
* Holey moley, Transform, better devour, oh my!
- Move DnaComponent into Shared because we need it for the DNA cloning
- Make Transform MOSTLY work on the LAST identity devoured.
- Fix some issues on devour that involved prediction, canceling and
Damage exeucting (Thanks Plykiya for pointing out AttemptFrequency!)
* Proper tail stealing and Damage modifier attempt
Add check to add a wagging component on the Changeling if the victim's
species Prototype had one.
attempt to add the Damage mitigation check
* MAJOR CLEANUP AND FIXES AUGH 3 DAYS!!!
- Nullspaced a clone of a victim
- fix audio using server virtualized Pvs (i hate this)
- fix the mispredicted doafters
- Clean up a wholelotta code
- utilize clone systems to clone appearances
- Move CloneAppearance from server to shared So we can actually access
it
* Examine stuff, more cleanup, Jumpsuit ripping
- make rotting prevent the action
- Add ripping of clothing (guh why is it also server)
- add some System stuff for pushing husked corpse inspection
- clean up more badcode
* Doing things properly, UI sorta kinda works.
- Utilize Relayed events for Devour checking
- Get a UI that partially works, Says the name of identities, doesn't
show their looks
- Make use of the New Dynamic BUI assignment
- commit the sin of no client prediction cause nullspace entities aren't
networked
* Got an entity for the Frontend transform
Issue with the looks
* Stick a camera into a fake mobs forehead
- Get the UI to see the net entity in pause space by using a
ViewSubscriber to get the Pvs from the initially stored identity entity
- Remove all the other parts used to try to get this to work before hand
* Raaaaadiallllllls also fix protection coefficents
- Change FancyWindow to Radial
- Fix Issue where coeffeient checking was the wrong way round
* absolutely massive cleanup, no more camera in mobs
- cleaned up event variables that are not needed
- Removed the use of a Pause space and go back to Nullspace usage
- use a PvsOverride rather than ViewSharing
- Remove old commented out code and Lots of unused code
* Fix "Ui elements" dying on the screen
- some minor cleanup
- don't start the entities that get cloned
* ftl, cleanup, and fixing missing transform details
- add replace functionality to TypingIndicatorSystem and
BodyEmotesSystem
- add placeholder sounds and functions to TransformBodyEmotes
- add extra Pvs handling for later use
- attributions for the funny straw sound
- Sound collections for all of the sounds
- various cleanups
* Some extra cleanup
* Fix some false assumptions about TypingIndicator
- Bubbles now transfer on spawned humans rather than used humans
- Clean up YET MORE CODE
- make it so you can't eat yourself
* Oooprs, forgot to add a Husked Corpse Loc
* Missing period in the husked corpse loc
* bad devour windup placeholder
* Husking and WIP Lungs
- Husking now will be prevented from Revival fully and will change
the appearance of players
* Add finalized Sprites for actions and final meta
- add devour on and off sprites
- add transform action sprite
- Add Armblade sprite for future use
- Credit obscenelytinyshark for the sprites <3
* Remove ling lungs, Entity<> everything
- Remove the ling lungs stuff for now... body system is overly
complicated, makes my head hurt
- Switch every method to use Entity<> from Uid, Comp format
* cleanup, admin logging, WIP Roles
* Admin verb, Roundstart, gamerule stuff
- add a Admin verb to make Changelingification easy!
- Add game rule stuff for admin verb and to tell the hapless
goober how to be a changeling... sorta
- clean up parts to make VV easy... USE THE VERB!!
* Armor Coefficent Check
- Remove bespoke changeling armor check and replace it
with a generic armor coefficient query.
* move to UnrevivableComponent instead of husked
- Move UnrevivableComponent to shared
- add Analyzable and ReasonMessage to UnrevivableComponent
to give granular control of the message and whether or not it shows up
in the analyzer
- remove the check for HuskedComponent in DefibrillatorSystem
* aaaaaaa CopyComp
- Some cleanup
- make Vocal system shared
- make VocalSystem Not make more Actions than it needs
- Use some code from ChameleonProjector so we can copy components
- partially ungod method the Transform system
* Cleanup, Moving more things to CopyComp
- TransformBodyEmotes now uses CopyComp (it's a server component so i
need to tell the server to deal with it
- TypingIndicatorComponent also now uses CopyComp
- cleaned up old, now unused "replace" methods in favor of CopyComp
- BodyEmotesSystem now has a publically accessable LoadSounds to deal
with the same problem Screaming had
* WIP
* Devour Windup noise, ForensicsSystem cleanup
* Revert VocalSystem Changes
- Reverted Moving VocalSystem to shared, copy comp acomplishes it
- added component.ScreamActionEntity = null; for copy comp
* cleanup unneeded comments
* revert an accidental line removal
* Remove duplicate SharedHumanoidAppearanceSystem
* Cleanup Typo's and import Forensics components for Dna
* Some more forensics calls
* cleanup use CopyComp for now until CopyComps
* CR cleanup
* Undo some SharedHumanoidAppearanceSystem changes
* Confound these spaces
* Some Copycomp stuff and fixing some PVS override
* use the proper TryCopyComps that are merged
* Change TransformMenu with RadialWithSector
* All sounds done, Fix lack of typing indicator issue
* Updated attributions to include used sound authors
* some ftl typos and mind_role text issue
* DNA, Screaming, appearance, grammar, wagging
- reduced all of the above using ApplyComponentChanges
- Issue still remains with bodyEmotes sticking around in the UI
* Fix UI stuff, partials, entprotoid, good practices
- bunch of partials added
- UI now has a predicted message
- EntProtoID in the admin verb
- RipClothing now uses Entity<ButcherableComponent>
- husking is now optional (off by default) for testing/till we have
hivemind/when we figure out what were doing with devour
- remove TransformGrammarSet
* More CR stuff and documentation
- Make TargetIsProtected less of a meme, with a prototype
set of DamageTypes to check
- Documenation everywhere
- Move DevourEvents into its own file
* Predicted sounds and fix the comp clone list
- Made all start and stop sounds shared
- Split out the rest of the events and UI stuff into subfiles
- Fixed some Clone comp list issues where comments had -'s causing them
to be read incorrectly
* Damage cap check, Identity Shutdown cleanup, cleanup
* Sound stuff (but actually this time)
* Missed documentation
* Missed Documentation and a EntProtoId
* Remove unused dependency
* Remove a nullcheck
* Some dummy minplayers
* CR - Husked now uses a rem/ensure
* Update Actions in the Prototype
* Fixup mindswap handover
- cleanup and handover PVS on mindswap
* Fixup Missing meta from accidental "Take-theirs"
* Add the Armblade to the roundstart-role
* Cleanup, CR (everything but the UI and renames)
* missed a spot
* missed some more whitespace
* Renames
* Primary constructor and a space in these trying times
* User interface stuff for Slime transformation
* popup prediction
* Ling devour no longer makes duplicate identities
- added a key to identities to the original victim
- Add some extra clone settings
* add guard statements to OnClones
* SentOnlyToOwner additions
* fix for sound stoppage error
* Move Organ deleter into soon to be atomized husk
* clone event inventory
* mono sounds
* lower sound volume
* Fix networked sound warning
* Clone comps thing
* review
* attributions
* Fix clobbered changes
* I'm gonna weh out
- whole bunch of CR changes
* fix some very buggy git
* okay its fixed
* address most review points
* fix inventory
* we hate entityuids
* fix test and more cleanup
* move this
* fix more stuff
* fix validation and rootable
* Remove Quickswitch due to some UI quirks
* oops left out some better explanation
* remove dangling LastConsumed component fields
* fix test fail
* try this
* cleanup cloning subscriptions, add movement speed modifier
* fix slime storage
* fix cloning setting inheritance
* Add session information to transform admin logs
* slay the integration test hydra
* dwarf size
* more volume tweaks
* comments
* improve comments and unpredict deletion due to errors when shutting down the server
* fix displancement cloning
---------
Co-authored-by: ScarKy0 <scarky0@onet.eu>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2025-08-06 16:55:49 -03:00
|
|
|
component.StorageInsertSound = state.StorageInsertSound;
|
|
|
|
|
component.StorageRemoveSound = state.StorageRemoveSound;
|
|
|
|
|
component.StorageOpenSound = state.StorageOpenSound;
|
|
|
|
|
component.StorageCloseSound = state.StorageCloseSound;
|
|
|
|
|
component.DefaultStorageOrientation = state.DefaultStorageOrientation;
|
2023-12-04 18:04:39 -05:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
_oldStoredItems.Clear();
|
2023-12-04 18:04:39 -05:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
foreach (var item in component.StoredItems)
|
|
|
|
|
{
|
|
|
|
|
_oldStoredItems.Add(item.Key, item.Value);
|
2025-01-27 21:29:51 +11:00
|
|
|
}
|
2023-12-04 18:04:39 -05:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
component.StoredItems.Clear();
|
2023-12-04 18:04:39 -05:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
foreach (var (nent, location) in state.StoredItems)
|
|
|
|
|
{
|
|
|
|
|
var ent = EnsureEntity<StorageComponent>(nent, uid);
|
|
|
|
|
component.StoredItems[ent] = location;
|
|
|
|
|
}
|
2023-12-04 18:04:39 -05:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
component.SavedLocations.Clear();
|
2023-12-04 18:04:39 -05:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
foreach (var loc in state.SavedLocations)
|
2025-02-05 14:13:06 +01:00
|
|
|
{
|
2025-02-08 17:17:55 +11:00
|
|
|
component.SavedLocations[loc.Key] = new(loc.Value);
|
2023-12-04 18:04:39 -05:00
|
|
|
}
|
2025-02-05 14:13:06 +01:00
|
|
|
|
2025-05-21 16:16:26 +10:00
|
|
|
UpdateOccupied((uid, component));
|
|
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
var uiDirty = !component.StoredItems.SequenceEqual(_oldStoredItems);
|
2023-12-04 18:04:39 -05:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
if (uiDirty && UI.TryGetOpenUi<StorageBoundUserInterface>(uid, StorageComponent.StorageUiKey.Key, out var storageBui))
|
2025-01-27 21:29:51 +11:00
|
|
|
{
|
2025-02-08 17:17:55 +11:00
|
|
|
storageBui.Refresh();
|
|
|
|
|
// Make sure nesting still updated.
|
|
|
|
|
var player = _player.LocalEntity;
|
2025-02-05 14:13:06 +01:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
if (NestedStorage && player != null && ContainerSystem.TryGetContainingContainer((uid, null, null), out var container) &&
|
|
|
|
|
UI.TryGetOpenUi<StorageBoundUserInterface>(container.Owner, StorageComponent.StorageUiKey.Key, out var containerBui))
|
|
|
|
|
{
|
2025-02-17 19:24:34 +11:00
|
|
|
_queuedBuis.Add((containerBui, false));
|
2025-02-08 17:17:55 +11:00
|
|
|
}
|
2025-01-27 21:29:51 +11:00
|
|
|
}
|
|
|
|
|
}
|
2023-12-04 18:04:39 -05:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
public override void UpdateUI(Entity<StorageComponent?> entity)
|
2025-01-27 21:29:51 +11:00
|
|
|
{
|
2025-02-08 17:17:55 +11:00
|
|
|
if (UI.TryGetOpenUi<StorageBoundUserInterface>(entity.Owner, StorageComponent.StorageUiKey.Key, out var sBui))
|
|
|
|
|
{
|
|
|
|
|
sBui.Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-02-05 14:13:06 +01:00
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
protected override void HideStorageWindow(EntityUid uid, EntityUid actor)
|
|
|
|
|
{
|
|
|
|
|
if (UI.TryGetOpenUi<StorageBoundUserInterface>(uid, StorageComponent.StorageUiKey.Key, out var storageBui))
|
|
|
|
|
{
|
2025-02-17 19:24:34 +11:00
|
|
|
_queuedBuis.Add((storageBui, false));
|
2025-02-08 17:17:55 +11:00
|
|
|
}
|
2023-12-04 18:04:39 -05:00
|
|
|
}
|
|
|
|
|
|
2025-02-08 17:17:55 +11:00
|
|
|
protected override void ShowStorageWindow(EntityUid uid, EntityUid actor)
|
2023-12-04 18:04:39 -05:00
|
|
|
{
|
2025-02-08 17:17:55 +11:00
|
|
|
if (UI.TryGetOpenUi<StorageBoundUserInterface>(uid, StorageComponent.StorageUiKey.Key, out var storageBui))
|
|
|
|
|
{
|
2025-02-17 19:24:34 +11:00
|
|
|
_queuedBuis.Add((storageBui, true));
|
2025-02-08 17:17:55 +11:00
|
|
|
}
|
2023-09-11 21:20:46 +10:00
|
|
|
}
|
|
|
|
|
|
2023-09-12 22:34:04 +10:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public override void PlayPickupAnimation(EntityUid uid, EntityCoordinates initialCoordinates, EntityCoordinates finalCoordinates,
|
|
|
|
|
Angle initialRotation, EntityUid? user = null)
|
|
|
|
|
{
|
|
|
|
|
if (!_timing.IsFirstTimePredicted)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
PickupAnimation(uid, initialCoordinates, finalCoordinates, initialRotation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandlePickupAnimation(PickupAnimationEvent msg)
|
|
|
|
|
{
|
|
|
|
|
PickupAnimation(GetEntity(msg.ItemUid), GetCoordinates(msg.InitialPosition), GetCoordinates(msg.FinalPosition), msg.InitialAngle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PickupAnimation(EntityUid item, EntityCoordinates initialCoords, EntityCoordinates finalCoords, Angle initialAngle)
|
|
|
|
|
{
|
|
|
|
|
if (!_timing.IsFirstTimePredicted)
|
|
|
|
|
return;
|
2025-02-08 17:17:55 +11:00
|
|
|
|
2024-07-13 14:25:51 -07:00
|
|
|
if (TransformSystem.InRange(finalCoords, initialCoords, 0.1f) ||
|
2023-09-12 22:34:04 +10:00
|
|
|
!Exists(initialCoords.EntityId) || !Exists(finalCoords.EntityId))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-13 14:05:22 -07:00
|
|
|
var finalMapPos = TransformSystem.ToMapCoordinates(finalCoords).Position;
|
2024-06-02 05:07:41 +01:00
|
|
|
var finalPos = Vector2.Transform(finalMapPos, TransformSystem.GetInvWorldMatrix(initialCoords.EntityId));
|
2023-09-12 22:34:04 +10:00
|
|
|
|
2023-10-14 10:28:06 -07:00
|
|
|
_entityPickupAnimation.AnimateEntityPickup(item, initialCoords, finalPos, initialAngle);
|
2023-09-12 22:34:04 +10:00
|
|
|
}
|
|
|
|
|
|
2022-04-28 06:11:15 -06:00
|
|
|
/// <summary>
|
|
|
|
|
/// Animate the newly stored entities in <paramref name="msg"/> flying towards this storage's position
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
public void HandleAnimatingInsertingEntities(AnimateInsertingEntitiesEvent msg)
|
2022-03-30 16:23:20 -07:00
|
|
|
{
|
2023-09-11 21:20:46 +10:00
|
|
|
TryComp(GetEntity(msg.Storage), out TransformComponent? transformComp);
|
2022-03-30 16:23:20 -07:00
|
|
|
|
2022-04-28 06:11:15 -06:00
|
|
|
for (var i = 0; msg.StoredEntities.Count > i; i++)
|
2022-03-30 16:23:20 -07:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
var entity = GetEntity(msg.StoredEntities[i]);
|
2023-09-11 21:20:46 +10:00
|
|
|
|
2022-04-28 06:11:15 -06:00
|
|
|
var initialPosition = msg.EntityPositions[i];
|
2023-12-04 18:04:39 -05:00
|
|
|
if (Exists(entity) && transformComp != null)
|
2022-04-28 06:11:15 -06:00
|
|
|
{
|
2023-10-14 10:28:06 -07:00
|
|
|
_entityPickupAnimation.AnimateEntityPickup(entity, GetCoordinates(initialPosition), transformComp.LocalPosition, msg.EntityAngles[i]);
|
2022-04-28 06:11:15 -06:00
|
|
|
}
|
2022-03-30 16:23:20 -07:00
|
|
|
}
|
|
|
|
|
}
|
2025-02-17 19:24:34 +11:00
|
|
|
|
|
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
{
|
|
|
|
|
base.Update(frameTime);
|
|
|
|
|
|
|
|
|
|
if (!_timing.IsFirstTimePredicted)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This update loop exists just to synchronize with UISystem and avoid 1-tick delays.
|
|
|
|
|
// If deferred opens / closes ever get removed you can dump this.
|
|
|
|
|
foreach (var (bui, open) in _queuedBuis)
|
|
|
|
|
{
|
|
|
|
|
if (open)
|
|
|
|
|
{
|
|
|
|
|
bui.Show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bui.Hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_queuedBuis.Clear();
|
|
|
|
|
}
|
2022-03-30 16:23:20 -07:00
|
|
|
}
|