upd
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ) );
|
||||
Task.WhenAll( workshopItems.Select( x => InstallWorkshopClothing( x, token ) ) )
|
||||
.ContinueWith( ( tasks ) =>
|
||||
{
|
||||
foreach ( var cloth in tasks.Result )
|
||||
{
|
||||
if ( cloth is null )
|
||||
continue;
|
||||
|
||||
foreach ( var task in tasks )
|
||||
{
|
||||
var c = await task;
|
||||
|
||||
if ( c 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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user