コード例 #1
0
        /// <summary>
        /// This entity has become the active entity. This most likely
        /// means a player was carrying it in their inventory and now
        /// has it in their hands.
        /// </summary>
        public override void ActiveStart(Entity ent)
        {
            base.ActiveStart(ent);

            EnableDrawing = true;

            if (ent is Player player)
            {
                var animator = player.GetActiveAnimator();
                if (animator != null)
                {
                    TickPlayerAnimator(animator);
                }
            }

            //
            // If we're the local player (clientside) create viewmodel
            // and any HUD elements that this weapon wants
            //
            if (HasLocalPlayerOwner)
            {
                DestroyViewModel();
                DestroyHudElements();

                CreateViewModel();
                CreateHudElements();

                ViewModelEntity?.SetAnimParam("deploy", true);
            }
        }
コード例 #2
0
        public virtual void ShootEffects(int clipInfoIndex)
        {
            Host.AssertClient();

            if (clipInfoIndex < 0 || clipInfoIndex >= ClipInfos.Length)
            {
                return;
            }

            ClipInfo clipInfo = ClipInfos[clipInfoIndex];

            if (clipInfo == null)
            {
                return;
            }

            if (CarriableInfo.Category != CarriableCategories.Melee)
            {
                foreach (KeyValuePair <string, string> keyValuePair in clipInfo.ShootEffectList)
                {
                    Particles.Create(keyValuePair.Key, EffectEntity, keyValuePair.Value);
                }
            }

            if (IsLocalPawn && clipInfo.ShakeEffect != null)
            {
                _ = new Perlin(clipInfo.ShakeEffect.Length, clipInfo.ShakeEffect.Speed, clipInfo.ShakeEffect.Size, clipInfo.ShakeEffect.Rotation);
            }

            ViewModelEntity?.SetAnimParameter("fire", true);
            CrosshairPanel?.CreateEvent("fire");
        }
コード例 #3
0
ファイル: Flashlight.cs プロジェクト: JustPlayerDE/sandbox
    public override void Simulate(Client cl)
    {
        if (cl == null)
        {
            return;
        }

        var  input  = Input;
        bool toggle = input.Pressed(InputButton.Flashlight) || input.Pressed(InputButton.Attack1);

        if (timeSinceLightToggled > 0.1f && toggle)
        {
            LightEnabled = !LightEnabled;

            PlaySound(LightEnabled ? "flashlight-on" : "flashlight-off");

            if (worldLight.IsValid())
            {
                worldLight.Enabled = LightEnabled;
            }

            if (viewLight.IsValid())
            {
                viewLight.Enabled = LightEnabled;
            }

            timeSinceLightToggled = 0;
        }

        if (IsClient && input.Pressed(InputButton.Attack2))
        {
            ViewModelEntity?.SetAnimBool("admire", true);
        }
    }
コード例 #4
0
    public override void OnPlayerControlTick(Player owner)
    {
        if (owner == null)
        {
            return;
        }

        var  input  = owner.Input;
        bool toggle = input.Pressed(InputButton.Flashlight) || input.Pressed(InputButton.Attack1);

        if (timeSinceLightToggled > 0.1f && toggle)
        {
            LightEnabled = !LightEnabled;

            PlaySound(LightEnabled ? "flashlight-on" : "flashlight-off");

            if (worldLight.IsValid())
            {
                worldLight.Enabled = LightEnabled;
            }

            if (viewLight.IsValid())
            {
                viewLight.Enabled = LightEnabled;
            }

            timeSinceLightToggled = 0;
        }

        if (IsClient && input.Pressed(InputButton.Attack2))
        {
            ViewModelEntity?.SetAnimParam("admire", true);
        }
    }
コード例 #5
0
    private void OnMeleeHit(bool leftHand)
    {
        Host.AssertClient();

        ViewModelEntity?.SetAnimParameter("attack_has_hit", true);
        ViewModelEntity?.SetAnimParameter("attack", true);
        ViewModelEntity?.SetAnimParameter("holdtype_attack", leftHand ? 2 : 1);
    }
コード例 #6
0
ファイル: DmWeapon.cs プロジェクト: UAVXP/dm98
    protected virtual void ShootEffects()
    {
        Host.AssertClient();

        PlaySound("rust_pistol.shoot");
        Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");

        ViewModelEntity?.SetAnimParam("fire", true);
    }
コード例 #7
0
ファイル: Shotgun.cs プロジェクト: UAVXP/dm98
    protected override void ShootEffects()
    {
        Host.AssertClient();

        PlaySound("rust_pumpshotgun.shoot");
        Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");
        Particles.Create("particles/pistol_ejectbrass.vpcf", EffectEntity, "ejection_point");

        ViewModelEntity?.SetAnimParam("fire", true);
    }
コード例 #8
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            if (IsClient && ViewModelEntity.IsValid())
            {
                DestroyViewModel();
                DestroyHudElements();
            }
        }
