Skip to content

Commit

Permalink
Revert "Implement field-deltas for melee"
Browse files Browse the repository at this point in the history
This reverts commit 67ed4c3.
  • Loading branch information
sleepyyapril committed Dec 21, 2024
1 parent 9bb4c93 commit c1b272a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Content.Shared.Weapons.Melee;
/// <summary>
/// When given to a mob lets them do unarmed attacks, or when given to an item lets someone wield it to do attacks.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(fieldDeltas: true), AutoGenerateComponentPause]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
public sealed partial class MeleeWeaponComponent : Component
{
// TODO: This is becoming bloated as shit.
Expand Down Expand Up @@ -96,7 +96,7 @@ public sealed partial class MeleeWeaponComponent : Component
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public bool ResistanceBypass = false;

/// <summary>
/// Base damage for this weapon. Can be modified via heavy damage or other means.
/// </summary>
Expand Down
27 changes: 6 additions & 21 deletions Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void OnMeleeShot(EntityUid uid, MeleeWeaponComponent component, ref GunS
if (gun.NextFire > component.NextAttack)
{
component.NextAttack = gun.NextFire;
DirtyField(uid, component, nameof(MeleeWeaponComponent.NextAttack));
Dirty(uid, component);
}
}

Expand All @@ -128,7 +128,7 @@ private void OnMeleeSelected(EntityUid uid, MeleeWeaponComponent component, Hand
return;

component.NextAttack = minimum;
DirtyField(uid, component, nameof(MeleeWeaponComponent.NextAttack));
Dirty(uid, component);
}

private void OnGetBonusMeleeDamage(EntityUid uid, BonusMeleeDamageComponent component, ref GetMeleeDamageEvent args)
Expand Down Expand Up @@ -168,7 +168,7 @@ private void OnStopAttack(StopAttackEvent msg, EntitySessionEventArgs args)
return;

weapon.Attacking = false;
DirtyField(weaponUid, weapon, nameof(MeleeWeaponComponent.Attacking));
Dirty(weaponUid, weapon);
}

private void OnLightAttack(LightAttackEvent msg, EntitySessionEventArgs args)
Expand Down Expand Up @@ -392,7 +392,7 @@ private bool AttemptAttack(EntityUid user, EntityUid weaponUid, MeleeWeaponCompo
swings++;
}

DirtyField(weaponUid, weapon, nameof(MeleeWeaponComponent.NextAttack));
Dirty(weaponUid, weapon);

// Do this AFTER attack so it doesn't spam every tick
var ev = new AttemptMeleeEvent();
Expand Down Expand Up @@ -832,7 +832,6 @@ private void OnItemToggle(EntityUid uid, ItemToggleMeleeWeaponComponent itemTogg
//Setting deactivated damage to the weapon's regular value before changing it.
itemToggleMelee.DeactivatedDamage ??= meleeWeapon.Damage;
meleeWeapon.Damage = itemToggleMelee.ActivatedDamage;
DirtyField(uid, meleeWeapon, nameof(MeleeWeaponComponent.Damage));
}

meleeWeapon.SoundHit = itemToggleMelee.ActivatedSoundOnHit;
Expand All @@ -842,49 +841,35 @@ private void OnItemToggle(EntityUid uid, ItemToggleMeleeWeaponComponent itemTogg
//Setting the deactivated sound on no damage hit to the weapon's regular value before changing it.
itemToggleMelee.DeactivatedSoundOnHitNoDamage ??= meleeWeapon.SoundNoDamage;
meleeWeapon.SoundNoDamage = itemToggleMelee.ActivatedSoundOnHitNoDamage;
DirtyField(uid, meleeWeapon, nameof(MeleeWeaponComponent.SoundNoDamage));
}

if (itemToggleMelee.ActivatedSoundOnSwing != null)
{
//Setting the deactivated sound on no damage hit to the weapon's regular value before changing it.
itemToggleMelee.DeactivatedSoundOnSwing ??= meleeWeapon.SoundSwing;
meleeWeapon.SoundSwing = itemToggleMelee.ActivatedSoundOnSwing;
DirtyField(uid, meleeWeapon, nameof(MeleeWeaponComponent.SoundSwing));
}

if (itemToggleMelee.DeactivatedSecret)
{
meleeWeapon.Hidden = false;
}
}
else
{
if (itemToggleMelee.DeactivatedDamage != null)
{
meleeWeapon.Damage = itemToggleMelee.DeactivatedDamage;
DirtyField(uid, meleeWeapon, nameof(MeleeWeaponComponent.Damage));
}

meleeWeapon.SoundHit = itemToggleMelee.DeactivatedSoundOnHit;
DirtyField(uid, meleeWeapon, nameof(MeleeWeaponComponent.SoundHit));

if (itemToggleMelee.DeactivatedSoundOnHitNoDamage != null)
{
meleeWeapon.SoundNoDamage = itemToggleMelee.DeactivatedSoundOnHitNoDamage;
DirtyField(uid, meleeWeapon, nameof(MeleeWeaponComponent.SoundNoDamage));
}

if (itemToggleMelee.DeactivatedSoundOnSwing != null)
{
meleeWeapon.SoundSwing = itemToggleMelee.DeactivatedSoundOnSwing;
DirtyField(uid, meleeWeapon, nameof(MeleeWeaponComponent.SoundSwing));
}

if (itemToggleMelee.DeactivatedSecret)
{
meleeWeapon.Hidden = true;
}
}

Dirty(uid, meleeWeapon);
}
}

0 comments on commit c1b272a

Please sign in to comment.