mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-03-12 01:01:22 +00:00
revert IncrementWearForWeaponWithStickers
This commit is contained in:
@@ -139,6 +139,27 @@ namespace WeaponPaints
|
|||||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel);
|
UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// silly method to update sticker when call RefreshWeapons()
|
||||||
|
private void IncrementWearForWeaponWithStickers(CCSPlayerController player, CBasePlayerWeapon weapon)
|
||||||
|
{
|
||||||
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null ||
|
||||||
|
weaponInfo.Stickers.Count <= 0) return;
|
||||||
|
|
||||||
|
float wearIncrement = 0.001f;
|
||||||
|
float currentWear = weaponInfo.Wear;
|
||||||
|
|
||||||
|
var playerWear = _temporaryPlayerWeaponWear.GetOrAdd(player.Slot, _ => new ConcurrentDictionary<int, float>());
|
||||||
|
|
||||||
|
float incrementedWear = playerWear.AddOrUpdate(
|
||||||
|
weaponDefIndex,
|
||||||
|
currentWear + wearIncrement,
|
||||||
|
(_, oldWear) => Math.Min(oldWear + wearIncrement, 1.0f)
|
||||||
|
);
|
||||||
|
|
||||||
|
weapon.FallbackWear = incrementedWear;
|
||||||
|
}
|
||||||
|
|
||||||
private void SetStickers(CCSPlayerController? player, CBasePlayerWeapon weapon)
|
private void SetStickers(CCSPlayerController? player, CBasePlayerWeapon weapon)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid) return;
|
if (player == null || !player.IsValid) return;
|
||||||
@@ -331,6 +352,8 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
newWeapon.Clip1 = ammo.Item1;
|
newWeapon.Clip1 = ammo.Item1;
|
||||||
newWeapon.ReserveAmmo[0] = ammo.Item2;
|
newWeapon.ReserveAmmo[0] = ammo.Item2;
|
||||||
|
|
||||||
|
IncrementWearForWeaponWithStickers(player, newWeapon);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user