Skip to content

Commit

Permalink
Закинул телескопичку
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 committed Jul 3, 2024
1 parent ea86b19 commit 945c850
Show file tree
Hide file tree
Showing 27 changed files with 377 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Content.Shared.Damage.Components;
using Content.Shared.Damage.Events;
using Content.Shared.Examine;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.ADT.SwitchableWeapon;
using Content.Shared.Toggleable;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Audio.Systems;

namespace Content.Server.ADT.SwitchableWeapon;

public sealed class SwitchableWeaponSystem : EntitySystem
{
[Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SwitchableWeaponComponent, UseInHandEvent>(Toggle);
SubscribeLocalEvent<SwitchableWeaponComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<SwitchableWeaponComponent, StaminaDamageOnHitAttemptEvent>(OnStaminaHitAttempt);
SubscribeLocalEvent<SwitchableWeaponComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
SubscribeLocalEvent<SwitchableWeaponComponent, ComponentAdd>(OnComponentAdded);
}

private void OnComponentAdded(EntityUid uid, SwitchableWeaponComponent component, ComponentAdd args)
{
UpdateState(uid, component);
}

//Non-stamina damage
private void OnGetMeleeDamage(EntityUid uid, SwitchableWeaponComponent component, ref GetMeleeDamageEvent args)
{
args.Damage = component.IsOpen ? component.DamageOpen : component.DamageFolded;
}

private void OnStaminaHitAttempt(EntityUid uid, SwitchableWeaponComponent component, ref StaminaDamageOnHitAttemptEvent args)
{
if (!component.IsOpen)
return;

//args.HitSoundOverride = component.BonkSound;
}

private void OnExamined(EntityUid uid, SwitchableWeaponComponent comp, ExaminedEvent args)
{
var msg = comp.IsOpen
? Loc.GetString("comp-switchable-examined-on")
: Loc.GetString("comp-switchable-examined-off");
args.PushMarkup(msg);
}

private void UpdateState(EntityUid uid, SwitchableWeaponComponent comp)
{
if (TryComp<ItemComponent>(comp.Owner, out var item))
{
_item.SetSize(item.Owner, comp.IsOpen ? comp.SizeOpened : comp.SizeClosed, item);
_item.SetHeldPrefix(comp.Owner, comp.IsOpen ? "on" : "off", false, item);
}

if (TryComp<AppearanceComponent>(comp.Owner, out var appearance))
_appearance.SetData(comp.Owner, ToggleVisuals.Toggled, comp.IsOpen, appearance);

// Change stamina damage according to state
if (TryComp<StaminaDamageOnHitComponent>(uid, out var stamComp))
{
stamComp.Damage = comp.IsOpen ? comp.StaminaDamageOpen : comp.StaminaDamageFolded;
}
}

private void Toggle(EntityUid uid, SwitchableWeaponComponent comp, UseInHandEvent args)
{
comp.IsOpen = !comp.IsOpen;
UpdateState(uid, comp);

var soundToPlay = comp.IsOpen ? comp.OpenSound : comp.CloseSound;
_audio.PlayPvs(soundToPlay, args.User);
}
}
51 changes: 51 additions & 0 deletions Content.Shared/ADT/SwitchableWeapon/SwitchableWeaponComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

using Content.Shared.Damage;
using Content.Shared.Item;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;

namespace Content.Shared.ADT.SwitchableWeapon;

[RegisterComponent]
public sealed partial class SwitchableWeaponComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)][DataField("damageFolded")]
public DamageSpecifier DamageFolded = new(){
DamageDict = new()
{
{ "Blunt", 0.0f },
}
};

[ViewVariables(VVAccess.ReadWrite)][DataField("damageOpen")]
public DamageSpecifier DamageOpen = new(){
DamageDict = new()
{
{ "Blunt", 4.0f },
}
};

[ViewVariables(VVAccess.ReadWrite)][DataField("staminaDamageFolded")]
public float StaminaDamageFolded = 0;

[ViewVariables(VVAccess.ReadWrite)][DataField("staminaDamageOpen")]
public float StaminaDamageOpen = 28;

[ViewVariables(VVAccess.ReadWrite)][DataField("isOpen")]
public bool IsOpen = false;

[ViewVariables(VVAccess.ReadWrite)][DataField("openSound")]
public SoundSpecifier? OpenSound;

[ViewVariables(VVAccess.ReadWrite)][DataField("closeSound")]
public SoundSpecifier? CloseSound;

[ViewVariables(VVAccess.ReadWrite)][DataField("bonkSound")]
public SoundSpecifier? BonkSound;

[ViewVariables(VVAccess.ReadWrite)][DataField("sizeOpened")]
public ProtoId<ItemSizePrototype> SizeOpened = "Normal";

