remove footprints (#670)

This commit is contained in:
Ed
2024-12-13 17:33:42 +03:00
committed by GitHub
parent e1f67be2a8
commit c9d2b8fb2b
33 changed files with 3 additions and 351 deletions

View File

@@ -1,178 +0,0 @@
using System.Numerics;
using Content.Server._CP14.Footprints.Components;
using Content.Server.Decals;
using Content.Shared._CP14.Decals;
using Content.Shared.DoAfter;
using Content.Shared.Fluids;
using Content.Shared.Fluids.Components;
using Content.Shared.Interaction;
using Content.Shared.Inventory.Events;
using Content.Shared.Maps;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.Footprints;
public sealed class CP14FootprintsSystem : EntitySystem
{
[Dependency] private readonly DecalSystem _decal = default!;
[Dependency] private readonly SharedMapSystem _maps = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CP14FootprintTrailerComponent, MoveEvent>(OnTrailerMove);
SubscribeLocalEvent<CP14FootprintTrailerComponent, StartCollideEvent>(OnTrailerCollide);
SubscribeLocalEvent<CP14FootprintHolderComponent, GotEquippedEvent>(OnHolderEquipped);
SubscribeLocalEvent<CP14FootprintHolderComponent, GotUnequippedEvent>(OnHolderUnequipped);
SubscribeLocalEvent<CP14DecalCleanerComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<CP14DecalCleanerComponent, CP14DecalCleanerDoAfterEvent>(OnCleanDoAfter);
}
private void OnCleanDoAfter(Entity<CP14DecalCleanerComponent> ent, ref CP14DecalCleanerDoAfterEvent args)
{
if (args.Cancelled || args.Handled)
return;
var gridUid = Transform(ent).GridUid;
if (gridUid is null)
return;
if (!TryComp<MapGridComponent>(gridUid, out var map))
return;
var coord = EntityManager.GetCoordinates(args.ClickLocation);
_audio.PlayPvs(ent.Comp.Sound, coord);
SpawnAtPosition(ent.Comp.SpawnEffect, coord);
var oldDecals = _decal.GetDecalsInRange(gridUid.Value, args.ClickLocation.Position, ent.Comp.Range);
foreach (var (id, decal) in oldDecals)
{
if (decal.Cleanable)
_decal.RemoveDecal(gridUid.Value, id);
}
args.Handled = true;
}
private void OnAfterInteract(Entity<CP14DecalCleanerComponent> ent, ref AfterInteractEvent args)
{
if (!args.CanReach && !args.Handled)
return;
var doAfter = new DoAfterArgs(EntityManager,
args.User,
ent.Comp.Delay,
new CP14DecalCleanerDoAfterEvent(EntityManager.GetNetCoordinates(args.ClickLocation)),
ent)
{
BreakOnMove = true,
BreakOnDamage = true,
NeedHand = true,
};
_doAfter.TryStartDoAfter(doAfter);
args.Handled = true;
}
private void OnHolderUnequipped(Entity<CP14FootprintHolderComponent> ent, ref GotUnequippedEvent args)
{
if (!TryComp<Components.CP14FootprintTrailerComponent>(args.Equipee, out var trailer))
return;
trailer.holder = null;
if (TryComp<CP14FootprintHolderComponent>(args.Equipee, out var selfHolder))
{
trailer.holder = selfHolder;
}
}
private void OnHolderEquipped(Entity<CP14FootprintHolderComponent> ent, ref GotEquippedEvent args)
{
if (!TryComp<Components.CP14FootprintTrailerComponent>(args.Equipee, out var trailer))
return;
trailer.holder = ent.Comp;
}
private void OnTrailerCollide(Entity<Components.CP14FootprintTrailerComponent> ent, ref StartCollideEvent args)
{
if (ent.Comp.holder is null)
return;
var footprint = ent.Comp.holder;
if (!TryComp<PuddleComponent>(args.OtherEntity, out var puddle))
return;
if (puddle.Solution is null)
return;
var sol = puddle.Solution;
var splittedSol = sol.Value.Comp.Solution.SplitSolutionWithout(footprint.PickSolution, SharedPuddleSystem.EvaporationReagents);
if (splittedSol.Volume > 0)
UpdateFootprint(footprint, splittedSol.GetColor(_proto));
}
private void UpdateFootprint(CP14FootprintHolderComponent comp, Color color)
{
comp.DecalColor = color;
comp.Intensity = 1f;
}
private void OnTrailerMove(Entity<Components.CP14FootprintTrailerComponent> ent, ref MoveEvent args)
{
//Temporaly disabled
return;
if (ent.Comp.holder is null)
return;
var footprint = ent.Comp.holder;
var distance = Vector2.Distance(args.OldPosition.Position, args.NewPosition.Position);
footprint.DistanceTraveled += distance;
if (footprint.DistanceTraveled < footprint.DecalDistance)
return;
footprint.DistanceTraveled = 0f;
var xform = Transform(ent);
if (!TryComp<MapGridComponent>(xform.GridUid, out var mapGrid))
return;
var tileRef = _maps.GetTileRef(xform.GridUid.Value, mapGrid, xform.Coordinates);
var tileDef = (ContentTileDefinition)_tileDefManager[tileRef.Tile.TypeId];
if (tileDef.Weather && tileDef.Color is not null)
{
UpdateFootprint(footprint, tileDef.Color.Value);
return;
}
if (footprint.Intensity <= 0)
return;
_decal.TryAddDecal(footprint.DecalProto,
xform.Coordinates.Offset(new Vector2(-0.5f, -0.5f)),
out var decal,
footprint.DecalColor.WithAlpha(footprint.Intensity),
xform.LocalRotation,
cleanable: true);
footprint.Intensity = MathF.Max(0, footprint.Intensity - footprint.DistanceIntensityCost);
}
}

