This commit is contained in:
Oscar
2025-06-10 02:09:21 +03:00
parent 38754d2b59
commit 6e784491fd
34 changed files with 1429 additions and 574 deletions

View File

@@ -1,23 +1,20 @@
using System.Threading.Tasks;
using Sasalka;
namespace Sandbox.Weapons;
public sealed class Weapon : Component
public sealed class Weapon : AmmoUseableBase
{
[Property] public SkinnedModelRenderer GunRenderer { get; private set; }
[Property] public GameObject BulletOut { get; private set; }
[Property] public GameObject MuzzleLight { get; private set; }
[Property] public GameObject particlePrefab { get; set; }
[Property] public GameObject bloodParticle { get; set; }
[Property] public DecalDefinition ImpactDecal { get; set; }
[Property] public SoundEvent ImpactSound { get; set; }
private SoundPointComponent _sound;
protected override void OnStart()
{
base.OnStart();
_sound = GameObject.GetComponent<SoundPointComponent>( true );
}
@@ -36,32 +33,30 @@ public sealed class Weapon : Component
.UseHitboxes()
.Run();
Log.Info( Dedugan.Local.GameObject );
if (tr.Hit && tr.Hitbox != null)
if ( tr.Hit && tr.Hitbox != null )
{
var components = tr.GameObject.Components;
var boneIndex = tr.Hitbox.Bone.Index;
// Log.Info($"{tr.GameObject.Name} attacked");
var dedugan = components.Get<Dedugan>();
var enemy = components.Get<Enemy>();
if (dedugan.IsValid() || enemy.IsValid())
if ( dedugan.IsValid() || enemy.IsValid() )
{
CreateHitEffects(tr.EndPosition, tr.Normal, true);
CreateHitEffects( tr.EndPosition, tr.Normal, true );
}
if (dedugan.IsValid())
if ( dedugan.IsValid() )
{
dedugan.ReportHit(dir, boneIndex);
dedugan.ReportHit( dir, boneIndex );
}
if (enemy.IsValid())
if ( enemy.IsValid() )
{
enemy.ReportHit(dir, boneIndex);
Log.Info(boneIndex);
enemy.ReportHit( dir, boneIndex );
Log.Info( boneIndex );
}
}
else if ( tr.Hitbox == null )
@@ -100,4 +95,9 @@ public sealed class Weapon : Component
await GameTask.DelaySeconds( 0.05f );
MuzzleLight.Enabled = false;
}
protected override void OnUse()
{
Attack();
}
}