[ViewVariables(VVAccess.ReadWrite)][DataField("sizeClosed")]
public ProtoId<ItemSizePrototype> SizeClosed = "Normal";
}
Binary file added Resources/Audio/ADT/close_telescopichka.ogg
Binary file not shown.
Binary file added Resources/Audio/ADT/open_telescopichka.ogg
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ent-ADTtelescopicBaton = Телескопическая дубинка
.desc = "Большая, опасная и выдвижная дубинка. Может храниться в карманах в сложенном состоянии."
.suffix = { "" }
ent-ADTtelescopicBatonBob = Телескопическая дубинка Боба
.desc = "Эксклюзивная телескопическая дубинка, полностью из золота."
.suffix = { "" }
ent-ADTtelescopicBatonKon = Телескопическая дубинка Йохана
.desc = "Непонятно, кровь это или цвет дубинки.."
.suffix = { "" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
- type: entity
name: TelescopicBaton
parent: BaseItem
id: ADTtelescopicBaton
description: Big, dangerous telescopic baton. Can be stored in pockets when turned off.
components:
- type: Sprite
sprite: ADT/Objects/Weapons/Melee/telescopic_baton.rsi
layers:
- state: telescope_off
map: [ "enum.ToggleVisuals.Layer" ]
- type: SwitchableWeapon
openSound: "/Audio/ADT/open_telescopichka.ogg"
closeSound: "/Audio/ADT/close_telescopichka.ogg"
#bonkSound: "/Audio/ADT/bonk_dubinka.ogg"
damageOpen:
types:
Blunt: 2.4
damageFolded:
types:
Blunt: 0
staminaDamageFolded: 0
staminaDamageOpen: 35
sizeOpened: Normal
sizeClosed: Small
- type: StaminaDamageOnHit
damage: 0
- type: MeleeWeapon
damage:
types:
Blunt: 2.4
- type: Item
size: Small
sprite: ADT/Objects/Weapons/Melee/telescopic_baton.rsi
- type: UseDelay
delay: 1.0
- type: DisarmMalus
malus: 0
- type: Appearance
- type: GenericVisualizer
visuals:
enum.ToggleVisuals.Toggled:
enum.ToggleVisuals.Layer:
True: {state: telescope_on}
False: {state: telescope_off}

- type: entity
name: TelescopicBatonBob
parent: ADTtelescopicBaton
id: ADTtelescopicBatonBob
description: Big, dangerous telescopic baton. Can be stored in pockets when turned off.
components:
- type: Sprite
sprite: ADT/Objects/Weapons/Melee/telescopic_baton_bob.rsi
layers:
- state: telescope_off
map: [ "enum.ToggleVisuals.Layer" ]
- type: SwitchableWeapon
openSound: "/Audio/ADT/open_telescopichka.ogg"
closeSound: "/Audio/ADT/close_telescopichka.ogg"
#bonkSound: "/Audio/ADT/bonk_dubinka.ogg"
damageOpen:
types:
Blunt: 2.4
damageFolded:
types:
Blunt: 0
staminaDamageFolded: 0
staminaDamageOpen: 35
- type: StaminaDamageOnHit
damage: 0
- type: MeleeWeapon
damage:
types:
Blunt: 2.4
- type: Item
size: Small
sprite: ADT/Objects/Weapons/Melee/telescopic_baton_bob.rsi
- type: UseDelay
delay: 1.0
- type: DisarmMalus
malus: 0
- type: Appearance
- type: GenericVisualizer
visuals:
enum.ToggleVisuals.Toggled:
enum.ToggleVisuals.Layer:
True: {state: telescope_on}
False: {state: telescope_off}



- type: entity
name: TelescopicBatonKon
parent: ADTtelescopicBaton
id: ADTtelescopicBatonKon
description: Big, dangerous telescopic baton. Can be stored in pockets when turned off.
components:
- type: Sprite
sprite: ADT/Objects/Weapons/Melee/telescopic_baton_kon.rsi
layers:
- state: telescope_off
map: [ "enum.ToggleVisuals.Layer" ]
- type: SwitchableWeapon
openSound: "/Audio/ADT/open_telescopichka.ogg"
closeSound: "/Audio/ADT/close_telescopichka.ogg"
#bonkSound: "/Audio/ADT/bonk_dubinka.ogg"
damageOpen:
types:
Blunt: 2.4
damageFolded:
types:
Blunt: 0
staminaDamageFolded: 0
staminaDamageOpen: 35
- type: StaminaDamageOnHit
damage: 0
- type: MeleeWeapon
damage:
types:
Blunt: 2.4
- type: Item
size: Small
sprite: ADT/Objects/Weapons/Melee/telescopic_baton_kon.rsi
- type: UseDelay
delay: 1.0
- type: DisarmMalus
malus: 0
- type: Appearance
- type: GenericVisualizer
visuals:
enum.ToggleVisuals.Toggled:
enum.ToggleVisuals.Layer:
True: {state: telescope_on}
False: {state: telescope_off}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": 1,
"license": "CC-BY-3.0",
"copyright": "Sprited by mixnikita",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "telescope_on"
},
{
"name": "telescope_off"
},
{
"name": "off-inhand-left",
"directions": 4
},
{
"name": "off-inhand-right",
"directions": 4
},
{
"name": "on-inhand-left",
"directions": 4
},
{
"name": "on-inhand-right",
"directions": 4
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": 1,
"license": "CC-BY-3.0",
"copyright": "Sprited by mixnikita",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "telescope_on"
},
{
"name": "telescope_off"
},
{
"name": "off-inhand-left",
"directions": 4
},
{
"name": "off-inhand-right",
"directions": 4
},
{
"name": "on-inhand-left",
"directions": 4
},
{
"name": "on-inhand-right",
"directions": 4
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": 1,
"license": "CC-BY-3.0",
"copyright": "Sprited by mixnikita",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "telescope_on"
},
{
"name": "telescope_off"
},
{
"name": "off-inhand-left",
"directions": 4
},
{
"name": "off-inhand-right",
"directions": 4
},
{
"name": "on-inhand-left",
"directions": 4
},
{
"name": "on-inhand-right",
"directions": 4
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 945c850

Please sign in to comment.