Files
tbd-station-14/Content.Server/Gatherable/GatherableSystem.cs
metalgearsloth fb4d980848 Mining tweaks (#18686)
So we have pickaxe, drill, crusher, and PKA (projectiles).
The tier list in terms of mining speed should go:
- PKA
- Crusher
- Pickaxe
- Drill

As a result:
- Nerfed PKA firerate to 0.5 and bumped damage (slight DPS nerf due to meta).
- Crusher bumped to 1 hit per second as PKA is still more common and also to make it better at mining.
- Pickaxe is 1 hit per second and also gets structural (fireaxe should still beat it by a little bit) so it's better to break stuff than crusher but worse in combat.
- Drill is 1.5 hits per second but otherwise weak.
2023-08-05 20:23:38 -05:00

75 lines
2.4 KiB
C#

using Content.Server.Destructible;
using Content.Server.Gatherable.Components;
using Content.Shared.EntityList;
using Content.Shared.Interaction;
using Content.Shared.Tag;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.Gatherable;
public sealed partial class GatherableSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly DestructibleSystem _destructible = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GatherableComponent, ActivateInWorldEvent>(OnActivate);
SubscribeLocalEvent<GatherableComponent, AttackedEvent>(OnAttacked);
InitializeProjectile();
}
private void OnAttacked(EntityUid uid, GatherableComponent component, AttackedEvent args)
{
if (component.ToolWhitelist?.IsValid(args.Used, EntityManager) != true)
return;
Gather(uid, args.User, component);
}
private void OnActivate(EntityUid uid, GatherableComponent component, ActivateInWorldEvent args)
{
Gather(uid, args.User, component);
}
public void Gather(EntityUid gatheredUid, EntityUid? gatherer = null, GatherableComponent? component = null, SoundSpecifier? sound = null)
{
if (!Resolve(gatheredUid, ref component))
return;
// Complete the gathering process
_destructible.DestroyEntity(gatheredUid);
_audio.PlayPvs(sound, gatheredUid);
// Spawn the loot!
if (component.MappedLoot == null)
return;
var pos = Transform(gatheredUid).MapPosition;
foreach (var (tag, table) in component.MappedLoot)
{
if (tag != "All")
{
if (gatherer != null && !_tagSystem.HasTag(gatherer.Value, tag))
continue;
}
var getLoot = _prototypeManager.Index<EntityLootTablePrototype>(table);
var spawnLoot = getLoot.GetSpawns();
var spawnPos = pos.Offset(_random.NextVector2(0.3f));
Spawn(spawnLoot[0], spawnPos);
}
}
}