コード例 #9
0
    public override void SimulateAnimator(PawnAnimator anim)
    {
        anim.SetAnimParameter("holdtype", 5);
        anim.SetAnimParameter("aim_body_weight", 1.0f);

        if (Owner.IsValid())
        {
            ViewModelEntity?.SetAnimParameter("b_grounded", Owner.GroundEntity.IsValid());
            ViewModelEntity?.SetAnimParameter("aim_pitch", Owner.EyeRotation.Pitch());
        }
    }
コード例 #10
0
ファイル: Flashlight.cs プロジェクト: Facepunch/sandbox
    private void OnMeleeHit()
    {
        Host.AssertClient();

        if (IsLocalPawn)
        {
            _ = new Sandbox.ScreenShake.Perlin(1.0f, 1.0f, 3.0f);
        }

        ViewModelEntity?.SetAnimParameter("attack_hit", true);
    }
コード例 #11
0
ファイル: Crossbow.cs プロジェクト: Redhacker1/dm98
        protected override void ShootEffects()
        {
            Host.AssertClient();

            if (Owner == Local.Pawn)
            {
                new Perlin(0.5f, 4.0f, 1.0f, 0.5f);
            }

            ViewModelEntity?.SetAnimBool("fire", true);
            CrosshairPanel?.CreateEvent("fire");
        }
コード例 #12
0
ファイル: Crossbow.cs プロジェクト: zct8002/dm98
    protected override void ShootEffects()
    {
        Host.AssertClient();

        if (Owner == Player.Local)
        {
            new Sandbox.ScreenShake.Perlin(0.5f, 4.0f, 1.0f, 0.5f);
        }

        ViewModelEntity?.SetAnimParam("fire", true);
        CrosshairPanel?.OnEvent("fire");
    }
コード例 #13
0
    protected virtual void ShootEffects()
    {
        Host.AssertClient();

        Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");

        if (IsLocalPawn)
        {
            _ = new Sandbox.ScreenShake.Perlin();
        }

        ViewModelEntity?.SetAnimParameter("fire", true);
        CrosshairPanel?.CreateEvent("fire");
    }
コード例 #14
0
    protected virtual void DoubleShootEffects()
    {
        Host.AssertClient();

        Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");

        ViewModelEntity?.SetAnimParam("fire_double", true);
        CrosshairPanel?.OnEvent("fire");

        if (Owner == Player.Local)
        {
            new Sandbox.ScreenShake.Perlin(3.0f, 3.0f, 3.0f);
        }
    }
コード例 #15
0
        public virtual void ClientFinishReload(int clipInfoIndex)
        {
            if (clipInfoIndex < 0 || clipInfoIndex >= ClipInfos.Length)
            {
                return;
            }

            ClipInfo clipInfo = ClipInfos[clipInfoIndex];

            if (!string.IsNullOrEmpty(clipInfo.ViewModelReloadFinishAnim))
            {
                ViewModelEntity?.SetAnimParameter(clipInfo.ViewModelReloadFinishAnim, true);
            }
        }
コード例 #16
0
ファイル: Shotgun.cs プロジェクト: Redhacker1/dm98
        protected virtual void DoubleShootEffects()
        {
            Host.AssertClient();

            Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");

            ViewModelEntity?.SetAnimBool("fire_double", true);
            CrosshairPanel?.CreateEvent("fire");

            if (IsLocalPawn)
            {
                new Perlin(3.0f, 3.0f, 3.0f);
            }
        }
コード例 #17
0
    protected virtual void ShootEffects()
    {
        Host.AssertClient();

        PlaySound("rust_pistol.shoot");
        Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");

        if (Owner == Player.Local)
        {
            new Sandbox.ScreenShake.Perlin();
        }

        ViewModelEntity?.SetAnimParam("fire", true);
    }
コード例 #18
0
        //
        // Shotgun-specific reload.
        // Loads one shell at a time. Lets you pause the reload to shoot in-between shells.
        //
        public override void OnReloadFinish()
        {
            IsReloading            = false;
            TimeSincePrimaryAttack = 0;

            // Local functions are ass but this is super useful
            void Finished() => ViewModelEntity?.SetAnimParam("reload_finished", true);

            // Do we have a full mag?
            if (AmmoClip >= ClipSize)
            {
                Finished();                 // Yeah, f**k off
                return;
            }

            // Do we even have ammo?
            if (AvailableAmmo() != 0)
            {
                // There's ammo, take it
                AmmoClip++;
                ReserveAmmo--;
            }
            else
            {
                // No ammo, f**k off
                Finished();
                return;
            }

            // Janky way to pause reloads if we're between shells
            if (Owner.Input.Down(InputButton.Attack1))
            {
                Finished();
                return;
            }

            // Have we finished reloading?
            if (AmmoClip < ClipSize && AvailableAmmo() > 0)
            {
                // No, let's take another shell
                Reload();
            }
            else
            {
                // Yeah, f**k off
                Finished();
                return;
            }
        }
