Skip to content

Commit 247735f

Browse files
committed
feat(managed): More method to weapon service
1 parent 26e22d4 commit 247735f

File tree

2 files changed

+81
-9
lines changed

2 files changed

+81
-9
lines changed

managed/src/SwiftlyS2.Core/Modules/Schemas/Extensions/CPlayer_WeaponServices.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,42 @@ public partial interface CPlayer_WeaponServices {
2020
/// <param name="weapon">The weapon to select.</param>
2121
public void SelectWeapon(CBasePlayerWeapon weapon);
2222

23+
/// <summary>
24+
/// Drop a weapon by slot.
25+
/// </summary>
26+
/// <param name="slot">The slot to drop the weapon from.</param>
27+
public void DropWeaponBySlot( gear_slot_t slot );
28+
29+
/// <summary>
30+
/// Remove a weapon by slot.
31+
/// </summary>
32+
/// <param name="slot">The slot to remove the weapon from.</param>
33+
public void RemoveWeaponBySlot( gear_slot_t slot );
34+
35+
/// <summary>
36+
/// Select a weapon by slot.
37+
/// </summary>
38+
/// <param name="slot">The slot to select the weapon from.</param>
39+
public void SelectWeaponBySlot( gear_slot_t slot );
40+
41+
/// <summary>
42+
/// Drop a weapon by designer name.
43+
/// </summary>
44+
/// <param name="designerName">The designer name of the weapon to drop.</param>
45+
public void DropWeaponByDesignerName( string designerName );
46+
47+
/// <summary>
48+
/// Remove a weapon by designer name.
49+
/// </summary>
50+
/// <param name="designerName">The designer name of the weapon to remove.</param>
51+
public void RemoveWeaponByDesignerName( string designerName );
52+
53+
/// <summary>
54+
/// Select a weapon by designer name.
55+
/// </summary>
56+
/// <param name="designerName">The designer name of the weapon to select.</param>
57+
public void SelectWeaponByDesignerName( string designerName );
58+
2359
/// <summary>
2460
/// Drop all weapons with the specified class.
2561
/// </summary>

managed/src/SwiftlyS2.Core/Modules/Schemas/Extensions/CPlayer_WeaponServicesImpl.cs

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,68 @@ public void SelectWeapon(CBasePlayerWeapon weapon) {
2121
GameFunctions.CCSPlayer_WeaponServices_SelectWeapon(Address, weapon.Address);
2222
}
2323

24-
public void DropWeaponByClass<T>() where T : CBasePlayerWeapon {
25-
var name = EntitySystemService.TypeToDesignerName[typeof(T)];
24+
public void DropWeaponBySlot( gear_slot_t slot ) {
2625
MyWeapons.ToList().ForEach(weapon => {
27-
if (weapon.Value?.Entity?.DesignerName == name) {
26+
if ( weapon.Value?.As<CCSWeaponBase>().WeaponBaseVData.GearSlot == slot ) {
2827
DropWeapon(weapon.Value);
2928
}
3029
});
3130
}
3231

33-
public void RemoveWeaponByClass<T>() where T : CBasePlayerWeapon {
34-
var name = EntitySystemService.TypeToDesignerName[typeof(T)];
32+
public void RemoveWeaponBySlot( gear_slot_t slot ) {
3533
MyWeapons.ToList().ForEach(weapon => {
36-
if (weapon.Value?.Entity?.DesignerName == name) {
34+
if ( weapon.Value?.As<CCSWeaponBase>().WeaponBaseVData.GearSlot == slot ) {
3735
RemoveWeapon(weapon.Value);
3836
}
3937
});
4038
}
4139

42-
public void SelectWeaponByClass<T>() where T : CBasePlayerWeapon {
43-
var name = EntitySystemService.TypeToDesignerName[typeof(T)];
40+
public void SelectWeaponBySlot( gear_slot_t slot ) {
4441
MyWeapons.ToList().ForEach(weapon => {
45-
if (weapon.Value?.Entity?.DesignerName == name) {
42+
if ( weapon.Value?.As<CCSWeaponBase>().WeaponBaseVData.GearSlot == slot ) {
4643
SelectWeapon(weapon.Value);
4744
return;
4845
}
4946
});
5047
}
5148

49+
public void DropWeaponByDesignerName( string designerName ) {
50+
MyWeapons.ToList().ForEach(weapon => {
51+
if ( weapon.Value?.Entity?.DesignerName == designerName ) {
52+
DropWeapon(weapon.Value);
53+
}
54+
});
55+
}
56+
57+
public void RemoveWeaponByDesignerName( string designerName ) {
58+
MyWeapons.ToList().ForEach(weapon => {
59+
if ( weapon.Value?.Entity?.DesignerName == designerName ) {
60+
RemoveWeapon(weapon.Value);
61+
}
62+
});
63+
}
64+
65+
public void SelectWeaponByDesignerName( string designerName ) {
66+
MyWeapons.ToList().ForEach(weapon => {
67+
if ( weapon.Value?.Entity?.DesignerName == designerName ) {
68+
SelectWeapon(weapon.Value);
69+
}
70+
});
71+
}
72+
73+
public void DropWeaponByClass<T>() where T : CBasePlayerWeapon {
74+
var name = EntitySystemService.TypeToDesignerName[typeof(T)];
75+
DropWeaponByDesignerName(name);
76+
}
77+
78+
public void RemoveWeaponByClass<T>() where T : CBasePlayerWeapon {
79+
var name = EntitySystemService.TypeToDesignerName[typeof(T)];
80+
RemoveWeaponByDesignerName(name);
81+
}
82+
83+
public void SelectWeaponByClass<T>() where T : CBasePlayerWeapon {
84+
var name = EntitySystemService.TypeToDesignerName[typeof(T)];
85+
SelectWeaponByDesignerName(name);
86+
}
87+
5288
}

0 commit comments

Comments
 (0)