* PaintableAirlockComponent and AirlockGroupPrototype have been replaced * Slightly redesigned SprayPainterSystem for greater versatility * Added handling of changes to the appearance of doors and storages * PaintableGroup prototypes have been created * Generating tabs with styles in the UI * Fix error with undiscovered layer * Slight improvement * Removed unnecessary property * The category for `PaintableGroup` was allocated to a separate prototype so that the engine itself would check if the category existed * Added canisters, but repainting doesn't work * Added localization to styles * Fix sprite changing * Added the ability to paint canisters * slight ui improvement * Fix yamllinter errors * Fix test * The UI now remembers which tab was open * Fix build (?) * Rename * Charges have been added to the spray painter * Added a charge texture for the spray painter * Now spray painter can paint decals * Increased number of charges * Spawning dummy objects has been replaced by PrototypeManager * added a signature about the painting of the object * fix * Code commenting * Fix upstream * Update Content.Shared/SprayPainter/Components/SprayPainterAmmo.cs Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> * review * Now decals can only be painted if the corresponding tab in the menu is open. * Fixed a bug with pipe and decal tabs not being remembered * Update EntityStorageVisualizerSystem.cs * record * loc * Cleanup * Revert electrified visuals * more cleanup, fix charges, del ammo4 * no empty file, remove meta component * closet exceptions, storage visualizer fixes * enable/disable decal through alt-verb * Fix missed merge conflicts * fix snap offset, button event handlers * simpler order, fix snap loc string * Remove PaintableViz.BaseRSI, no decal item, A-Z * State-respecting UI, BUI updates, FTL fixes * revert DecalPlacerWindow changes * revert unwanted changes, cleanup function order * Limit SprayPainterAmmo write access to AmmoSystem * Remove PaintedSystem * spray paint ammo lathe recipe, youtool listing * category as a list, groups as subtabs * Restore inhand copyright in meta.json * empty spray painter, recipe produces an empty one * allow alpha on spray painter decals * add comments * paintable wall lockers * Restrict painting more objects * Suggested event changes, event cleanup * component comments, fix ammo inhands * uncleanable decals, dirty styles on mapinit * organize paintables, separate emergency/closet grp * fix categories newline at EOF * airlock group whitespace cleanup * realphabetize * Clean up EntityStorageViz merge conflict markers * Apply requested changes * Apply suggestions from sowelipililimute's review Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> * betrayal most foul * Remove members from EntityPaintedEvent * No emerg. group, steelsec to secure, locker/closet * Enable repainting the medical wall locker * comments, no flags on PaintableVisuals * Remove locked variants from closets/wall closets * removable decals * off value consistency * can't paint away those bones * fix precedence * Remove AirlockDepartment, AirlockGroup protos Both unused. * whitelist consistency re: ammo component * add standing emergency closet styles * alphabetize the spray painter listings --------- Co-authored-by: Ertanic <black.ikra.14@gmail.com> Co-authored-by: Эдуард <36124833+Ertanic@users.noreply.github.com> Co-authored-by: pathetic meowmeow <uhhadd@gmail.com>
154 lines
5.5 KiB
C#
154 lines
5.5 KiB
C#
using Content.Shared.Doors.Components;
|
|
using Content.Shared.Doors.Systems;
|
|
using Content.Shared.SprayPainter.Prototypes;
|
|
using Robust.Client.Animations;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Doors;
|
|
|
|
public sealed class DoorSystem : SharedDoorSystem
|
|
{
|
|
[Dependency] private readonly AnimationPlayerSystem _animationSystem = default!;
|
|
[Dependency] private readonly IComponentFactory _componentFactory = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly SpriteSystem _sprite = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<DoorComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
|
}
|
|
|
|
protected override void OnComponentInit(Entity<DoorComponent> ent, ref ComponentInit args)
|
|
{
|
|
var comp = ent.Comp;
|
|
comp.OpenSpriteStates = new List<(DoorVisualLayers, string)>(2);
|
|
comp.ClosedSpriteStates = new List<(DoorVisualLayers, string)>(2);
|
|
|
|
comp.OpenSpriteStates.Add((DoorVisualLayers.Base, comp.OpenSpriteState));
|
|
comp.ClosedSpriteStates.Add((DoorVisualLayers.Base, comp.ClosedSpriteState));
|
|
|
|
comp.OpeningAnimation = new Animation
|
|
{
|
|
Length = TimeSpan.FromSeconds(comp.OpeningAnimationTime),
|
|
AnimationTracks =
|
|
{
|
|
new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = DoorVisualLayers.Base,
|
|
KeyFrames =
|
|
{
|
|
new AnimationTrackSpriteFlick.KeyFrame(comp.OpeningSpriteState, 0f),
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
comp.ClosingAnimation = new Animation
|
|
{
|
|
Length = TimeSpan.FromSeconds(comp.ClosingAnimationTime),
|
|
AnimationTracks =
|
|
{
|
|
new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = DoorVisualLayers.Base,
|
|
KeyFrames =
|
|
{
|
|
new AnimationTrackSpriteFlick.KeyFrame(comp.ClosingSpriteState, 0f),
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
comp.EmaggingAnimation = new Animation
|
|
{
|
|
Length = TimeSpan.FromSeconds(comp.EmaggingAnimationTime),
|
|
AnimationTracks =
|
|
{
|
|
new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = DoorVisualLayers.BaseUnlit,
|
|
KeyFrames =
|
|
{
|
|
new AnimationTrackSpriteFlick.KeyFrame(comp.EmaggingSpriteState, 0f),
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
private void OnAppearanceChange(Entity<DoorComponent> entity, ref AppearanceChangeEvent args)
|
|
{
|
|
if (args.Sprite == null)
|
|
return;
|
|
|
|
if (!AppearanceSystem.TryGetData<DoorState>(entity, DoorVisuals.State, out var state, args.Component))
|
|
state = DoorState.Closed;
|
|
|
|
if (AppearanceSystem.TryGetData<string>(entity, PaintableVisuals.Prototype, out var prototype, args.Component))
|
|
UpdateSpriteLayers((entity.Owner, args.Sprite), prototype);
|
|
|
|
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.AnimationKey))
|
|
_animationSystem.Stop(entity.Owner, DoorComponent.AnimationKey);
|
|
|
|
UpdateAppearanceForDoorState(entity, args.Sprite, state);
|
|
}
|
|
|
|
private void UpdateAppearanceForDoorState(Entity<DoorComponent> entity, SpriteComponent sprite, DoorState state)
|
|
{
|
|
_sprite.SetDrawDepth((entity.Owner, sprite), state is DoorState.Open ? entity.Comp.OpenDrawDepth : entity.Comp.ClosedDrawDepth);
|
|
|
|
switch (state)
|
|
{
|
|
case DoorState.Open:
|
|
foreach (var (layer, layerState) in entity.Comp.OpenSpriteStates)
|
|
{
|
|
_sprite.LayerSetRsiState((entity.Owner, sprite), layer, layerState);
|
|
}
|
|
|
|
return;
|
|
case DoorState.Closed:
|
|
foreach (var (layer, layerState) in entity.Comp.ClosedSpriteStates)
|
|
{
|
|
_sprite.LayerSetRsiState((entity.Owner, sprite), layer, layerState);
|
|
}
|
|
|
|
return;
|
|
case DoorState.Opening:
|
|
if (entity.Comp.OpeningAnimationTime == 0.0)
|
|
return;
|
|
|
|
_animationSystem.Play(entity, (Animation)entity.Comp.OpeningAnimation, DoorComponent.AnimationKey);
|
|
|
|
return;
|
|
case DoorState.Closing:
|
|
if (entity.Comp.ClosingAnimationTime == 0.0 || entity.Comp.CurrentlyCrushing.Count != 0)
|
|
return;
|
|
|
|
_animationSystem.Play(entity, (Animation)entity.Comp.ClosingAnimation, DoorComponent.AnimationKey);
|
|
|
|
return;
|
|
case DoorState.Denying:
|
|
_animationSystem.Play(entity, (Animation)entity.Comp.DenyingAnimation, DoorComponent.AnimationKey);
|
|
|
|
return;
|
|
case DoorState.Emagging:
|
|
_animationSystem.Play(entity, (Animation)entity.Comp.EmaggingAnimation, DoorComponent.AnimationKey);
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void UpdateSpriteLayers(Entity<SpriteComponent> sprite, string targetProto)
|
|
{
|
|
if (!_prototypeManager.TryIndex(targetProto, out var target))
|
|
return;
|
|
|
|
if (!target.TryGetComponent(out SpriteComponent? targetSprite, _componentFactory))
|
|
return;
|
|
|
|
_sprite.SetBaseRsi(sprite.AsNullable(), targetSprite.BaseRSI);
|
|
}
|
|
}
|