This commit is contained in:
Oscar 2025-06-10 20:45:40 +03:00
parent dd266b1a8a
commit de85b85b13
14 changed files with 196 additions and 273 deletions

View File

@ -1,16 +0,0 @@
{
"Slot": "Body",
"HoldType": "None",
"ImageTexture": null,
"ImageUrl": "https://cdn.sbox.game/asset/pukes.pyjamatop/thumb.png.9405387bc9d8e406",
"ClothUrl": "pukes/pyjamatop",
"Name": "Pyjama Top",
"Description": "Test clothing",
"Prefab": null,
"WeaponDefinition": {
"Position": "0,0,0",
"Rotation": "0,0,0,0"
},
"__references": [],
"__version": 0
}

View File

@ -1,47 +0,0 @@
{
"Slot": "RightHand",
"HoldType": "Pistol",
"ImageTexture": {
"$compiler": "texture",
"$source": "imagefile",
"data": {
"FilePath": "textures/box_box_parallax_example_texture.png",
"MaxSize": 4096,
"ConvertHeightToNormals": false,
"NormalScale": 1,
"Rotate": 0,
"FlipVertical": false,
"FlipHorizontal": false,
"Padding": {
"Size": "0,0",
"EdgeSize": "0,0"
},
"Sharpen": 0,
"InvertColor": false,
"Blur": 0,
"Brightness": 1,
"Contrast": 1,
"Saturation": 1,
"Hue": 0,
"Colorize": false,
"TargetColor": "0,1,0,1",
"CacheToDisk": true
},
"compiled": "textures/generated/imagefile/40617d16d6d5e270.vtex"
},
"ImageUrl": "https://files.koptilnya.xyz/?r=/download&path=L9Ch0L3QuNC80L7QuiDRjdC60YDQsNC90LAgMjAyNC0wNC0wNSAwMjA3MTIucG5n",
"Name": "Пистун",
"Description": "Стреляй-убивао",
"Count": 1,
"MaxCount": 1,
"Prefab": {
"_type": "gameobject",
"prefab": "prefabs/weapon/pistol_1.prefab"
},
"WeaponDefinition": {
"Position": "-1.108,0.38,-2.367",
"Rotation": "0.002790701,0.01173679,0.006057173,0.9999089"
},
"__references": [],
"__version": 0
}

File diff suppressed because one or more lines are too long

View File

@ -1,16 +0,0 @@
{
"Slot": "None",
"HoldType": "None",
"ImageTexture": null,
"ImageUrl": "https://cdn.sbox.game/org/doubletrouble/denimshorts/thumb/03a1325a-4ac5-4884-8cc2-b379a01b976c.png",
"ClothUrl": "doubletrouble/denimshorts",
"Name": "Denim Shorts",
"Description": "test shorts",
"Prefab": null,
"WeaponDefinition": {
"Position": "0,0,0",
"Rotation": "0,0,0,0"
},
"__references": [],
"__version": 0
}

View File

