-
Notifications
You must be signed in to change notification settings - Fork 243
[ADD] Самодельный хлам. #2436
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
Open
Armorkillerd
wants to merge
45
commits into
AdventureTimeSS14:master
Choose a base branch
from
Armorkillerd:105
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[ADD] Самодельный хлам. #2436
Changes from 5 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
f544d53
ebal
Armorkillerd 2f1b756
Merge branch 'master' into 105
Armorkillerd 6115d30
1
Armorkillerd d2e1432
2
Armorkillerd ed69127
3
Armorkillerd d62c55c
4
Armorkillerd a736875
sda
Armorkillerd 5a2252c
6
Armorkillerd 4023495
sfa
Armorkillerd aa3d33e
7
Armorkillerd 9ccdcb4
8
Armorkillerd a1260e0
9
Armorkillerd b5f3836
11
Armorkillerd 07a91cd
12
Armorkillerd 9db9a86
13
Armorkillerd 5f8f989
14
Armorkillerd 3bcfd35
15
Armorkillerd fb286a3
desd
Armorkillerd ba2ab40
16
Armorkillerd 1831fb6
sa
Armorkillerd ce6bd66
Merge branch 'master' into 105
Armorkillerd b4a4021
fdu
Armorkillerd 5da928f
17
Armorkillerd 57435d3
sad
Armorkillerd 54ba0ad
18
Armorkillerd 29cb687
19
Armorkillerd e41abe5
20
Armorkillerd 5389f79
Sad
Armorkillerd 1f2d4a2
20
Armorkillerd 7d38acc
as
Armorkillerd 2dbd00a
sad
Armorkillerd bfdf2c7
damn
Armorkillerd 80c76eb
lol
Armorkillerd eee0717
77
Armorkillerd c7abbf9
ded
Armorkillerd 698cf30
Merge branch 'master' into 105
Armorkillerd 23fcf18
Merge branch 'master' into 105
Armorkillerd 5b02223
11
Armorkillerd feca82f
Merge branch 'master' into 105
Armorkillerd 4342099
12
Armorkillerd 1b48f3f
21
Armorkillerd 8f843d1
1
Armorkillerd 4339fa2
13
Armorkillerd 0f25e15
Merge branch 'master' into 105
Armorkillerd 491a78e
Merge branch 'master' into 105
Armorkillerd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,24 @@ | ||
| using Content.Shared.ADT.Weapon.Systems; | ||
| using System.Numerics; | ||
| using Content.Shared.ADT.Weapon.Components; | ||
| using Content.Shared.Inventory; | ||
| using Content.Shared.Popups; | ||
| using Content.Shared.Tag; | ||
| using Content.Shared.Throwing; | ||
| using Content.Shared.Weapons.Ranged.Systems; | ||
| using Robust.Shared.Physics.Systems; | ||
|
|
||
| //linq | ||
| using System.Linq; | ||
| using Content.Shared.Weapons.Ranged.Events; | ||
| using Robust.Shared.Random; | ||
| using Content.Shared.Damage; | ||
| using Content.Shared.Wieldable; | ||
| using Robust.Shared.Audio.Systems; | ||
| using Robust.Shared.Player; | ||
| using Robust.Shared.Audio; | ||
|
|
||
| namespace Content.Client.ADT.Weapon.Systems; | ||
| public sealed partial class WeaponDismantleOnShootSystem : SharedWeaponDismantleOnShootSystem | ||
| { | ||
| } |
103 changes: 103 additions & 0 deletions
103
Content.Server/ADT/Weapon/WeaponDismantleOnShootSystem.cs
This file contains hidden or 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,103 @@ | ||
| using Content.Shared.ADT.Weapon.Systems; | ||
| using System.Numerics; | ||
| using Content.Shared.ADT.Weapon.Components; | ||
| using Content.Shared.Inventory; | ||
| using Content.Shared.Popups; | ||
| using Content.Shared.Tag; | ||
| using Content.Shared.Throwing; | ||
| using Content.Shared.Weapons.Ranged.Systems; | ||
| using Robust.Shared.Physics.Systems; | ||
|
|
||
| //linq | ||
| using System.Linq; | ||
| using Content.Shared.Weapons.Ranged.Events; | ||
| using Robust.Shared.Random; | ||
| using Content.Shared.Damage; | ||
| using Content.Shared.Wieldable; | ||
| using Content.Shared.Weapons.Ranged.Components; | ||
| using Robust.Shared.Audio.Systems; | ||
| using Robust.Shared.Map; | ||
|
|
||
| namespace Content.Server.ADT.Weapon.Systems; | ||
| public sealed partial class WeaponDismantleOnShootSystem : SharedWeaponDismantleOnShootSystem | ||
| { | ||
| [Dependency] private readonly TagSystem _tagSystem = default!; | ||
| [Dependency] private readonly SharedGunSystem _gunSystem = default!; | ||
| [Dependency] private readonly ILogManager _log = default!; | ||
| [Dependency] protected readonly SharedTransformSystem _transformSystem = default!; | ||
| [Dependency] private readonly SharedPhysicsSystem _physics = default!; | ||
| [Dependency] private readonly SharedPopupSystem _popup = default!; | ||
| [Dependency] private readonly ThrowingSystem _throwing = default!; | ||
| [Dependency] private readonly InventorySystem _inventory = default!; | ||
| [Dependency] protected readonly DamageableSystem Damageable = default!; | ||
| [Dependency] private readonly IEntityManager _entityManager = default!; | ||
| [Dependency] private readonly SharedAudioSystem _audio = default!; | ||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| SubscribeLocalEvent<WeaponDismantleOnShootComponent, AmmoShotEvent>(OnGunShot); | ||
| } | ||
|
|
||
| private void OnGunShot(Entity<WeaponDismantleOnShootComponent> ent, ref AmmoShotEvent args) | ||
| { | ||
| if (DismantleCheck(ent, ref args) == false) | ||
| return; | ||
|
|
||
| //apply the damage to the shooter | ||
| //get the shooters damageable component | ||
| Damageable.TryChangeDamage(args.Shooter, ent.Comp.SelfDamage, origin:args.Shooter); | ||
|
|
||
| //we need the user past this point | ||
| if (!args.Shooter.HasValue) | ||
| return; | ||
|
|
||
| _audio.PlayPvs(ent.Comp.DismantleSound, args.Shooter.Value); | ||
|
|
||
| //get the users transform | ||
| var userPosition = Transform(args.Shooter.Value).Coordinates; | ||
|
|
||
| if (!TryComp<GunComponent>(ent, out var gunComponent)) | ||
| return; | ||
|
|
||
| var toCoordinates = gunComponent.ShootCoordinates; | ||
|
|
||
| if (toCoordinates == null) | ||
| return; | ||
|
|
||
| //loop through all of the items | ||
| var random = IoCManager.Resolve<IRobustRandom>(); | ||
| foreach (var item in ent.Comp.items) | ||
| { | ||
| for (var i = 0; i < item.Amount; i++) | ||
| { | ||
| //roll to see if we destroy the item or not | ||
| if (!random.Prob(item.SpawnProbability)) | ||
| continue; | ||
|
|
||
| //get the item entity | ||
| var itemEntity = Spawn(item.PrototypeId, userPosition); | ||
|
|
||
| Vector2 direction = toCoordinates.Value.Position; | ||
| //normalize it | ||
| direction = Vector2.Normalize(direction); | ||
| //multiply it by the distance | ||
| direction *= ent.Comp.DismantleDistance; | ||
| //rotate it by the angle | ||
| direction = item.LaunchAngle.RotateVec(direction); | ||
|
|
||
| //roll for random angle modifier | ||
| double randomAngle = random.NextDouble(-item.AngleRandomness.Degrees, item.AngleRandomness.Degrees); | ||
| //rotate it by the random angle | ||
| direction = Angle.FromDegrees(randomAngle).RotateVec(direction); | ||
|
|
||
| var throwDirection = new EntityCoordinates(args.Shooter.Value, direction); | ||
|
|
||
| _throwing.TryThrow(itemEntity, throwDirection, ent.Comp.DismantleDistance, compensateFriction: true); | ||
| } | ||
| } | ||
|
|
||
| //now we need to destroy the gun | ||
| //get the gun entity | ||
| _entityManager.QueueDeleteEntity(ent.Owner); | ||
| } | ||
| } | ||
This file contains hidden or 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
55 changes: 55 additions & 0 deletions
55
Content.Shared/ADT/Weapons/Components/WeaponDismantleOnShootComponent.cs
This file contains hidden or 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,55 @@ | ||
| using Content.Shared.Damage; | ||
| using Content.Shared.Storage; | ||
| using Content.Shared.Tag; | ||
| using Robust.Shared.Audio; | ||
| using Robust.Shared.GameStates; | ||
| using Robust.Shared.Prototypes; | ||
| using Robust.Shared.Serialization; | ||
|
|
||
| namespace Content.Shared.ADT.Weapon.Components; | ||
| [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
| public sealed partial class WeaponDismantleOnShootComponent : Component | ||
| { | ||
| [DataField, AutoNetworkedField] | ||
| public float DismantleChance = 0.0f; | ||
|
|
||
| /// <summary> | ||
| /// How far to throw things when dismantling. | ||
| /// </summary> | ||
| [DataField, AutoNetworkedField] | ||
| public float DismantleDistance = 5f; | ||
|
|
||
| [DataField] | ||
| public SoundCollectionSpecifier? DismantleSound = new SoundCollectionSpecifier("MetalBreak"); | ||
|
|
||
| [DataField, AutoNetworkedField] | ||
| [ViewVariables(VVAccess.ReadWrite)] | ||
| public DamageSpecifier SelfDamage = new(); | ||
|
|
||
| [DataField, AutoNetworkedField] | ||
| public List<DismantleOnShootItem> items = []; | ||
| } | ||
|
|
||
| [DataDefinition] | ||
| [Serializable, NetSerializable] | ||
| public sealed partial class DismantleOnShootItem | ||
| { | ||
| public DismantleOnShootItem() { } | ||
| [DataField("id")] | ||
| public EntProtoId? PrototypeId = null; | ||
|
|
||
| /// <summary> | ||
| /// The probability that an item will spawn. Takes decimal form so 0.05 is 5%, 0.50 is 50% etc. | ||
| /// </summary> | ||
| [DataField("prob")] | ||
| public float SpawnProbability = 1; | ||
|
|
||
| [DataField] | ||
| public int Amount = 1; | ||
|
|
||
| [ViewVariables(VVAccess.ReadWrite), DataField] | ||
| public Angle LaunchAngle = Angle.FromDegrees(0); | ||
|
|
||
| [ViewVariables(VVAccess.ReadWrite), DataField] | ||
| public Angle AngleRandomness = Angle.FromDegrees(5); | ||
| } |
38 changes: 38 additions & 0 deletions
38
Content.Shared/ADT/Weapons/SharedWeaponDismantleOnShootSystem.cs
This file contains hidden or 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,38 @@ | ||
| using Content.Shared.ADT.Weapon.Components; | ||
| using Content.Shared.Examine; | ||
| using Content.Shared.Weapons.Ranged.Events; | ||
| using Content.Shared.Weapons.Ranged.Systems; | ||
| using Robust.Shared.Random; | ||
|
|
||
| namespace Content.Shared.ADT.Weapon.Systems; | ||
|
|
||
| public abstract partial class SharedWeaponDismantleOnShootSystem : EntitySystem | ||
| { | ||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| SubscribeLocalEvent<WeaponDismantleOnShootComponent, ExaminedEvent>(OnExamine); | ||
| } | ||
|
|
||
| public bool DismantleCheck(Entity<WeaponDismantleOnShootComponent> ent, ref AmmoShotEvent args) | ||
| { | ||
| //roll to see if we explode or not | ||
| var random = IoCManager.Resolve<IRobustRandom>(); | ||
| //1.0f means always true, 0.0f means always false | ||
| if (!random.Prob(ent.Comp.DismantleChance)) | ||
| return false; | ||
|
|
||
| return true; | ||
| } | ||
Armorkillerd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private void OnExamine(Entity<WeaponDismantleOnShootComponent> ent, ref ExaminedEvent args) | ||
| { | ||
| if (!args.IsInDetailsRange) | ||
| return; | ||
|
|
||
| if (ent.Comp.DismantleChance <= 0.0f) | ||
| return; | ||
|
|
||
| args.PushMarkup(Loc.GetString("examine-weapon-dismantle-on-shoot", ("chance", String.Format("{0:0.#}", ent.Comp.DismantleChance * 100)))); | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.