AutoCompState + ItemToggle fixes (#23422)
* AutoCompState + ItemToggle fixes Fix a lot of the comp states that are never actually networked and also cleaned up ItemToggle events a bunch. ItemToggle will still need some future work for lights and sounds. * Also catch these
This commit is contained in:
@@ -13,6 +13,7 @@ using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Item.ItemToggle.Components;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Weapons.Melee.Components;
|
||||
@@ -29,6 +30,7 @@ using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Toolshed.Syntax;
|
||||
using ItemToggleMeleeWeaponComponent = Content.Shared.Item.ItemToggle.Components.ItemToggleMeleeWeaponComponent;
|
||||
|
||||
namespace Content.Shared.Weapons.Melee;
|
||||
|
||||
@@ -74,7 +76,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
SubscribeLocalEvent<BonusMeleeDamageComponent, GetHeavyDamageModifierEvent>(OnGetBonusHeavyDamageModifier);
|
||||
SubscribeLocalEvent<BonusMeleeAttackRateComponent, GetMeleeAttackRateEvent>(OnGetBonusMeleeAttackRate);
|
||||
|
||||
SubscribeLocalEvent<ItemToggleMeleeWeaponComponent, ItemToggleMeleeWeaponUpdateEvent>(OnItemToggle);
|
||||
SubscribeLocalEvent<ItemToggleMeleeWeaponComponent, ItemToggledEvent>(OnItemToggle);
|
||||
|
||||
SubscribeAllEvent<HeavyAttackEvent>(OnHeavyAttack);
|
||||
SubscribeAllEvent<LightAttackEvent>(OnLightAttack);
|
||||
@@ -864,7 +866,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
/// <summary>
|
||||
/// Used to update the MeleeWeapon component on item toggle.
|
||||
/// </summary>
|
||||
private void OnItemToggle(EntityUid uid, ItemToggleMeleeWeaponComponent itemToggleMelee, ItemToggleMeleeWeaponUpdateEvent args)
|
||||
private void OnItemToggle(EntityUid uid, ItemToggleMeleeWeaponComponent itemToggleMelee, ItemToggledEvent args)
|
||||
{
|
||||
if (!TryComp(uid, out MeleeWeaponComponent? meleeWeapon))
|
||||
return;
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Shared.Database;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Item.ItemToggle.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
@@ -23,7 +24,7 @@ namespace Content.Shared.Weapons.Reflect;
|
||||
/// <summary>
|
||||
/// This handles reflecting projectiles and hitscan shots.
|
||||
/// </summary>
|
||||
public abstract class SharedReflectSystem : EntitySystem
|
||||
public sealed class ReflectSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly INetManager _netManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
@@ -41,13 +42,14 @@ public abstract class SharedReflectSystem : EntitySystem
|
||||
|
||||
SubscribeLocalEvent<ReflectComponent, ProjectileReflectAttemptEvent>(OnReflectCollide);
|
||||
SubscribeLocalEvent<ReflectComponent, HitScanReflectAttemptEvent>(OnReflectHitscan);
|
||||
SubscribeLocalEvent<ReflectUserComponent, ProjectileReflectAttemptEvent>(OnReflectUserCollide);
|
||||
SubscribeLocalEvent<ReflectUserComponent, HitScanReflectAttemptEvent>(OnReflectUserHitscan);
|
||||
|
||||
SubscribeLocalEvent<ReflectComponent, GotEquippedEvent>(OnReflectEquipped);
|
||||
SubscribeLocalEvent<ReflectComponent, GotUnequippedEvent>(OnReflectUnequipped);
|
||||
SubscribeLocalEvent<ReflectComponent, GotEquippedHandEvent>(OnReflectHandEquipped);
|
||||
SubscribeLocalEvent<ReflectComponent, GotUnequippedHandEvent>(OnReflectHandUnequipped);
|
||||
SubscribeLocalEvent<ReflectComponent, ItemToggledEvent>(OnToggleReflect);
|
||||
|
||||
SubscribeLocalEvent<ReflectUserComponent, ProjectileReflectAttemptEvent>(OnReflectUserCollide);
|
||||
SubscribeLocalEvent<ReflectUserComponent, HitScanReflectAttemptEvent>(OnReflectUserHitscan);
|
||||
}
|
||||
|
||||
private void OnReflectUserHitscan(EntityUid uid, ReflectUserComponent component, ref HitScanReflectAttemptEvent args)
|
||||
@@ -209,6 +211,12 @@ public abstract class SharedReflectSystem : EntitySystem
|
||||
RefreshReflectUser(args.User);
|
||||
}
|
||||
|
||||
private void OnToggleReflect(EntityUid uid, ReflectComponent comp, ref ItemToggledEvent args)
|
||||
{
|
||||
comp.Enabled = args.Activated;
|
||||
Dirty(uid, comp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes whether someone has reflection potential so we can raise directed events on them.
|
||||
/// </summary>
|
||||
Reference in New Issue
Block a user