@ -2028,9 +2028,9 @@
"__version": 1,
"Flags": 8,
"Name": "ankle_R",
"Position": "0.4100335,-4.377071,3.807489",
"Rotation": "0.6728557,0.2185201,-0.3316683,0.6241075",
"Scale": "1.000002,1.000002,1.000002",
"Position": "0.4099646,-4.377359,3.807756",
"Rotation": "0.6728516,0.2185292,-0.3316596,0.6241136",
"Scale": "1.000001,1.000001,1.000001",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2045,9 +2045,9 @@
"__version": 1,
"Flags": 8,
"Name": "ankle_L",
"Position": "0.4083832,4.427598,3.805829",
"Rotation": "0.6245875,0.3321067,-0.218319,0.6722592",
"Scale": "1,1,1",
"Position": "0.4083393,4.427768,3.806167",
"Rotation": "0.6245928,0.3320992,-0.2183265,0.6722555",
"Scale": "1.000001,1.000001,1.000001",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2062,9 +2062,9 @@
"__version": 1,
"Flags": 8,
"Name": "arm_lower_R",
"Position": "-2.305881,-8.654749,40.97688",
"Rotation": "0.5030814,0.3782525,-0.540166,0.5586189",
"Scale": "1.000004,1.000004,1.000004",
"Position": "-2.567823,-9.414575,40.7076",
"Rotation": "0.4924873,0.3660672,-0.5479427,0.5685155",
"Scale": "1.000005,1.000005,1.000005",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2079,9 +2079,9 @@
"__version": 1,
"Flags": 8,
"Name": "arm_lower_L",
"Position": "-1.954972,9.871452,41.46471",
"Rotation": "0.5850527,0.5385041,-0.3695764,0.4807702",
"Scale": "1.000003,1.000003,1.000003",
"Position": "-2.410847,9.395028,40.69125",
"Rotation": "0.5735433,0.5426417,-0.3705063,0.4891964",
"Scale": "1.000005,1.000005,1.000005",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2096,9 +2096,9 @@
"__version": 1,
"Flags": 8,
"Name": "hand_R",
"Position": "-1.301779,-10.37271,33.53143",
"Rotation": "0.4744667,0.3565034,-0.5969852,0.5398108",
"Scale": "1.000005,1.000005,1.000005",
"Position": "-1.554352,-11.43732,33.34042",
"Rotation": "0.4642905,0.3432117,-0.604311,0.5490432",
"Scale": "1.000007,1.000007,1.000007",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2113,9 +2113,9 @@
"__version": 1,
"Flags": 8,
"Name": "hand_L",
"Position": "-0.8232388,11.98876,34.14148",
"Rotation": "0.5664198,0.5951051,-0.345663,0.4533604",
"Scale": "1.000003,1.000003,1.000003",
"Position": "-1.358666,11.39837,33.32423",
"Rotation": "0.5545862,0.5991901,-0.3473969,0.4612166",
"Scale": "1.000006,1.000006,1.000006",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2130,9 +2130,9 @@
"__version": 1,
"Flags": 8,
"Name": "hold_R",
"Position": "0.1027977,-8.932137,27.48148",
"Rotation": "0.3143174,0.7234542,0.06842977,0.6108487",
"Scale": "1.000005,1.000005,1.000005",
"Position": "-0.1356873,-10.24809,27.23935",
"Rotation": "0.3025265,0.7237881,0.05324486,0.6178782",
"Scale": "1.000008,1.000008,1.000008",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2147,9 +2147,9 @@
"__version": 1,
"Flags": 8,
"Name": "hold_L",
"Position": "0.5759228,10.85694,28.0248",
"Rotation": "-0.2817041,0.7288769,-0.05973086,0.6211389",
"Scale": "1.000004,1.000004,1.000004",
"Position": "0.03949806,10.18287,27.22342",
"Rotation": "-0.2958933,0.7264506,-0.0589573,0.6174469",
"Scale": "1.000007,1.000007,1.000007",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2165,7 +2165,7 @@
"Flags": 8,
"Name": "IK_right_hand",
"Position": "-1.684358,-11.3081,33.23968",
"Rotation": "0.4603033,0.3490921,-0.6097354,0.5426587",
"Rotation": "0.4603033,0.3490922,-0.6097354,0.5426587",
"Scale": "1,1,1",
"Tags": "",
"Enabled": true,
@ -2198,9 +2198,9 @@
"__version": 1,
"Flags": 8,
"Name": "leg_lower_R",
"Position": "2.141828,-4.433267,16.20256",
"Rotation": "0.4914648,0.5026264,-0.5626303,0.435059",
"Scale": "1,1,1",
"Position": "2.852134,-4.64673,16.07982",
"Rotation": "0.4771746,0.5220156,-0.5701445,0.4180185",
"Scale": "1.000002,1.000002,1.000002",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2215,8 +2215,8 @@
"__version": 1,
"Flags": 8,
"Name": "leg_lower_L",
"Position": "2.990841,4.839132,16.04515",
"Rotation": "0.4134015,0.568549,-0.5290765,0.4753201",
"Position": "2.710925,4.660064,16.10588",
"Rotation": "0.4209704,0.5689973,-0.5179102,0.4804112",
"Scale": "1.000001,1.000001,1.000001",
"Tags": "",
"Enabled": true,
@ -2232,9 +2232,9 @@
"__version": 1,
"Flags": 8,
"Name": "middle_of_both_hands",
"Position": "-0.8430352,0.9475369,29.01887",
"Rotation": "0.01926278,0.7531982,0.004356876,0.6574971",
"Scale": "1.000004,1.000004,1.000004",
"Position": "-1.265596,-0.021348,28.53136",
"Rotation": "0.003585241,0.7594557,-0.003357793,0.6505405",
"Scale": "1.000006,1.000006,1.000006",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2249,9 +2249,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_arm_upper_R_twist1",
"Position": "-1.400206,-7.729323,45.82975",
"Position": "-1.681034,-8.291717,45.52214",
"Rotation": "0,0,0,1",
"Scale": "1.000003,1.000003,1.000003",
"Scale": "1.000005,1.000005,1.000005",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2266,9 +2266,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_arm_lower_R_twist1",
"Position": "-1.80383,-9.513729,37.25415",
"Position": "-2.061087,-10.42595,37.02401",
"Rotation": "0,0,0,1",
"Scale": "1.000004,1.000004,1.000004",
"Scale": "1.000006,1.000006,1.000006",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2283,9 +2283,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_elbow_R_position",
"Position": "-2.314887,-8.657202,40.97291",
"Rotation": "-0.0298567,-0.6296679,0.7760905,0.01761862",
"Scale": "1.000004,1.000004,1.000004",
"Position": "-2.574409,-9.417637,40.70373",
"Rotation": "-0.03302322,-0.6136653,0.7886796,0.01757571",
"Scale": "1.000006,1.000006,1.000006",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2300,9 +2300,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_elbow_L_position",
"Position": "-1.963849,9.874497,41.4608",
"Rotation": "-0.04279031,0.7921829,-0.6040214,0.07598255",
"Scale": "1.000003,1.000003,1.000003",
"Position": "-2.417371,9.398232,40.68735",
"Rotation": "-0.05309913,0.7858217,-0.6108508,0.08078353",
"Scale": "1.000005,1.000005,1.000005",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2317,9 +2317,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_arm_upper_L_twist1",
"Position": "-1.12625,8.624744,46.25906",
"Position": "-1.545969,8.256403,45.50608",
"Rotation": "0,0,0,1",
"Scale": "1.000002,1.000002,1.000002",
"Scale": "1.000005,1.000005,1.000005",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2334,9 +2334,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_arm_lower_L_twist1",
"Position": "-1.389105,10.93011,37.80309",
"Position": "-1.884756,10.3967,37.00774",
"Rotation": "0,0,0,1",
"Scale": "1.000003,1.000003,1.000003",
"Scale": "1.000006,1.000006,1.000006",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2351,9 +2351,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_leg_upper_R_twist1",
"Position": "1.383293,-4.265827,23.39594",
"Position": "1.835075,-4.537014,23.24235",
"Rotation": "0,0,0,1",
"Scale": "1.000001,1.000001,1.000001",
"Scale": "1.000002,1.000002,1.000002",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2368,9 +2368,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_leg_upper_L_twist1",
"Position": "1.837544,4.795762,23.18769",
"Position": "1.777929,4.543681,23.27972",
"Rotation": "0,0,0,1",
"Scale": "1,1,1",
"Scale": "1.000001,1.000001,1.000001",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2385,9 +2385,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_kneecap_R_position",
"Position": "2.503448,-4.474622,16.17259",
"Rotation": "0.5185856,0.4737309,-0.5330592,0.4716947",
"Scale": "1.000001,1.000001,1.000001",
"Position": "3.351182,-4.701256,16.04174",
"Rotation": "0.5169078,0.4808557,-0.5317466,0.4677923",
"Scale": "1.000002,1.000002,1.000002",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2402,8 +2402,8 @@
"__version": 1,
"Flags": 8,
"Name": "driver_kneecap_L_position",
"Position": "3.534691,4.896688,16.00735",
"Rotation": "0.7001207,0.04391778,0.02674206,0.7121707",
"Position": "3.176064,4.711613,16.06872",
"Rotation": "0.7050594,0.04671752,0.02711059,0.7070882",
"Scale": "1.000001,1.000001,1.000001",
"Tags": "",
"Enabled": true,
@ -2419,9 +2419,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_leg_lower_R_twist1",
"Position": "1.275923,-4.405165,10.00504",
"Position": "1.63105,-4.512045,9.943793",
"Rotation": "0,0,0,1",
"Scale": "1.000001,1.000001,1.000001",
"Scale": "1.000003,1.000003,1.000003",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2436,9 +2436,9 @@
"__version": 1,
"Flags": 8,
"Name": "driver_leg_lower_L_twist1",
"Position": "1.699609,4.633352,9.925488",
"Position": "1.55963,4.543931,9.956005",
"Rotation": "0,0,0,1",
"Scale": "1.000001,1.000001,1.000001",
"Scale": "1.000002,1.000002,1.000002",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2453,9 +2453,9 @@
"__version": 1,
"Flags": 8,
"Name": "forward_reference_modelspace",
"Position": "-0.2639478,0.2526502,43.42427",
"Position": "-0.4114534,0.001021107,43.38918",
"Rotation": "0,0,0,1",
"Scale": "1.000001,1.000001,1.000001",
"Scale": "1.000002,1.000002,1.000002",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2470,9 +2470,9 @@
"__version": 1,
"Flags": 8,
"Name": "eyes",
"Position": "5.885584,-0.1965587,63.25779",
"Rotation": "0.0126497,-0.01464069,-0.01462483,0.9997059",
"Scale": "1.000002,1.000002,1.000002",
"Position": "5.407951,-0.1355422,63.24592",
"Rotation": "-0.0007134229,-0.01552102,-0.01144814,0.9998137",
"Scale": "1.000004,1.000004,1.000004",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2487,9 +2487,9 @@
"__version": 1,
"Flags": 8,
"Name": "eye_R_forward",
"Position": "5.788969,-3.540511,63.17171",
"Rotation": "0.0126497,-0.01464069,-0.01462483,0.9997059",
"Scale": "1.000002,1.000002,1.000002",
"Position": "5.331269,-3.481122,63.24951",
"Rotation": "-0.0007134229,-0.01552102,-0.01144814,0.9998137",
"Scale": "1.000004,1.000004,1.000004",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2504,9 +2504,9 @@
"__version": 1,
"Flags": 8,
"Name": "eye_L_forward",
"Position": "5.982198,3.147393,63.34386",
"Rotation": "0.0126497,-0.01464069,-0.01462483,0.9997059",
"Scale": "1.000002,1.000002,1.000002",
"Position": "5.484632,3.210038,63.24234",
"Rotation": "-0.0007134229,-0.01552102,-0.01144814,0.9998137",
"Scale": "1.000004,1.000004,1.000004",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2521,9 +2521,9 @@
"__version": 1,
"Flags": 8,
"Name": "forward_reference",
"Position": "0.779397,0.1321325,56.21957",
"Rotation": "0.0126497,-0.01464069,-0.01462483,0.9997059",
"Scale": "1.000002,1.000002,1.000002",
"Position": "0.3106461,-0.02626462,56.19444",
"Rotation": "-0.0007134229,-0.01552102,-0.01144814,0.9998137",
"Scale": "1.000004,1.000004,1.000004",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2538,9 +2538,9 @@
"__version": 1,
"Flags": 8,
"Name": "foot_R",
"Position": "1.982155,-4.910447,0.1893355",
"Rotation": "0.0004867911,-0.0000140816,-0.08711611,0.9961981",
"Scale": "1.000002,1.000002,1.000002",
"Position": "1.982103,-4.910701,0.1895912",
"Rotation": "0.0004849434,-0.00001452863,-0.08709995,0.9961995",
"Scale": "1.000004,1.000004,1.000004",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,
@ -2555,8 +2555,8 @@
"__version": 1,
"Flags": 8,
"Name": "foot_L",
"Position": "1.978698,4.966865,1.053316",
"Rotation": "-0.0872355,0.9961876,0.0004070103,0.00001410835",
"Position": "1.978663,4.967034,1.053633",
"Rotation": "-0.08722261,0.9961888,0.0004088581,0.00001432814",
"Scale": "1.000002,1.000002,1.000002",
"Tags": "",
"Enabled": true,
@ -2572,9 +2572,9 @@
"__version": 1,
"Flags": 8,
"Name": "hat",
"Position": "0.6251416,-0.2530355,71.37424",
"Rotation": "0.0126497,-0.01464069,-0.01462483,0.9997059",
"Scale": "1.000002,1.000002,1.000002",
"Position": "0.1355461,-0.005559167,71.35379",
"Rotation": "-0.0007134229,-0.01552102,-0.01144814,0.9998137",
"Scale": "1.000004,1.000004,1.000004",
"Tags": "",
"Enabled": true,
"NetworkMode": 2,