View File

@@ -1,26 +0,0 @@
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.Footprints.Components;
/// <summary>
/// allows you to remove cleanable decals from tiles with a short delay.
/// </summary>
[RegisterComponent, Access(typeof(CP14FootprintsSystem))]
public sealed partial class CP14DecalCleanerComponent : Component
{
[DataField]
public SoundSpecifier Sound = new SoundCollectionSpecifier("CP14Broom")
{
Params = AudioParams.Default.WithVariation(0.2f),
};
[DataField]
public EntProtoId? SpawnEffect = "CP14DustEffect";
[DataField]
public float Range = 1.2f;
[DataField]
public TimeSpan Delay = TimeSpan.FromSeconds(0.75f);
}

View File

@@ -1,33 +0,0 @@
using Content.Shared.Decals;
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.Footprints.Components;
/// <summary>
/// stores the type of footprints and their settings.
/// </summary>
[RegisterComponent, Access(typeof(CP14FootprintsSystem))]
public sealed partial class CP14FootprintHolderComponent : Component
{
[DataField]
public ProtoId<DecalPrototype> DecalProto = "CP14FootprintsBoots";
[DataField]
public float DecalDistance = 1f;
[DataField]
public float DistanceTraveled = 0f;
[DataField]
public Color DecalColor = Color.White;
[DataField]
public float Intensity = 0f;
[DataField]
public FixedPoint2 PickSolution = 1f;
[DataField]
public float DistanceIntensityCost = 0.2f;
}

View File

@@ -1,14 +0,0 @@
namespace Content.Server._CP14.Footprints.Components;
/// <summary>
/// allows an entity to leave footprints on the tiles
/// </summary>
[RegisterComponent, Access(typeof(CP14FootprintsSystem))]
public sealed partial class CP14FootprintTrailerComponent : Component
{
/// <summary>
/// Source and type of footprint
/// </summary>
[DataField]
public CP14FootprintHolderComponent? holder = null;
}

View File

@@ -130,12 +130,6 @@ namespace Content.Shared.Maps
[DataField]
public ProtoId<ContentTileDefinition>? BurnedTile { get; private set; } = null;
/// <summary>
/// CP14 - color for footprints
/// </summary>
[DataField]
public Color? Color;
/// <summary>
/// CP14 - auto removing spilled reagents from tile
/// </summary>

View File

@@ -53,11 +53,6 @@
copyright: 'by deleted_user_7146007 of Freesound.org. Cropped and mixed from stereo to mono.'
source: "https://freesound.org/people/deleted_user_7146007/sounds/383725/"
- files: ["broom1.ogg", "broom2.ogg", "broom3.ogg"]
license: "CC-BY-4.0"
copyright: 'by F.M.Audio of Freesound.org. Cropped by TheShuEd.'
source: "https://freesound.org/people/F.M.Audio/sounds/552056/"
- files: ["book1.ogg"]
license: "CC-BY-4.0"
copyright: 'by flag2 of Freesound.org. edit to Mono by TheShuEd.'

View File

@@ -1,13 +0,0 @@
- type: decal
id: CP14Footprints
showMenu: true
sprite:
sprite: _CP14/Decals/footprints.rsi
state: footprint
- type: decal
id: CP14FootprintsBoots
showMenu: true
sprite:
sprite: _CP14/Decals/footprints.rsi
state: boots

View File

