52 lines
1.0 KiB
C#
52 lines
1.0 KiB
C#
using Sandbox.Citizen;
|
|
using Sandbox.Weapons;
|
|
|
|
public sealed partial class Dedugan
|
|
{
|
|
[Property] public GameObject Gun { get; set; }
|
|
[Sync] private bool InAds { get; set; } = false;
|
|
|
|
private Weapon _weapon { get; set; }
|
|
|
|
void WeaponStart()
|
|
{
|
|
_weapon = Gun.Components.Get<Weapon>(FindMode.EverythingInSelfAndDescendants );
|
|
|
|
Log.Info( $"_weapon: {_weapon}, Network.IsOwner: {Network.IsOwner}" );
|
|
}
|
|
|
|
[Rpc.Broadcast]
|
|
void Attack()
|
|
{
|
|
Renderer.Set( "b_attack", true );
|
|
}
|
|
|
|
void WeaponUpdate()
|
|
{
|
|
if ( InAds )
|
|
{
|
|
AnimationHelper.Handedness = CitizenAnimationHelper.Hand.Right;
|
|
AnimationHelper.HoldType = CitizenAnimationHelper.HoldTypes.Pistol;
|
|
|
|
Gun.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
AnimationHelper.Handedness = CitizenAnimationHelper.Hand.Both;
|
|
AnimationHelper.HoldType = CitizenAnimationHelper.HoldTypes.None;
|
|
|
|
Gun.Enabled = false;
|
|
}
|
|
|
|
if ( !Network.IsOwner ) return;
|
|
|
|
InAds = Input.Down( "Attack2" );
|
|
|
|
if ( Input.Pressed( "Attack1" ) && InAds )
|
|
{
|
|
_weapon.Attack();
|
|
Attack();
|
|
}
|
|
}
|
|
}
|