View File

@ -0,0 +1,12 @@
namespace Sasalka;
[GameResource( "Base Item Definition", "inv", "", Category = "Sasalka", Icon = "inventory_2" )]
public class BaseItemDefinition : GameResource
{
public string Name { get; set; }
public string Description { get; set; }
[ResourceType( "prefab" )] public GameObject Prefab { get; set; }
public Texture ImageTexture { get; set; }
public string ImageUrl { get; set; }
}

View File

@ -0,0 +1,8 @@
namespace Sasalka;
[GameResource( "Clothing Item Definition", "clitem", "", Category = "Sasalka", Icon = "inventory_2" )]
public class ClothingItemDefinition : BaseItemDefinition, IEquipable
{
[Property] public string ClothUrl { get; set; }
public Inventar.InventorySlot Slot { get; set; }
}

View File

@ -0,0 +1,6 @@
namespace Sasalka;
public interface IEquipable
{
Inventar.InventorySlot Slot { get; }
}

View File

@ -2,23 +2,11 @@
namespace Sasalka;
[GameResource( "Inventory Item Definition", "inv", "", Category = "Sasalka", Icon = "inventory_2" )]
public class InventoryItemDefinition : GameResource
[GameResource( "Weapon Item Definition", "weapon", "", Category = "Sasalka", Icon = "inventory_2" )]
public class WeaponItemDefinition : BaseItemDefinition, IEquipable
{
public Inventar.InventorySlot Slot { get; set; }
public CitizenAnimationHelper.HoldTypes HoldType { get; set; } = CitizenAnimationHelper.HoldTypes.None;
public Texture ImageTexture { get; set; }
public string ImageUrl { get; set; }
public string ClothUrl { get; set; }
public string Name { get; set; }
public string Description { get; set; }
[ResourceType( "prefab" )] public GameObject Prefab { get; set; }
[InlineEditor, Space] public WeaponDefinition WeaponDefinition { get; set; }
}

