upd
This commit is contained in:
@@ -21,6 +21,11 @@ public sealed partial class Dedugan : Component
|
||||
Definition = ResourceLibrary.Get<InventoryItemDefinition>( "Items/Pijama.inv" )
|
||||
} );
|
||||
|
||||
Inventory.AddItem( new InventoryItem
|
||||
{
|
||||
Definition = ResourceLibrary.Get<InventoryItemDefinition>( "Items/shorts_1.inv" )
|
||||
} );
|
||||
|
||||
Inventory.AddItem( new InventoryItem
|
||||
{
|
||||
Definition = ResourceLibrary.Get<InventoryItemDefinition>( "Items/pistol.inv" )
|
||||
@@ -41,93 +46,90 @@ public sealed partial class Dedugan : Component
|
||||
|
||||
private void OnItemEquipped( InventoryItem item )
|
||||
{
|
||||
var go = item.Definition.Prefab.Clone();
|
||||
|
||||
AnimationHelper.HoldType = item.Definition.HoldType;
|
||||
|
||||
// switch ( item.Definition.Slot )
|
||||
// {
|
||||
// case Inventar.InventorySlot.LeftHand | Inventar.InventorySlot.RightHand:
|
||||
// go.Parent = Renderer.GetAttachmentObject( "hold_R" );
|
||||
// AnimationHelper.Handedness = CitizenAnimationHelper.Hand.Both;
|
||||
// break;
|
||||
// case Inventar.InventorySlot.RightHand:
|
||||
// go.Parent = Renderer.GetAttachmentObject( "hold_R" );
|
||||
// AnimationHelper.Handedness = CitizenAnimationHelper.Hand.Right;
|
||||
// break;
|
||||
// case Inventar.InventorySlot.LeftHand:
|
||||
// go.Parent = Renderer.GetAttachmentObject( "hold_L" );
|
||||
// AnimationHelper.Handedness = CitizenAnimationHelper.Hand.Left;
|
||||
// break;
|
||||
// default:
|
||||
// go.Parent = Renderer.GetAttachmentObject( "forward_reference_modelspace" );
|
||||
// break;
|
||||
// }
|
||||
switch ( item.Definition.Slot )
|
||||
if ( item.Definition.Prefab.IsValid() )
|
||||
{
|
||||
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;
|
||||
case Inventar.InventorySlot.LeftHand:
|
||||
go.Parent = Renderer.GetAttachmentObject( "hold_L" );
|
||||
break;
|
||||
default:
|
||||
go.Parent = Renderer.GetAttachmentObject( "forward_reference_modelspace" );
|
||||
break;
|
||||
var go = item.Definition.Prefab.Clone();
|
||||
|
||||
AnimationHelper.HoldType = item.Definition.HoldType;
|
||||
|
||||
switch ( item.Definition.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;
|
||||
case Inventar.InventorySlot.LeftHand:
|
||||
go.Parent = Renderer.GetAttachmentObject( "hold_L" );
|
||||
break;
|
||||
default:
|
||||
go.Parent = Renderer.GetAttachmentObject( "forward_reference_modelspace" );
|
||||
break;
|
||||
}
|
||||
|
||||
go.LocalPosition = item.Definition.WeaponDefinition.Position;
|
||||
go.LocalRotation = item.Definition.WeaponDefinition.Rotation;
|
||||
|
||||
go.NetworkSpawn();
|
||||
|
||||
var hand = item.Definition.Slot switch
|
||||
{
|
||||
Inventar.InventorySlot.LeftHand => CitizenAnimationHelper.Hand.Left,
|
||||
Inventar.InventorySlot.RightHand => CitizenAnimationHelper.Hand.Right,
|
||||
Inventar.InventorySlot.LeftHand | Inventar.InventorySlot.RightHand => CitizenAnimationHelper.Hand.Both,
|
||||
_ => CitizenAnimationHelper.Hand.Both
|
||||
};
|
||||
|
||||
AnimationHelper.HoldType = item.Definition.HoldType;
|
||||
AnimationHelper.Handedness = hand;
|
||||
|
||||
RpcSetHoldAnimation( item.Definition.HoldType, hand );
|
||||
|
||||
InAds = true;
|
||||
// item.SpawnedObject = go;
|
||||
}
|
||||
|
||||
go.LocalPosition = item.Definition.WeaponDefinition.Position;
|
||||
go.LocalRotation = item.Definition.WeaponDefinition.Rotation;
|
||||
|
||||
go.NetworkSpawn();
|
||||
|
||||
var hand = item.Definition.Slot switch
|
||||
else
|
||||
{
|
||||
Inventar.InventorySlot.LeftHand => CitizenAnimationHelper.Hand.Left,
|
||||
Inventar.InventorySlot.RightHand => CitizenAnimationHelper.Hand.Right,
|
||||
Inventar.InventorySlot.LeftHand | Inventar.InventorySlot.RightHand => CitizenAnimationHelper.Hand.Both,
|
||||
_ => CitizenAnimationHelper.Hand.Both
|
||||
};
|
||||
|
||||
AnimationHelper.HoldType = item.Definition.HoldType;
|
||||
AnimationHelper.Handedness = hand;
|
||||
|
||||
RpcSetHoldAnimation( item.Definition.HoldType, hand );
|
||||
|
||||
InAds = true;
|
||||
// item.SpawnedObject = go;
|
||||
WearWorkshop( new List<string>() { item.Definition.ClothUrl } );
|
||||
}
|
||||
}
|
||||
|
||||
private void OnItemUnEquipped( InventoryItem item )
|
||||
{
|
||||
switch ( item.Definition.Slot )
|
||||
if ( item.Definition.Prefab.IsValid() )
|
||||
{
|
||||
case Inventar.InventorySlot.LeftHand | Inventar.InventorySlot.RightHand:
|
||||
case Inventar.InventorySlot.RightHand:
|
||||
case Inventar.InventorySlot.LeftHand:
|
||||
var attachmentName = !item.Definition.Slot.HasFlag( Inventar.InventorySlot.RightHand )
|
||||
? "hold_L"
|
||||
: "hold_R";
|
||||
switch ( item.Definition.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 )
|
||||
? "hold_L"
|
||||
: "hold_R";
|
||||
|
||||
Renderer.GetAttachmentObject( attachmentName ).Children.ForEach( child => child.Destroy() );
|
||||
// AnimationHelper.Handedness = CitizenAnimationHelper.Hand.Both;
|
||||
// AnimationHelper.HoldType = CitizenAnimationHelper.HoldTypes.None;
|
||||
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:
|
||||
Renderer.GetAttachmentObject( "forward_reference_modelspace" ).Children
|
||||
.ForEach( child => child.Destroy() );
|
||||
break;
|
||||
RpcSetHoldAnimation( CitizenAnimationHelper.HoldTypes.None, CitizenAnimationHelper.Hand.Both );
|
||||
break;
|
||||
default:
|
||||
Renderer.GetAttachmentObject( "forward_reference_modelspace" ).Children
|
||||
.ForEach( child => child.Destroy() );
|
||||
break;
|
||||
}
|
||||
|
||||
// item.SpawnedObject = null;
|
||||
item.Destroy();
|
||||
|
||||
InAds = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info( "STRIPPIN" );
|
||||
StripByName( item.Definition.Name );
|
||||
}
|
||||
|
||||
// item.SpawnedObject = null;
|
||||
item.Destroy();
|
||||
|
||||
InAds = false;
|
||||
}
|
||||
|
||||
[Rpc.Broadcast]
|
||||
|
||||
@@ -76,12 +76,11 @@ partial class Dedugan
|
||||
|
||||
CurrentClothing.Clothing.RemoveAll( entry => !allowedCategories.Contains( entry.Clothing.Category ) );
|
||||
CurrentClothing.Apply( Renderer );
|
||||
|
||||
WearWorkshop( WorkshopItems );
|
||||
}
|
||||
|
||||
CancellationTokenSource _cts;
|
||||
|
||||
[Rpc.Broadcast]
|
||||
public async void WearWorkshop( List<string> workshopItems )
|
||||
{
|
||||
_cts = new CancellationTokenSource();
|
||||
@@ -108,11 +107,24 @@ partial class Dedugan
|
||||
CurrentClothing.Normalize();
|
||||
CurrentClothing.Apply( Renderer );
|
||||
Renderer.PostAnimationUpdate();
|
||||
}
|
||||
|
||||
// foreach ( var clothing in CurrentClothing.Clothing )
|
||||
// {
|
||||
// Log.Info( clothing.Clothing.Title );
|
||||
// }
|
||||
[Rpc.Broadcast]
|
||||
public void StripByName( string name )
|
||||
{
|
||||
CurrentClothing.Clothing.RemoveAll( entry => entry.Clothing.Title == name );
|
||||
|
||||
CurrentClothing.Normalize();
|
||||
CurrentClothing.Apply( Renderer );
|
||||
Renderer.PostAnimationUpdate();
|
||||
}
|
||||
|
||||
|
||||
public void CancelDressing()
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_cts?.Dispose();
|
||||
_cts = default;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ public sealed class RagdollController : Component
|
||||
[Group( "Config" ), Order( 0 ), Property]
|
||||
public bool isLocked { get; set; }
|
||||
|
||||
public float size { get; set; }
|
||||
|
||||
[Sync]
|
||||
public new bool Enabled
|
||||
{
|
||||
@@ -27,10 +29,11 @@ public sealed class RagdollController : Component
|
||||
|
||||
if ( !value )
|
||||
{
|
||||
// size = bodyRenderer.Parameters.GetFloat( "scale_height" );
|
||||
WorldPosition = bodyRenderer.WorldPosition;
|
||||
bodyRenderer.LocalPosition = Vector3.Zero;
|
||||
|
||||
bodyRenderer.ClearParameters();
|
||||
// bodyRenderer.ClearParameters();
|
||||
bodyRenderer.ClearPhysicsBones();
|
||||
}
|
||||
}
|
||||
@@ -60,7 +63,7 @@ public sealed class RagdollController : Component
|
||||
bodyLock.X = isLocked;
|
||||
bodyLock.Y = isLocked;
|
||||
bodyLock.Z = isLocked;
|
||||
|
||||
|
||||
bodyPhysics.Locking = bodyLock;
|
||||
bodyPhysics.MotionEnabled = !isLocked;
|
||||
WorldPosition = bodyRenderer.WorldPosition;
|
||||
|
||||
Reference in New Issue
Block a user