forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* deleted old comp and sys * new comp * rework done * 1 more tip * + comment * kirus fix * kirus fix 2 * Update DisarmOnAttackComponent.cs --------- Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com>
- Loading branch information
1 parent
9e5ae30
commit a5b1a7b
Showing
4 changed files
with
62 additions
and
68 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Content.Shared/SS220/Weapons/Melee/Components/DisarmOnAttackComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.SS220.Weapons.Melee.Components; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class DisarmOnAttackComponent : Component | ||
{ | ||
//Should be between 0 and 1 | ||
[DataField(required: true)] | ||
public float Chance = 0; | ||
|
||
[DataField] | ||
public float HeavyAttackChance = 0; | ||
} |
16 changes: 0 additions & 16 deletions
16
...20/Weapons/Melee/KnockingWeaponOutOfHands/Components/KnockingWeaponOutOfHandsComponent.cs
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
...ed/SS220/Weapons/Melee/KnockingWeaponOutOfHands/Systems/KnockingWeaponOutOfHandsSystem.cs
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
Content.Shared/SS220/Weapons/Melee/Systems/DisarmOnAttackSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using Content.Shared.SS220.Weapons.Melee.Components; | ||
using Content.Shared.Hands.EntitySystems; | ||
using Content.Shared.Inventory; | ||
using Content.Shared.Weapons.Melee.Events; | ||
using Content.Shared.CombatMode; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Shared.SS220.Weapons.Melee.Systems; | ||
|
||
public sealed class SharedDisarmOnAttackSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly InventorySystem _inventory = default!; | ||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<DisarmOnAttackComponent, WeaponAttackEvent>(OnAttackEvent); | ||
} | ||
|
||
private void OnAttackEvent(Entity<DisarmOnAttackComponent> ent, ref WeaponAttackEvent args) | ||
{ | ||
bool chance = false; ; | ||
|
||
switch (args.Type) | ||
{ | ||
case AttackType.HEAVY: | ||
chance = _random.Prob(ent.Comp.HeavyAttackChance); | ||
break; | ||
|
||
case AttackType.LIGHT: | ||
chance = _random.Prob(ent.Comp.Chance); | ||
break; | ||
} | ||
|
||
if (!chance) | ||
return; | ||
|
||
var ev = new DisarmedEvent { Target = args.Target, Source = args.User }; | ||
RaiseLocalEvent(args.Target, ev); | ||
} | ||
} |