View File

@ -17,20 +17,12 @@ public class Inventar
public List<InventoryItem> Items { get; private set; } = new();
public static bool IsInventoryOpen = false;
// public Dictionary<InventorySlot, EquippedItem> EquippedItems { get; private set; } = new();
public Dictionary<InventorySlot, InventoryItem> EquippedItems { get; private set; } = new();
public event Action OnChanged;
public event Action<InventoryItem> OnEquipped;
public event Action<InventoryItem> OnUnEquipped;
// public class EquippedItem
// {
// public InventoryItem Item { get; set; }
// public GameObject SpawnedObject { get; set; }
// }
public void AddItem( InventoryItem item )
{
Items.Add( item );
@ -44,15 +36,30 @@ public class Inventar
OnChanged?.Invoke();
}
// public void EquipItem( InventoryItem item )
// {
// if ( EquippedItems.ContainsValue( item ) )
// {
// UnEquipItem( item );
// }
// else
// {
// EquippedItems.Add( item.Definition.Slot, item );
// OnEquipped?.Invoke( item );
// }
// }
public void EquipItem( InventoryItem item )
{
if ( item.Definition is not IEquipable equipable ) return;
if ( EquippedItems.ContainsValue( item ) )
{
UnEquipItem( item );
}
else
{
EquippedItems.Add( item.Definition.Slot, item );
EquippedItems[equipable.Slot] = item;
OnEquipped?.Invoke( item );
}
}

