sasalka/Code/Weapons/PhysBullet.cs
2025-06-08 23:47:32 +03:00

61 lines
1.4 KiB
C#

public sealed class PhysBullet : Component, Component.ICollisionListener
{
[Property] public Collider collider { get; set; }
[Property] public Rigidbody BRigidbody { get; set; }
protected override async void OnStart()
{
if ( collider != null )
{
collider.OnTriggerEnter += OnTriggerEnter;
}
await Task.DelaySeconds( 5 );
GameObject.Destroy();
}
protected override void OnUpdate()
{
}
async void ICollisionListener.OnCollisionStart( Collision collision )
{
await Task.DelaySeconds( 1 );
GameObject.Destroy();
}
// var a= Scene.Trace.Ray( collision.Contact.Point, collision.Contact.Point + collision.Contact.Normal * 10 ).Run();
// Log.Info(collision.Other.GameObject);
// Log.Info(a.GameObject);
// DebugOverlay.Line(a.StartPosition,a.EndPosition, duration: 5.5f);
// DestroyGameObject();
public void OnTriggerEnter( Collider other )
{
var components = other.Components;
if ( components.TryGet<RagdollController>( out var controller ) )
{
if ( Network.IsOwner )
return;
controller.Enabled = true;
// ModelHitboxes sas = controller.Components.Get<ModelHitboxes>();
// collider.FindClosestPoint(other.WorldPosition);
// var d = controller.GameObject.GetComponent<Dedugan>();
//
// d.Controller.Velocity = Vector3.Up * 2500;
// rb.MassOverride = 500f;
//
// rb.ApplyImpulse( Vector3.Up * 5000000 );
// rb.Destroy();
// controller.bodyPhysics.
}
}
}