@@ -13,7 +13,6 @@
state: icon
- type: Item
size: Normal
- type: CP14FootprintHolder
- type: entity
parent: CP14ClothingShoesBase

View File

@@ -221,9 +221,6 @@
- type: CP14MagicUnsafeSleep
- type: CP14MagicAttuningMind
autoCopyToMind: true
- type: CP14FootprintHolder
decalProto: CP14Footprints
- type: CP14FootprintTrailer
- type: CP14DemiplaneStabilizer
requireAlive: true
- type: CanEnterCryostorage

View File

@@ -33,31 +33,4 @@
- type: SolutionContainerManager
solutions:
absorbed:
maxVol: 50
- type: entity
id: CP14BaseBroom
parent:
- BaseItem
- CP14BaseWeaponDestructible
name: wooden broom
description: Sweeps up dried footprints and other stains from the floor
components:
- type: Item
size: Normal
storedRotation: 0
shape:
- 0,0,0,2
sprite: _CP14/Objects/Tools/broom.rsi
- type: Sprite
sprite: _CP14/Objects/Tools/broom.rsi
state: icon
- type: MeleeWeapon
wideAnimationRotation: 10
damage:
types:
Blunt: 5
soundHit:
collection: MetalThud
- type: CP14DecalCleaner
delay: 0.75
maxVol: 50

View File

@@ -34,16 +34,6 @@
CP14Cloth: 1
result: CP14BaseMop
- type: CP14Recipe
id: CP14BaseBroom
tag: CP14RecipeWorkbench
craftTime: 3
entities:
CP14Wheat: 2
stacks:
CP14WoodenPlanks: 2
result: CP14BaseBroom
- type: CP14Recipe
id: CP14BaseBattleStaff
tag: CP14RecipeWorkbench

View File

@@ -29,13 +29,6 @@
- /Audio/_CP14/Items/sawing3.ogg
- /Audio/_CP14/Items/sawing4.ogg
- /Audio/_CP14/Items/sawing5.ogg
- type: soundCollection
id: CP14Broom
files:
- /Audio/_CP14/Items/broom1.ogg
- /Audio/_CP14/Items/broom2.ogg
- /Audio/_CP14/Items/broom3.ogg
- type: soundCollection
id: CP14Parry

View File

@@ -37,5 +37,4 @@
collection: FootstepAsteroid
heatCapacity: 10000
weather: true
color: "#38373b"
indestructible: true

View File

@@ -40,7 +40,6 @@
heatCapacity: 10000
weather: true
suckReagents: true
color: "#452f27"
- type: tile
editorHidden: false
@@ -73,7 +72,6 @@
heatCapacity: 10000
weather: true
suckReagents: true
color: "#dccd9e"
- type: tile
id: CP14FloorGrass
@@ -107,7 +105,6 @@
heatCapacity: 10000
weather: true
suckReagents: true
color: "#4a613a"
- type: tile
id: CP14FloorGrassLight
@@ -141,7 +138,6 @@
heatCapacity: 10000
weather: true
suckReagents: true
color: "#4a613a"
- type: tile
id: CP14FloorGrassTall
@@ -175,7 +171,6 @@
heatCapacity: 10000
weather: true
suckReagents: true
color: "#4a613a"
- type: tile
id: CP14FloorSnowDeepDeep

View File

@@ -1281,7 +1281,6 @@
collection: FootstepWood
heatCapacity: 10000
weather: true
color: "#0d0906"
- type: tile #Big
editorHidden: false
@@ -1305,7 +1304,6 @@
collection: FootstepWood
heatCapacity: 10000
weather: true
color: "#0d0906"
- type: tile #Cruci
editorHidden: false
@@ -1329,7 +1327,6 @@
collection: FootstepWood
heatCapacity: 10000
weather: true
color: "#0d0906"
- type: tile #Stairways
editorHidden: false
@@ -1353,6 +1350,5 @@
collection: FootstepWood
heatCapacity: 10000
weather: true
color: "#0d0906"
### /BURNED

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

View File

@@ -1,17 +0,0 @@
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"license": "CLA",
"copyright": "Created by TheShuEd",
"states": [
{
"name": "boots"
},
{
"name": "footprint"
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 696 B

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 B

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 884 B

After

Width:  |  Height:  |  Size: 850 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 B

After

Width:  |  Height:  |  Size: 906 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1015 B

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -202,6 +202,8 @@ CP14FloraTreeLarge06: CP14FloraTreeGreenLarge
CP14DungeonEntranceAutoLink: CP14LaddersDownStoneAutoLink
CP14DungeonExitAutoLink: CP14LaddersUpStoneAutoLink
CP14BaseBroom: null
# <---> CrystallEdge migration zone end