-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ScreenUtil class + small reformat/relocation
- Loading branch information
Showing
23 changed files
with
446 additions
and
1,600 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Sandbox; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
/* | ||
* Utility class to handle framerate independent + useful calculations | ||
*/ | ||
|
||
namespace SWB_Base | ||
{ | ||
class MathUtil | ||
{ | ||
public static float FILerp( float fromF, float toF, float amount ) | ||
{ | ||
return fromF.LerpTo( toF, amount * RealTime.Delta ); | ||
} | ||
|
||
public static Vector3 FILerp( Vector3 fromVec, Vector3 toVec, float amount ) | ||
{ | ||
return fromVec.LerpTo( toVec, amount * RealTime.Delta ); | ||
} | ||
|
||
public static Angles FILerp( Angles fromAng, Angles toAng, float amount ) | ||
{ | ||
return Angles.Lerp( fromAng, toAng, amount * RealTime.Delta ); | ||
} | ||
|
||
public static Vector3 RelativeAdd( Vector3 vec1, Vector3 vec2, Rotation rot ) | ||
{ | ||
vec1 += vec2.x * rot.Right; | ||
vec1 += vec2.y * rot.Up; | ||
vec1 += vec2.z * rot.Forward; | ||
|
||
return vec1; | ||
} | ||
|
||
public static T GetRandom<T>( List<T> list ) | ||
{ | ||
if ( list.Count == 0 ) return default; | ||
|
||
var random = new Random(); | ||
var randI = random.Next( list.Count ); | ||
return list[randI]; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using Sandbox; | ||
using System; | ||
|
||
namespace SWB_Base | ||
{ | ||
partial class ScreenUtil | ||
{ | ||
public static void Shake( float length = 0, float speed = 0, float size = 0, float rotation = 0 ) | ||
{ | ||
ShakeRPC( length, speed, size, rotation ); | ||
} | ||
|
||
public static void Shake( To to, float length = 0, float speed = 0, float size = 0, float rotation = 0 ) | ||
{ | ||
ShakeRPC( to, length, speed, size, rotation ); | ||
} | ||
|
||
public static void Shake( To to, ScreenShake screenShake ) | ||
{ | ||
if ( screenShake != null ) | ||
Shake( to, screenShake.Length, screenShake.Speed, screenShake.Size, screenShake.Rotation ); | ||
} | ||
|
||
public static void Shake( ScreenShake screenShake ) | ||
{ | ||
if ( screenShake != null ) | ||
Shake( screenShake.Length, screenShake.Speed, screenShake.Size, screenShake.Rotation ); | ||
} | ||
|
||
public static void ShakeAt( Vector3 origin, float radius = 1, float length = 0, float speed = 0, float size = 0, float rotation = 0 ) | ||
{ | ||
var objects = Physics.GetEntitiesInSphere( origin, radius ); | ||
|
||
foreach ( var obj in objects ) | ||
{ | ||
// Player check | ||
if ( obj is not Player ply || !ply.IsValid() ) | ||
continue; | ||
|
||
// Distance check | ||
var targetPos = ply.PhysicsBody.MassCenter; | ||
var dist = Vector3.DistanceBetween( origin, targetPos ); | ||
if ( dist > radius ) | ||
continue; | ||
|
||
// Intensity calculation | ||
var distanceMul = 1.0f - Math.Clamp( dist / radius, 0.0f, 0.75f ); | ||
rotation *= distanceMul; | ||
size *= distanceMul; | ||
|
||
ShakeRPC( To.Single( ply ), length, speed, size, rotation ); | ||
} | ||
} | ||
|
||
public static void ShakeAt( Vector3 position, float radius, ScreenShake screenShake ) | ||
{ | ||
if ( screenShake != null ) | ||
ShakeAt( position, radius, screenShake.Length, screenShake.Speed, screenShake.Size, screenShake.Rotation ); | ||
} | ||
|
||
[ClientRpc] | ||
public static void ShakeRPC( float length = 0, float speed = 0, float size = 0, float rotation = 0 ) | ||
{ | ||
new Sandbox.ScreenShake.Perlin( length, speed, size, rotation ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Sandbox; | ||
using SWB_Base; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace SWB_EXPLOSIVES | ||
{ | ||
[Library( "swb_explosives_rpg7_hotdog", Title = "RPG-7-Hotdog" )] | ||
public class RPG7Hotdog : RPG7 | ||
{ | ||
public override string ViewModelPath => "weapons/swb/explosives/rpg-7-hotdog/swb_v_rpg7_hotdog.vmdl"; | ||
public override string WorldModelPath => "weapons/swb/explosives/rpg-7-hotdog/swb_w_rpg7_hotdog.vmdl"; | ||
public override string Icon => "/swb_explosives/textures/ui/icon_rpg7.png"; | ||
|
||
public override Func<ClipInfo, bool, FiredEntity> CreateEntity => CreateHotdogEntity; | ||
public override Vector3 EntityVelocity => new Vector3( 0, 0, 50 ); | ||
public override Angles EntityAngles => new Angles( 0, 180, 0 ); | ||
public override string EntityModel => "models/citizen_props/hotdog01.vmdl"; | ||
|
||
public RPG7Hotdog() : base() { } | ||
|
||
private FiredEntity CreateHotdogEntity( ClipInfo clipInfo, bool isPrimary ) | ||
{ | ||
var rocket = new Rocket(); | ||
rocket.Weapon = this; | ||
rocket.ExplosionDelay = 3f; | ||
rocket.ExplosionRadius = 400f; | ||
rocket.ExplosionDamage = 300f; | ||
rocket.ExplosionForce = 500f; | ||
rocket.ExplosionSounds = new List<string> | ||
{ | ||
"css_grenade_he.explode" | ||
}; | ||
rocket.ExplosionEffect = "particles/swb/explosion/hotdogs.vpcf"; | ||
rocket.RocketSound = "swb_explosives_rpg7.rocketloop"; | ||
rocket.RocketEffects = new List<string> | ||
{ | ||
"particles/swb/smoke/swb_smoketrail_1.vpcf", | ||
"particles/swb/fire/swb_fire_rocket_1.vpcf" | ||
}; | ||
rocket.ExplosionShake = new ScreenShake | ||
{ | ||
Length = 1f, | ||
Speed = 5f, | ||
Size = 7f, | ||
Rotation = 3f | ||
}; | ||
|
||
return rocket; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
weapons/css_grenade_he/particles/css_grenade_he_explosion.vpcf
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.