/// <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); } }
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"); }
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); } }
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); } }
private void OnMeleeHit(bool leftHand) { Host.AssertClient(); ViewModelEntity?.SetAnimParameter("attack_has_hit", true); ViewModelEntity?.SetAnimParameter("attack", true); ViewModelEntity?.SetAnimParameter("holdtype_attack", leftHand ? 2 : 1); }
protected virtual void ShootEffects() { Host.AssertClient(); PlaySound("rust_pistol.shoot"); Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle"); ViewModelEntity?.SetAnimParam("fire", true); }
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); }
protected override void OnDestroy() { base.OnDestroy(); if (IsClient && ViewModelEntity.IsValid()) { DestroyViewModel(); DestroyHudElements(); } }
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()); } }
private void OnMeleeHit() { Host.AssertClient(); if (IsLocalPawn) { _ = new Sandbox.ScreenShake.Perlin(1.0f, 1.0f, 3.0f); } ViewModelEntity?.SetAnimParameter("attack_hit", true); }
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"); }
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"); }
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"); }
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); } }
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); } }
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); } }
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); }
// // 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; } }
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); }
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"); }
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"); }
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"); }
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"); }
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); } }
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); } }
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); }
protected virtual void FinishReload() { ViewModelEntity?.SetAnimParam("reload_finished", true); }
public override void Reload() { base.Reload(); ViewModelEntity?.SetAnimParam("reload", true); }
public virtual void DryFire() { ViewModelEntity?.SetAnimBool("dryfire", true); }
public virtual void StartReloadEffects() { ViewModelEntity?.SetAnimParameter("reload", true); // TODO - player third person model reload }