コード例 #19
0
    protected override void ShootEffects()
    {
        Host.AssertClient();

        PlaySound("rust_smg.shoot");
        Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");
        Particles.Create("particles/pistol_ejectbrass.vpcf", EffectEntity, "ejection_point");

        if (Owner == Player.Local)
        {
            new Sandbox.ScreenShake.Perlin(0.5f, 4.0f, 1.0f, 0.5f);
        }

        ViewModelEntity?.SetAnimParam("fire", true);
    }
コード例 #20
0
    protected override void ShootEffects()
    {
        Host.AssertClient();

        Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");
        Particles.Create("particles/pistol_ejectbrass.vpcf", EffectEntity, "ejection_point");

        if (Owner == Local.Pawn)
        {
            new Sandbox.ScreenShake.Perlin(0.5f, 4.0f, 1.0f, 0.5f);
        }

        ViewModelEntity?.SetAnimParameter("fire", true);
        CrosshairPanel?.CreateEvent("fire");
    }
コード例 #21
0
        protected virtual void ShootEffects()
        {
            Host.AssertClient();

            Log.Info($"{EffectEntity} {ViewModelEntity} {IsFirstPersonMode} {CurrentView.Viewer} parent:{Parent}");
            Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");

            if (IsLocalPawn)
            {
                new Sandbox.ScreenShake.Perlin();
            }

            ViewModelEntity?.SetAnimBool("fire", true);
            CrosshairPanel?.OnEvent("fire");
        }
コード例 #22
0
        protected override void ShootEffects()
        {
            Host.AssertClient();

            Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");
            Particles.Create("particles/pistol_ejectbrass.vpcf", EffectEntity, "ejection_point");

            ViewModelEntity?.SetAnimParam("fire", true);

            if (Owner == Player.Local)
            {
                _ = new Sandbox.ScreenShake.Perlin(1.0f, 1.5f, 2.0f);
            }

            CrosshairPanel?.OnEvent("fire");
        }
コード例 #23
0
ファイル: Shotgun.cs プロジェクト: Redhacker1/dm98
        protected override void ShootEffects()
        {
            Host.AssertClient();

            Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");
            Particles.Create("particles/pistol_ejectbrass.vpcf", EffectEntity, "ejection_point");

            ViewModelEntity?.SetAnimBool("fire", true);

            if (IsLocalPawn)
            {
                new Perlin(1.0f, 1.5f, 2.0f);
            }

            CrosshairPanel?.CreateEvent("fire");
        }
コード例 #24
0
    public virtual void ShootEffects()
    {
        Host.AssertClient();

        var  muzzle  = EffectEntity.GetAttachment("muzzle");
        bool InWater = Physics.TestPointContents(muzzle.Pos, CollisionLayer.Water);

        Sound.FromEntity("rust_pistol.shoot", this);
        Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");

        ViewModelEntity?.SetAnimParam("fire", true);
        CrosshairPanel?.OnEvent("onattack");

        if (Owner == Player.Local)
        {
            new Sandbox.ScreenShake.Perlin(0.5f, 2.0f, 0.5f);
        }
    }
コード例 #25
0
    protected override void ShootEffects()
    {
        Host.AssertClient();

        var muzzle = EffectEntity.GetAttachment("muzzle");

        //bool InWater = Physics.TestPointContents( muzzle.Pos, CollisionLayer.Water );
        Sound.FromEntity(AttackSound.Name, this);

        Particles.Create("particles/balloon_grenade_launcher_muzzle.vpcf", EffectEntity, "muzzle");
        ViewModelEntity?.SetAnimParam("fire", true);
        CrosshairPanel?.OnEvent("onattack");

        if (Owner == Local.Client)
        {
            new Sandbox.ScreenShake.Perlin(0.5f, 2.0f, 0.5f);
        }
    }
コード例 #26
0
ファイル: DmWeapon.cs プロジェクト: Redhacker1/dm98
        protected virtual void ShootEffects()
        {
            Host.AssertClient();

            var particle = Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");
            var Light    = new Light(EffectEntity.Position, 1000, Color.Yellow * 100);

            //EffectEntity.AddChild(Light);


            if (IsLocalPawn)
            {
                new Perlin();
            }

            ViewModelEntity?.SetAnimBool("fire", true);
            CrosshairPanel?.CreateEvent("fire");

            HandleLight(Light);
        }
コード例 #27
0
 protected virtual void FinishReload()
 {
     ViewModelEntity?.SetAnimParam("reload_finished", true);
 }
コード例 #28
0
ファイル: Gun.cs プロジェクト: niederschlag/sandbox
    public override void Reload()
    {
        base.Reload();

        ViewModelEntity?.SetAnimParam("reload", true);
    }
コード例 #29
0
ファイル: ProphuntWeapon.cs プロジェクト: rtm516/Prophunt
 public virtual void DryFire()
 {
     ViewModelEntity?.SetAnimBool("dryfire", true);
 }
コード例 #30
0
    public virtual void StartReloadEffects()
    {
        ViewModelEntity?.SetAnimParameter("reload", true);

        // TODO - player third person model reload
    }