forked from Exiled-Official/EXILED
-
Notifications
You must be signed in to change notification settings - Fork 111
feat: [😭] Firearm AmmoModules Api
#288
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
345f91c
init
IRacle1 d0482d2
xd
IRacle1 4fc2ebb
let him cook
IRacle1 35fe771
uuu
IRacle1 9dfa8ec
Merge branch 'scpsl14' into firearmhard
Misaka-ZeroTwo b79cb11
yep
IRacle1 c384ed9
oh
IRacle1 6bf5c81
ammo drain
IRacle1 e43047a
OnAdded fix
IRacle1 a651eda
Reload
IRacle1 6c77a89
IsDistributed
IRacle1 7a660a3
reviewuwu
IRacle1 e3cf0dc
Merge branch 'scpsl14' into firearmhard
IRacle1 cd3d4d5
-_-
IRacle1 76d36c7
build
IRacle1 ad20e18
reimplement props
IRacle1 db01c37
😥
IRacle1 13fe7f5
😊
IRacle1 8503fc5
ah
IRacle1 a5da95d
docs
IRacle1 16eceb7
docs
IRacle1 89151a8
Merge branch 'scpsl14' into firearmhard
IRacle1 c8beea0
fix: some server crash
IRacle1 5431c57
refactor: docs
IRacle1 95533f6
fix/feat: syncing `MaxAmmo`
IRacle1 c68eb7e
ammo drain sync
IRacle1 9c48040
refactor: strange modules interaction
IRacle1 d50b888
docs: its automatic, trust me
IRacle1 770d8b3
fix: revolver and maxammo
IRacle1 9c3bd16
fix: ammodrain for automatic firearms
IRacle1 2d1b9c5
Update EXILED/Exiled.API/Features/Items/Firearm.cs
IRacle1 bb1a0d8
Update EXILED/Exiled.API/Features/Items/FirearmModules/Barrel/Automat…
IRacle1 64fc8e8
Update EXILED/Exiled.API/Features/Items/FirearmModules/Primary/Normal…
IRacle1 619629f
Update EXILED/Exiled.API/Features/Items/FirearmModules/Primary/Normal…
IRacle1 10596b6
Update EXILED/Exiled.API/Features/Items/FirearmModules/Primary/Normal…
IRacle1 7623aa2
all yamato requests
IRacle1 ad0aaa5
Merge branch 'scpsl14' into firearmhard
IRacle1 e82b890
fix
IRacle1 a3263ae
Merge branch 'dev' into firearmhard
BoltonDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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,33 @@ | ||
| // ----------------------------------------------------------------------- | ||
| // <copyright file="RevolverChamberState.cs" company="ExMod Team"> | ||
| // Copyright (c) ExMod Team. All rights reserved. | ||
| // Licensed under the CC BY-SA 3.0 license. | ||
| // </copyright> | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| namespace Exiled.API.Enums | ||
| { | ||
| using Exiled.API.Features.Items.FirearmModules.Primary; | ||
|
|
||
| /// <summary> | ||
| /// States for chamber in revolver cylindric magazine. | ||
| /// </summary> | ||
| /// <seealso cref="CylinderMagazine"/> | ||
| public enum RevolverChamberState | ||
| { | ||
| /// <summary> | ||
| /// State for empty chamber. | ||
| /// </summary> | ||
| Empty, | ||
|
|
||
| /// <summary> | ||
| /// State for chamber with a bullet. | ||
| /// </summary> | ||
| Live, | ||
|
|
||
| /// <summary> | ||
| /// State for discharged chamber. | ||
| /// </summary> | ||
| Discharged, | ||
| } | ||
| } |
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
121 changes: 121 additions & 0 deletions
121
EXILED/Exiled.API/Features/Items/FirearmModules/Barrel/AutomaticBarrelMagazine.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,121 @@ | ||
| // ----------------------------------------------------------------------- | ||
| // <copyright file="AutomaticBarrelMagazine.cs" company="ExMod Team"> | ||
| // Copyright (c) ExMod Team. All rights reserved. | ||
| // Licensed under the CC BY-SA 3.0 license. | ||
| // </copyright> | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| namespace Exiled.API.Features.Items.FirearmModules.Barrel | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| using InventorySystem.Items.Firearms.Modules; | ||
|
|
||
| using UnityEngine; | ||
|
|
||
| /// <summary> | ||
| /// Basic realization of <see cref="AutomaticActionModule"/> barrel. | ||
| /// </summary> | ||
| public class AutomaticBarrelMagazine : BarrelMagazine | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="AutomaticBarrelMagazine"/> class. | ||
| /// </summary> | ||
| /// <param name="automaticModule">Target <see cref="AutomaticActionModule"/>.</param> | ||
| public AutomaticBarrelMagazine(AutomaticActionModule automaticModule) | ||
| : base(automaticModule) | ||
| { | ||
| AutomaticBarrel = automaticModule; | ||
| Firearm = (Firearm)Item.Get(AutomaticBarrel.Firearm); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets an original <see cref="IAmmoContainerModule"/>. | ||
| /// </summary> | ||
| public AutomaticActionModule AutomaticBarrel { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override Firearm Firearm { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int Ammo | ||
| { | ||
| get | ||
| { | ||
| return AutomaticBarrel.AmmoStored; | ||
| } | ||
|
|
||
| set | ||
| { | ||
| AutomaticBarrel.AmmoStored = Mathf.Max(value, 0); | ||
|
|
||
| Resync(); | ||
| } | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| /// <remarks> | ||
| /// Will be ranged between <see langword="0"/> and <see langword="16"/> due basegame logic. | ||
| /// </remarks> | ||
| public override int MaxAmmo | ||
| { | ||
| get | ||
| { | ||
| return AutomaticBarrel.ChamberSize; | ||
| } | ||
|
|
||
| set | ||
| { | ||
| AutomaticBarrel.ChamberSize = Mathf.Clamp(value, 0, 16); | ||
| } | ||
|
IRacle1 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override bool IsCocked | ||
| { | ||
| get | ||
| { | ||
| return AutomaticBarrel.Cocked; | ||
| } | ||
|
|
||
| set | ||
| { | ||
| AutomaticBarrel.Cocked = value; | ||
| Resync(); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether barrel magazine has open bolt or not. | ||
| /// </summary> | ||
| public bool IsOpenBolted => | ||
| AutomaticBarrel.OpenBolt; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value indicating whether barrel bolt is currently locked. | ||
| /// </summary> | ||
| public bool BoltLocked | ||
| { | ||
| get | ||
| { | ||
| return AutomaticBarrel.BoltLocked; | ||
| } | ||
|
|
||
| set | ||
| { | ||
| AutomaticBarrel.BoltLocked = value; | ||
| Resync(); | ||
| } | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override void Resync() | ||
| { | ||
| AutomaticBarrel.ServerResync(); | ||
| } | ||
| } | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
EXILED/Exiled.API/Features/Items/FirearmModules/Barrel/BarrelMagazine.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,31 @@ | ||
| // ----------------------------------------------------------------------- | ||
| // <copyright file="BarrelMagazine.cs" company="ExMod Team"> | ||
| // Copyright (c) ExMod Team. All rights reserved. | ||
| // Licensed under the CC BY-SA 3.0 license. | ||
| // </copyright> | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| namespace Exiled.API.Features.Items.FirearmModules.Barrel | ||
| { | ||
| using InventorySystem.Items.Firearms.Modules; | ||
|
|
||
| /// <summary> | ||
| /// Basic abstraction of <see cref="IAmmoContainerModule"/> whose are logically used to be a barrels magazines. | ||
| /// </summary> | ||
| public abstract class BarrelMagazine : Magazine | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="BarrelMagazine"/> class. | ||
| /// </summary> | ||
| /// <param name="module">target <see cref="IAmmoContainerModule"/>.</param> | ||
| public BarrelMagazine(IAmmoContainerModule module) | ||
| : base(module) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value indicating whether barrel is cocked. | ||
| /// </summary> | ||
| public abstract bool IsCocked { get; set; } | ||
| } | ||
| } |
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.