-
Notifications
You must be signed in to change notification settings - Fork 244
Расширение механики луков и добавление луков для сб #2474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
4dc2df2
ea026e9
56ded2e
5ee9f80
297776b
c5d6110
ac0429a
87158f4
7692786
b973633
5be421b
023c5c7
92647dd
b190899
4f6c9a2
5f26340
7664d53
c455da7
5bfcce1
89b1b40
fbdb804
7a94e9a
52f5fbf
2ea3ce6
264df20
75fc88e
31e04dc
e91e100
975be00
b5a356c
a3872ed
cf76abb
4c9e9c3
9829842
a4f2ba0
6978660
1952d7a
d468d8a
bebc614
1eb9f9c
e6a8000
0ae4173
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using Content.Shared.ADT.BowsSystem.Components; | ||
| using Content.Shared.Weapons.Ranged.Events; | ||
| using Content.Shared.Weapons.Ranged.Systems; | ||
|
|
||
| namespace Content.Server.ADT.BowsSystem; | ||
|
|
||
| public sealed partial class BowsSystem : EntitySystem | ||
| { | ||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<ExpendedBowsComponent, ShotAttemptedEvent>(OnShootAttemp); | ||
| } | ||
|
|
||
| public void OnShootAttemp(Entity<ExpendedBowsComponent> bow,ref ShotAttemptedEvent args) | ||
| { | ||
| if(bow.Comp.StepOfTension==0) | ||
| args.Cancel(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| using Robust.Shared.GameStates; | ||
|
|
||
| namespace Content.Shared.ADT.BowsSystem.Components; | ||
| [RegisterComponent, NetworkedComponent] | ||
| public sealed partial class ExpendedBowsComponent : Component | ||
| { | ||
| [DataField, ViewVariables(VVAccess.ReadWrite)] | ||
| public TimeSpan coldownStart = TimeSpan.Zero; | ||
|
|
||
| [DataField, ViewVariables(VVAccess.ReadWrite)] | ||
| public TimeSpan coldown = TimeSpan.FromSeconds(7f); | ||
|
|
||
| [DataField, ViewVariables(VVAccess.ReadWrite)] | ||
| public int StepOfTension=0; | ||
Firemixx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [DataField, ViewVariables(VVAccess.ReadWrite)] | ||
| public string ItemSlot="projectiles"; | ||
Firemixx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| [DataField] | ||
| public Dictionary<int, string> TensionAndLoc = new Dictionary<int, string> | ||
| { | ||
| {0, "popup-bow-use-null"}, | ||
| {1, "popup-bow-use-light"}, | ||
| {2, "popup-bow-use-medium"}, | ||
| {3, "popup-bow-use-hard"}, | ||
| }; | ||
|
|
||
| [DataField] | ||
| public Dictionary<int, float> TensionAndModieferSpeed = new Dictionary<int, float> | ||
| { | ||
| {0, 0.5f}, | ||
| {1, 1f}, | ||
| {2, 1.4f}, | ||
| {3, 1.7f}, | ||
| }; | ||
|
|
||
| public string DamageToModidiering = "Piercing"; | ||
| public int MaxTension = 3; | ||
| public int MinTension = 0; | ||
Firemixx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| using Content.Shared.ADT.BowsSystem.Components; | ||
| using Content.Shared.Containers.ItemSlots; | ||
| using Content.Shared.Interaction.Events; | ||
| using Content.Shared.Projectiles; | ||
| using Content.Shared.Popups; | ||
| using Content.Shared.Weapons.Ranged.Components; | ||
| using Content.Shared.Weapons.Ranged.Events; | ||
| using Content.Shared.Weapons.Ranged.Systems; | ||
| using Content.Shared.Wieldable.Components; | ||
| using Robust.Shared.Containers; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Shared.ADT.BowsSystem; | ||
|
|
||
| public sealed partial class BowsSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly SharedContainerSystem _containerSystem = default!; | ||
| [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!; | ||
| [Dependency] private readonly IGameTiming _timing = default!; | ||
| [Dependency] private readonly SharedPopupSystem _popup = default!; | ||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| SubscribeLocalEvent<ExpendedBowsComponent, GunShotEvent>(OnShoot); | ||
| SubscribeLocalEvent<ExpendedBowsComponent, UseInHandEvent>(OnUseInHand); | ||
| SubscribeLocalEvent<ExpendedBowsComponent, GunRefreshModifiersEvent>(EditSpeed); | ||
| } | ||
|
|
||
| public void OnShoot(Entity<ExpendedBowsComponent> bow, ref GunShotEvent args) | ||
| { | ||
| if(!TryComp<ContainerAmmoProviderComponent>(bow, out var containerComp)) | ||
| return; | ||
| if (!_containerSystem.TryGetContainer(containerComp.ProviderUid.Value, containerComp.Container, out var container)) | ||
|
Check failure on line 33 in Content.Shared/ADT/BowsSystem/SharedBowsSystem.cs
|
||
Firemixx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return; | ||
| if (bow.Comp.StepOfTension!=bow.Comp.MinTension) | ||
| { | ||
| foreach (var i in container.ContainedEntities) | ||
| { | ||
| if (TryComp<ProjectileComponent>(i,out var proj)) | ||
| { | ||
| if (!proj.Damage.DamageDict.TryGetValue(bow.Comp.DamageToModidiering, out var ProjectileDamage)) | ||
| return; | ||
| var multipliedDamage = ProjectileDamage * bow.Comp.StepOfTension; | ||
| proj.Damage.DamageDict[bow.Comp.DamageToModidiering] = multipliedDamage; | ||
| } | ||
| } | ||
| } | ||
| bow.Comp.StepOfTension=bow.Comp.MinTension; | ||
Firemixx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public void OnUseInHand(Entity<ExpendedBowsComponent> bow, ref UseInHandEvent args) | ||
| { | ||
| bow.Comp.coldownStart = _timing.CurTime + bow.Comp.coldown; | ||
| } | ||
|
|
||
| public override void Update(float frameTime) | ||
| { | ||
| base.Update(frameTime); | ||
|
|
||
| var query = EntityQueryEnumerator<ExpendedBowsComponent>(); | ||
|
|
||
| while (query.MoveNext(out var uid, out var comp)) | ||
| { | ||
| if (_timing.CurTime < comp.coldownStart) | ||
| continue; | ||
| if(!TryComp<WieldableComponent>(uid,out var wielded) || !wielded.Wielded) | ||
| { | ||
| comp.StepOfTension=comp.MinTension; | ||
| continue; | ||
| } | ||
| if (comp.StepOfTension >= comp.MaxTension) | ||
| continue; | ||
|
|
||
| comp.StepOfTension++; | ||
| _popup.PopupClient(Loc.GetString(comp.TensionAndLoc[comp.StepOfTension],("user", wielded.User)), uid, wielded.User); | ||
|
Check failure on line 75 in Content.Shared/ADT/BowsSystem/SharedBowsSystem.cs
|
||
| comp.coldownStart = _timing.CurTime + comp.coldown; | ||
| } | ||
| } | ||
Firemixx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public void EditSpeed(Entity<ExpendedBowsComponent> bow, ref GunRefreshModifiersEvent args) | ||
| { | ||
| args.ProjectileSpeed *= bow.Comp.TensionAndModieferSpeed[bow.Comp.StepOfTension]; | ||
| } | ||
Firemixx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| popup-bow-use-null = {$user} отпускает тетиву! | ||
| popup-bow-use-light = {$user} начинает натягивать тетиву! | ||
| popup-bow-use-medium = {$user} натягивает тетиву сильнее! | ||
| popup-bow-use-hard = {$user} натягивает тетиву максимально! |
Uh oh!
There was an error while loading. Please reload this page.