View File

@ -4,12 +4,7 @@ namespace Sasalka;
public class InventoryItem : Component
{
public InventoryItemDefinition Definition { get; set; }
public BaseItemDefinition Definition { get; set; }
public int Count { get; set; } = 1;
public int MaxCount { get; set; } = 1;
// public GameObject SpawnedObject { get; set; }
}
// public int Count { get; set; } = 1;
// public int MaxCount { get; set; } = 1;

View File

@ -18,22 +18,22 @@ public sealed partial class Dedugan : Component
Inventory.AddItem( new InventoryItem
{
Definition = ResourceLibrary.Get<InventoryItemDefinition>( "Items/Pijama.inv" )
Definition = ResourceLibrary.Get<ClothingItemDefinition>( "Items/cloth_pijama.clitem" )
} );
// Inventory.AddItem( new InventoryItem
// {
// Definition = ResourceLibrary.Get<BaseItemDefinition>( "Items/shorts_1.inv" )
// } );
Inventory.AddItem( new InventoryItem
{
Definition = ResourceLibrary.Get<InventoryItemDefinition>( "Items/shorts_1.inv" )
} );
Inventory.AddItem( new InventoryItem
{
Definition = ResourceLibrary.Get<InventoryItemDefinition>( "Items/pistol.inv" )
Definition = ResourceLibrary.Get<WeaponItemDefinition>( "Items/pistol_test.weapon" )
} );
var ammo = new InventoryItem
{
Definition = ResourceLibrary.Get<InventoryItemDefinition>( "Items/pistol_ammo.inv" )
Definition = ResourceLibrary.Get<BaseItemDefinition>( "Items/pistol_ammo.inv" )
};
ammo.Count = 30;
ammo.MaxCount = 130;
@ -46,17 +46,16 @@ public sealed partial class Dedugan : Component
private void OnItemEquipped( InventoryItem item )
{
if ( item.Definition.Prefab.IsValid() )
// Если это оружие
if ( item.Definition is WeaponItemDefinition weaponDef && weaponDef.Prefab.IsValid() )
{
var go = item.Definition.Prefab.Clone();
var go = weaponDef.Prefab.Clone();
AnimationHelper.HoldType = item.Definition.HoldType;
AnimationHelper.HoldType = weaponDef.HoldType;
switch ( item.Definition.Slot )
switch ( weaponDef.Slot )
{
case Inventar.InventorySlot.LeftHand | Inventar.InventorySlot.RightHand:
go.Parent = Renderer.GetAttachmentObject( "hold_R" );
break;
case Inventar.InventorySlot.RightHand:
go.Parent = Renderer.GetAttachmentObject( "hold_R" );
break;
@ -68,12 +67,12 @@ public sealed partial class Dedugan : Component
break;
}
go.LocalPosition = item.Definition.WeaponDefinition.Position;
go.LocalRotation = item.Definition.WeaponDefinition.Rotation;
go.LocalPosition = weaponDef.WeaponDefinition.Position;
go.LocalRotation = weaponDef.WeaponDefinition.Rotation;
go.NetworkSpawn();
var hand = item.Definition.Slot switch
var hand = weaponDef.Slot switch
{
Inventar.InventorySlot.LeftHand => CitizenAnimationHelper.Hand.Left,
Inventar.InventorySlot.RightHand => CitizenAnimationHelper.Hand.Right,
@ -81,37 +80,34 @@ public sealed partial class Dedugan : Component
_ => CitizenAnimationHelper.Hand.Both
};
AnimationHelper.HoldType = item.Definition.HoldType;
AnimationHelper.Handedness = hand;
RpcSetHoldAnimation( item.Definition.HoldType, hand );
RpcSetHoldAnimation( weaponDef.HoldType, hand );
InAds = true;
// item.SpawnedObject = go;
}
else
// Если это одежда
else if ( item.Definition is ClothingItemDefinition clothingDef )
{
WearWorkshop( new List<string>() { item.Definition.ClothUrl } );
WearWorkshop( new List<string>() { clothingDef.ClothUrl } );
}
}
private void OnItemUnEquipped( InventoryItem item )
{
if ( item.Definition.Prefab.IsValid() )
if ( item.Definition is WeaponItemDefinition weaponDef && weaponDef.Prefab.IsValid() )
{
switch ( item.Definition.Slot )
switch ( weaponDef.Slot )
{
case Inventar.InventorySlot.LeftHand | Inventar.InventorySlot.RightHand:
case Inventar.InventorySlot.RightHand:
case Inventar.InventorySlot.LeftHand:
var attachmentName = !item.Definition.Slot.HasFlag( Inventar.InventorySlot.RightHand )
var attachmentName = !weaponDef.Slot.HasFlag( Inventar.InventorySlot.RightHand )
? "hold_L"
: "hold_R";
Renderer.GetAttachmentObject( attachmentName ).Children.ForEach( child => child.Destroy() );
// AnimationHelper.Handedness = CitizenAnimationHelper.Hand.Both;
// AnimationHelper.HoldType = CitizenAnimationHelper.HoldTypes.None;
RpcSetHoldAnimation( CitizenAnimationHelper.HoldTypes.None, CitizenAnimationHelper.Hand.Both );
break;
default:
@ -120,15 +116,12 @@ public sealed partial class Dedugan : Component
break;
}
// item.SpawnedObject = null;
item.Destroy();
InAds = false;
}
else
else if ( item.Definition is ClothingItemDefinition clothingDef )
{
Log.Info( "STRIPPIN" );
StripByName( item.Definition.Name );
StripByName( clothingDef.Name );
}
}

