Russian roulette now ends after a player dies. Still need to let the minigame manager know and add logic for moving to the next game, cleanup, ending a round, etc
This commit is contained in:
@@ -58,6 +58,7 @@ public partial class Pawn : AnimatedEntity
|
||||
|
||||
[BindComponent] public UserPawnController Controller { get; }
|
||||
[BindComponent] public PawnAnimator Animator { get; }
|
||||
[BindComponent] public PawnInventory Inventory { get; }
|
||||
|
||||
public override Ray AimRay => new Ray( EyePosition, EyeRotation.Forward );
|
||||
|
||||
@@ -71,12 +72,7 @@ public partial class Pawn : AnimatedEntity
|
||||
EnableDrawing = true;
|
||||
EnableHideInFirstPerson = true;
|
||||
EnableShadowInFirstPerson = true;
|
||||
}
|
||||
|
||||
public void Respawn()
|
||||
{
|
||||
Components.Create<UserPawnController>();
|
||||
Components.Create<PawnAnimator>();
|
||||
SetupPhysicsFromModel( PhysicsMotionType.Keyframed );
|
||||
}
|
||||
|
||||
public void DressFromClient( IClient cl )
|
||||
@@ -91,6 +87,7 @@ public partial class Pawn : AnimatedEntity
|
||||
SimulateRotation();
|
||||
Controller?.Simulate( cl );
|
||||
Animator?.Simulate();
|
||||
Inventory?.ActiveWeapon?.Simulate( cl );
|
||||
}
|
||||
|
||||
public override void BuildInput()
|
||||
@@ -130,4 +127,15 @@ public partial class Pawn : AnimatedEntity
|
||||
EyeRotation = Rotation.Slerp( Rotation, idealRotation, Time.Delta * 10f );
|
||||
Rotation = EyeRotation;
|
||||
}
|
||||
|
||||
public void LookAt( Vector3 position )
|
||||
{
|
||||
Rotation = Rotation.LookAt( (position - this.Position).Normal, Vector3.Up );
|
||||
EyePosition = position;
|
||||
}
|
||||
|
||||
public override void TakeDamage( DamageInfo info )
|
||||
{
|
||||
base.TakeDamage( info );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public partial class RoundManager : Entity
|
||||
/// <summary>
|
||||
/// The number of seconds from the timer starting before the round starts
|
||||
/// </summary>
|
||||
private const float RoundStartCountdownSeconds = 10f;
|
||||
private const float RoundStartCountdownSeconds = 5f;
|
||||
|
||||
/// <summary>
|
||||
/// The state of the current round
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Sandbox;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -26,6 +27,9 @@ public partial class Weapon : AnimatedEntity
|
||||
public virtual string ReloadAnimPath => "reload";
|
||||
public virtual string WeaponName => "weapon";
|
||||
public virtual float ReloadDuration => 4f;
|
||||
public virtual CitizenAnimationHelper.HoldTypes HoldType { get; }
|
||||
protected virtual List<string> HitTags => new List<string> { "solid", "player", "npc" };
|
||||
protected virtual float Damage => 20f;
|
||||
private bool Reloading => TimeSinceReloadStarted < ReloadDuration;
|
||||
|
||||
/// <summary>
|
||||
@@ -68,6 +72,7 @@ public partial class Weapon : AnimatedEntity
|
||||
SetParent( pawn, true );
|
||||
EnableDrawing = true;
|
||||
CreateViewModel( To.Single( pawn ) );
|
||||
pawn.SetAnimParameter( "holdtype", (int)HoldType );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,6 +82,7 @@ public partial class Weapon : AnimatedEntity
|
||||
{
|
||||
EnableDrawing = false;
|
||||
DestroyViewModel( To.Single( Owner ) );
|
||||
Pawn.SetAnimParameter( "holdtype", (int)CitizenAnimationHelper.HoldTypes.None );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -128,7 +134,7 @@ public partial class Weapon : AnimatedEntity
|
||||
/// <returns></returns>
|
||||
public virtual bool CanPrimaryAttack()
|
||||
{
|
||||
if ( !Owner.IsValid() || !Input.Down( "attack1" ) || Ammo == 0 || Reloading ) return false;
|
||||
if ( !Owner.IsValid() || !Input.Down( "attack1" ) || (Ammo == 0 && MaxAmmo != 0) || Reloading ) return false;
|
||||
|
||||
var rate = PrimaryRate;
|
||||
if ( rate <= 0 ) return true;
|
||||
@@ -138,7 +144,7 @@ public partial class Weapon : AnimatedEntity
|
||||
|
||||
private void ReduceAmmoAndPrimaryAttack()
|
||||
{
|
||||
Ammo--;
|
||||
Ammo = Math.Max(0, Ammo -1);
|
||||
PrimaryAttack();
|
||||
}
|
||||
|
||||
@@ -166,7 +172,7 @@ public partial class Weapon : AnimatedEntity
|
||||
|
||||
var trace = Trace.Ray( start, end )
|
||||
.UseHitboxes()
|
||||
.WithAnyTags( "solid", "player", "npc" )
|
||||
.WithAnyTags( HitTags.ToArray() )
|
||||
.Ignore( this )
|
||||
.Size( radius );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user