-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Speedloaders for Internal Magazine Weapons #29807
Changes from 2 commits
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 |
---|---|---|
|
@@ -49,10 +49,48 @@ private void OnBallisticInteractUsing(EntityUid uid, BallisticAmmoProviderCompon | |
return; | ||
|
||
if (GetBallisticShots(component) >= component.Capacity) | ||
{ | ||
Popup(Loc.GetString("gun-ballistic-transfer-target-full", ("entity", args.Target)), uid, args.User); | ||
return; | ||
} | ||
|
||
if (EntityManager.HasComponent<SpeedLoaderComponent>(args.Used)) | ||
{ | ||
var emptySlots = component.Capacity - component.UnspawnedCount - component.Entities.Count; // Number of empty slots in the shotgun | ||
|
||
var ammo = new List<(EntityUid? Entity, IShootable Shootable)>(); | ||
var ev = new TakeAmmoEvent(emptySlots, ammo, Transform(uid).Coordinates, args.User); | ||
RaiseLocalEvent(args.Used, ev); | ||
|
||
// empty speedloader | ||
if (ev.Ammo.Count == 0) | ||
{ | ||
Popup(Loc.GetString("gun-speedloader-empty"), uid, args.User); | ||
return; | ||
} | ||
|
||
foreach (var (ent, _) in ammo) | ||
{ | ||
if (ent == null) | ||
continue; | ||
|
||
component.Entities.Add(ent.Value); | ||
Containers.Insert(ent.Value, component.Container); | ||
|
||
if (IsClientSide(ent.Value)) | ||
Del(ent.Value); | ||
|
||
Comment on lines
+76
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this inserting then deleting it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what happens without the delete. 2024-08-08.21-51-03.mp4 |
||
if (ev.Ammo.Count == 0) | ||
break; | ||
Comment on lines
+83
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The event one is just a ref to the local variable, is this even possible here? It's being iterated in the loop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to work, is there another way to do this that's preferred or is that fine? 2024-08-08.22-00-55.mp4 |
||
} | ||
} | ||
// if not a speedloader just insert | ||
else | ||
{ | ||
component.Entities.Add(args.Used); | ||
Containers.Insert(args.Used, component.Container); | ||
} | ||
|
||
component.Entities.Add(args.Used); | ||
Containers.Insert(args.Used, component.Container); | ||
// Not predicted so | ||
Audio.PlayPredicted(component.SoundInsert, uid, args.User); | ||
args.Handled = true; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
- type: entity | ||
id: BaseSpeedLoaderShotgun | ||
name: "speed loader (shotgun)" | ||
parent: BaseItem | ||
abstract: true | ||
components: | ||
- type: Tag | ||
tags: | ||
- SpeedLoaderShotgun | ||
- type: SpeedLoader | ||
- type: BallisticAmmoProvider | ||
whitelist: | ||
tags: | ||
- ShellShotgun | ||
capacity: 4 | ||
- type: Sprite | ||
sprite: Objects/Weapons/Guns/Ammunition/SpeedLoaders/Shotgun/shotgun_speed_loader.rsi | ||
- type: ContainerContainer | ||
containers: | ||
ballistic-ammo: !type:Container | ||
ents: [] | ||
|
||
- type: entity | ||
id: SpeedLoaderShotgun | ||
name: "speed loader (shotgun)" | ||
parent: BaseSpeedLoaderShotgun | ||
components: | ||
- type: BallisticAmmoProvider | ||
proto: ShellShotgun | ||
- type: Sprite | ||
layers: | ||
- state: base | ||
map: ["enum.GunVisualLayers.Base"] | ||
- state: base-4 | ||
map: ["enum.GunVisualLayers.Mag"] | ||
- type: MagazineVisuals | ||
magState: base | ||
steps: 5 | ||
zeroVisible: false | ||
- type: Appearance |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"version": 1, | ||
"size": { | ||
"x": 32, | ||
"y": 32 | ||
}, | ||
"license": "CC0-1.0", | ||
"copyright": "Created by @BluHNT from Nuclear-14 fork", | ||
"states": [ | ||
{ | ||
"name": "base" | ||
}, | ||
{ | ||
"name": "base-1" | ||
}, | ||
{ | ||
"name": "base-2" | ||
}, | ||
{ | ||
"name": "base-3" | ||
}, | ||
{ | ||
"name": "base-4" | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this doubling the existing speedloaders? It's not even using a whitelist or anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by this? Doubling the existing speedloaders? It is also using a whitelist for anything inserted.
![image](https://private-user-images.githubusercontent.com/83733158/356444977-3cbb9327-4e25-46c7-8639-287083711d6c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMjQ0NTEsIm5iZiI6MTczOTMyNDE1MSwicGF0aCI6Ii84MzczMzE1OC8zNTY0NDQ5NzctM2NiYjkzMjctNGUyNS00NmM3LTg2MzktMjg3MDgzNzExZDZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDAxMzU1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJhMmY1ZWE5NDgzNTY2MTk3Yzc4Y2E4NGFiNWI0YmZlZGIzNTg1OTA3OTlhZTNhMzIxMDYwOGI3M2UyNWEyYjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.iPoRFsZCFfNavzdJ-a3RbNQUzaWHN_mT50pkjn3Fzbc)