mirror of
https://github.com/celisej567/gm_construct_port.git
synced 2026-01-05 06:10:06 +03:00
86 lines
2.2 KiB
C#
86 lines
2.2 KiB
C#
using Sandbox;
|
|
|
|
partial class SandboxPlayer
|
|
{
|
|
[ClientRpc]
|
|
private void BecomeRagdollOnClient( Vector3 velocity, DamageFlags damageFlags, Vector3 forcePos, Vector3 force, int bone )
|
|
{
|
|
var ent = new ModelEntity();
|
|
ent.Position = Position;
|
|
ent.Rotation = Rotation;
|
|
ent.Scale = Scale;
|
|
ent.MoveType = MoveType.Physics;
|
|
ent.UsePhysicsCollision = true;
|
|
ent.EnableAllCollisions = true;
|
|
ent.CollisionGroup = CollisionGroup.Debris;
|
|
ent.SetModel( GetModelName() );
|
|
ent.CopyBonesFrom( this );
|
|
ent.CopyBodyGroups( this );
|
|
ent.CopyMaterialGroup( this );
|
|
ent.TakeDecalsFrom( this );
|
|
ent.EnableHitboxes = true;
|
|
ent.EnableAllCollisions = true;
|
|
ent.SurroundingBoundsMode = SurroundingBoundsType.Physics;
|
|
ent.RenderColorAndAlpha = RenderColorAndAlpha;
|
|
ent.PhysicsGroup.Velocity = velocity;
|
|
|
|
if ( Local.Pawn == this )
|
|
{
|
|
//ent.EnableDrawing = false; wtf
|
|
}
|
|
|
|
ent.SetInteractsAs( CollisionLayer.Debris );
|
|
ent.SetInteractsWith( CollisionLayer.WORLD_GEOMETRY );
|
|
ent.SetInteractsExclude( CollisionLayer.Player | CollisionLayer.Debris );
|
|
|
|
foreach ( var child in Children )
|
|
{
|
|
if ( child is ModelEntity e )
|
|
{
|
|
var model = e.GetModelName();
|
|
if ( model != null && !model.Contains( "clothes" ) )
|
|
continue;
|
|
|
|
var clothing = new ModelEntity();
|
|
clothing.SetModel( model );
|
|
clothing.SetParent( ent, true );
|
|
clothing.RenderColorAndAlpha = e.RenderColorAndAlpha;
|
|
|
|
if ( Local.Pawn == this )
|
|
{
|
|
// clothing.EnableDrawing = false; wtf
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( damageFlags.HasFlag( DamageFlags.Bullet ) ||
|
|
damageFlags.HasFlag( DamageFlags.PhysicsImpact ) )
|
|
{
|
|
PhysicsBody body = bone > 0 ? ent.GetBonePhysicsBody( bone ) : null;
|
|
|
|
if ( body != null )
|
|
{
|
|
body.ApplyImpulseAt( forcePos, force * body.Mass );
|
|
}
|
|
else
|
|
{
|
|
ent.PhysicsGroup.ApplyImpulse( force );
|
|
}
|
|
}
|
|
|
|
if ( damageFlags.HasFlag( DamageFlags.Blast ) )
|
|
{
|
|
if ( ent.PhysicsGroup != null )
|
|
{
|
|
ent.PhysicsGroup.AddVelocity( (Position - (forcePos + Vector3.Down * 100.0f)).Normal * (force.Length * 0.2f) );
|
|
var angularDir = (Rotation.FromYaw( 90 ) * force.WithZ( 0 ).Normal).Normal;
|
|
ent.PhysicsGroup.AddAngularVelocity( angularDir * (force.Length * 0.02f) );
|
|
}
|
|
}
|
|
|
|
Corpse = ent;
|
|
|
|
ent.DeleteAsync( 10.0f );
|
|
}
|
|
}
|