View File

@ -81,27 +81,24 @@ partial class Dedugan
CancellationTokenSource _cts;
[Rpc.Broadcast]
public async void WearWorkshop( List<string> workshopItems )
public void WearWorkshop( List<string> workshopItems )
{
_cts = new CancellationTokenSource();
var token = _cts.Token;
// var clothing = new ClothingContainer();
// clothing.AddRange( Clothings );
if ( workshopItems != null && workshopItems.Count > 0 )
{
var tasks = workshopItems.Select( x => InstallWorkshopClothing( x, token ) );
foreach ( var task in tasks )
Task.WhenAll( workshopItems.Select( x => InstallWorkshopClothing( x, token ) ) )
.ContinueWith( ( tasks ) =>
{
var c = await task;
if ( c is null )
foreach ( var cloth in tasks.Result )
{
if ( cloth is null )
continue;
CurrentClothing.Add( c );
CurrentClothing.Add( cloth );
}
} );
}
CurrentClothing.Normalize();
@ -109,6 +106,31 @@ partial class Dedugan
Renderer.PostAnimationUpdate();
}
// public async void AsyncWearWorkshop( List<string> workshopItems )
// {
// _cts = new CancellationTokenSource();
// var token = _cts.Token;
//
// if ( workshopItems != null && workshopItems.Count > 0 )
// {
// var tasks = workshopItems.Select( x => InstallWorkshopClothing( x, token ) );
//
// foreach ( var task in tasks )
// {
// var c = await task;
//
// if ( c is null )
// continue;
//
// CurrentClothing.Add( c );
// }
// }
//
// CurrentClothing.Normalize();
// CurrentClothing.Apply( Renderer );
// Renderer.PostAnimationUpdate();
// }
[Rpc.Broadcast]
public void StripByName( string name )
{

View File

@ -12,6 +12,8 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AComponent_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F473df774ec844d1eb1dafe31862610eb433000_003F72_003Ff5d9e547_003FComponent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADresser_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F7fb6d2768e9860b6a8981bf396c4df97bf8ea33bd23971f6e86435b43e47ed_003FDresser_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADresser_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F7fb6d2768e9860b6a8981bf396c4df97bf8ea33bd23971f6e86435b43e47ed_003FDresser_002Ecs_002Fz_003A2_002D0/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADresser_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F7fb6d2768e9860b6a8981bf396c4df97bf8ea33bd23971f6e86435b43e47ed_003FDresser_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADresser_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fa59714cc5d0c63b6ceff5bd775714767c621e47fa2e5128a61ed1744b471cd_003FDresser_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADresser_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fa59714cc5d0c63b6ceff5bd775714767c621e47fa2e5128a61ed1744b471cd_003FDresser_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADspProcessor_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb259d6161b344f3994a9007e79ffb76e727000_003Ffb_003F1e5434fb_003FDspProcessor_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADspVolume_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F473df774ec844d1eb1dafe31862610eb433000_003Fda_003Fdddba176_003FDspVolume_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
@ -54,6 +56,8 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASoundStream_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb259d6161b344f3994a9007e79ffb76e727000_003F3a_003Fc0eb182e_003FSoundStream_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASound_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb259d6161b344f3994a9007e79ffb76e727000_003F76_003F66594b07_003FSound_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATaskSource_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F473df774ec844d1eb1dafe31862610eb433000_003F8b_003Fdeeb5f11_003FTaskSource_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATaskSource_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F5c273b394d658f37148cd88e3228ab4468afcdb966ace219ae286c2c2785e1_003FTaskSource_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATask_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa03380083db34a2faee436e29e06a72ae8e910_003Fe5_003F331495b0_003FTask_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATransform_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8b0e17316e2d4ddbbfdca978e2f684da72400_003Fa4_003F44ed21fc_003FTransform_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATriggerActionComponent_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F473df774ec844d1eb1dafe31862610eb433000_003Fdc_003Fc3ba20f2_003FTriggerActionComponent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AVertex_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa2b91d29af2c4b9ba9c9da5883394d0b2bf200_003F66_003Fdfd9a75e_003FVertex_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>