🔍 s&box Package Code Search

Search C# source code, UI razor templates, shaders, and configs across s&box packages.

Showing code results for query: * (10 total matches found)
whiletruedoend.fistsanimationhelper / __gen_RazorNamespace.cs
Game library
global using Microsoft.AspNetCore.Components; 
global using Microsoft.AspNetCore.Components.Rendering;
whiletruedoend.fistsanimationhelper / Editor/MyEditorMenu.cs
Editor library
using Editor;
whiletruedoend.fistsanimationhelper / UnitTests/UnitTest.cs
UnitTest library
global using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class TestInit
{
	[AssemblyInitialize]
	public static void ClassInitialize( TestContext context )
	{
		Sandbox.Application.InitUnitTest();
	}
}
whiletruedoend.fistsanimationhelper / FootstepSoundsComponent.cs
Game library
using Sandbox;
using Sandbox.Diagnostics;
using Sandbox.Services;
using System;
using System.Threading;
public sealed class FootstepSoundsComponent : Component
{ 
	[Property] SkinnedModelRenderer Source { get; set; }

	[Property] bool StaticSound { get; set; }
	[Property, ShowIf("StaticSound", true)] SoundEvent FootstepSound { get; set; }
	protected override void OnEnabled()
	{
		if ( Source is null )
			return;

		Source.OnFootstepEvent += OnEvent;
	}

	protected override void OnDisabled()
	{
		if ( Source is null )
			return;

		Source.OnFootstepEvent -= OnEvent;
	}

	private void OnEvent( SceneModel.FootstepEvent e )
	{
		if ( !StaticSound )
			PhysicalFootstep(e);
		else
			Sound.Play( FootstepSound, Transform.Position );
	}

	void PhysicalFootstep( SceneModel.FootstepEvent e )
	{
		var tr = Scene.Trace
			.Ray( e.Transform.Position + Vector3.Up * 20, e.Transform.Position + Vector3.Up * -20 )
			.Run();

		if ( !tr.Hit )
			return;

		var snd = Sound.Play( tr.Surface.Sounds.FootLand, Transform.Position );
		snd.Volume = 0.5f;
	}
}
whiletruedoend.fistsanimationhelper / GravityControllerComponent.cs
Game library
using Sandbox;

/// <summary>
/// This is a component - in your library!
/// </summary>
[Title( "Gravity Controller" )]
public class GravityController : Component
{
	[Property] [Range(0.0f, 10000, 0.5f, false, true)] float Strength { get; set; } = 850.0f;
    protected override void OnUpdate()
    {
        base.OnUpdate();
		if (Scene.PhysicsWorld.Gravity != Transform.Rotation.Down * Strength)
		{
			Scene.PhysicsWorld.Gravity = Transform.Rotation.Down * Strength;
            foreach (var item in Scene.PhysicsWorld.Bodies)
            {
				item.Sleeping = false;
            }
        }
		
    }

    protected override void DrawGizmos()
    {
        base.DrawGizmos();
		Gizmo.Draw.Arrow( Vector3.Zero, Vector3.Down * Strength / 50.0f, 4, 1 );
    }
}
whiletruedoend.fistsanimationhelper / UnitTests/LibraryTest.cs
UnitTest library
using Sandbox;

[TestClass]
public partial class LibraryTests
{
	[TestMethod]
	public void SceneTest()
	{
		var scene = new Scene();
		using ( scene.Push() )
		{
			var go = new GameObject();

			Assert.AreEqual( 1, scene.Directory.GameObjectCount );
		}
	}

}
whiletruedoend.fistsanimationhelper / Code/FistsAnimationHelper.cs
Game library
using Sandbox;

[Title( "Fists Animation Helper" )]
public sealed class FistsAnimationHelper : Component
{
	[Property]
	SkinnedModelRenderer Target { get; set; }

	public bool IsGrounded
	{
		get => Target.GetBool( "b_grounded" );
		set => Target.Set( "b_grounded", value );
	}

	public bool IsRunning
	{
		get => Target.GetBool( "b_sprint" );
		set => Target.Set( "b_sprint", value );
	}

	public float ViewBob
	{
		get => Target.GetFloat( "move_bob" );
		set => Target.Set( "move_bob", System.Math.Clamp( value, 0f, 1f ) );
	}

	public void TriggerJump()
	{
		Target.Set( "b_jump", true );
	}

	public void TriggerAttack()
	{
		Target.Set( "b_attack", true );
	}

	public void TriggerHolster()
	{
		Target.Set( "b_holster", true );
	}

	public void TriggerDeploy()
	{
		Target.Set( "b_deploy", true );
	}
}
whiletruedoend.fistsanimationhelper / CitizenCustomisationComponent.cs
Game library
using Sandbox;
using Sandbox.Citizen;
using System.Collections.Generic;
using System.Linq;

[Title( "Citizen Customisation" )]
public sealed class CitizenCustomisationComponent : Component
{
	[Property] SkinnedModelRenderer body { get; set; }

	[Property] bool UseClientClothes { get; set; } = true;

	[Property][HideIf( "UseClientClothes", true )] List<Clothing> Clothes { get; set; }

	protected override void OnStart()
	{
		ApplyClothes();
	}

	public void ApplyClothes()
	{
		if ( body == null )
		{
			if ( Components.TryGet<SkinnedModelRenderer>( out var test ) )
			{
				body = test;
			}
			else
				return;
		}

		if ( UseClientClothes )
			LocalClothes();
		else
			ListClothes();
	}

	public void RemoveClothes()
	{
		var emptyContainer = new ClothingContainer();
		emptyContainer.Apply( body );
	}

	void LocalClothes()
	{
		var clothes = ClothingContainer.CreateFromLocalUser();
		clothes.Apply( body );
	}

	void ListClothes()
	{
		var container = new ClothingContainer();
		foreach ( var item in Clothes )
		{
			container.Clothing.Add( (new ClothingContainer.ClothingEntry( item )) );
		}
		container.Apply( body );
	}

	protected override void DrawGizmos()
	{
		// base.DrawGizmos();
		// foreach ( var item in Clothes )
		// {
		// 	Gizmo.Draw.Model( item.Model );
		// }
	}

}
whiletruedoend.fistsanimationhelper / FistsAnimationHelper.cs
Game library
using Sandbox;

[Title( "Fists Animation Helper" )]
public sealed class FistsAnimationHelper : Component
{
	[Property]
	SkinnedModelRenderer Target { get; set; }

	public bool IsGrounded
	{
		get => Target.GetBool( "b_grounded" );
		set => Target.Set( "b_grounded", value );
	}

	public bool IsRunning
	{
		get => Target.GetBool( "b_sprint" );
		set => Target.Set( "b_sprint", value );
	}

	public float ViewBob
	{
		get => Target.GetFloat( "move_bob" );
		set => Target.Set( "move_bob", System.Math.Clamp( value, 0f, 1f ) );
	}

	public void TriggerJump()
	{
		Target.Set( "b_jump", true );
	}

	public void TriggerAttack()
	{
		Target.Set( "b_attack", true );
	}

	public void TriggerHolster()
	{
		Target.Set( "b_holster", true );
	}

	public void TriggerDeploy()
	{
		Target.Set( "b_deploy", true );
	}
}
whiletruedoend.fistsanimationhelper / .obj/__compiler_extra.cs
Game library
global using static Sandbox.Internal.GlobalGameNamespace;
[assembly: global::System.Reflection.AssemblyMetadata( "AddonTitle", "Fists Animation Helper" )]
[assembly: global::System.Reflection.AssemblyMetadata( "AddonIdent", "fistsanimationhelper" )]
[assembly: global::System.Reflection.AssemblyMetadata( "OrgIdent", "whiletruedoend" )]
[assembly: global::System.Reflection.AssemblyMetadata( "Ident", "whiletruedoend.fistsanimationhelper" )]
[assembly: global::System.Reflection.AssemblyMetadata( "CompileTime", "06-Sep-24 18:57:41" )]
[assembly: global::System.Reflection.AssemblyMetadata( "EngineVersion", "17" )]
[assembly: global::System.Reflection.AssemblyMetadata( "EngineMinorVersion", "1" )]

[assembly: System.Runtime.Versioning.TargetFramework( ".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0" )]
[assembly: global::System.Reflection.AssemblyVersion("0.0.147.0")]
[assembly: global::System.Reflection.AssemblyFileVersion("0.0.147.0")]
Debug: View Raw JSON Response
{
    "TotalCount": 10,
    "Files": [
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": "__gen_RazorNamespace.cs",
            "FileName": "__gen_RazorNamespace.cs",
            "PackageType": "library",
            "CodeKind": "Game",
            "AssetVersionId": 72176,
            "Code": "global using Microsoft.AspNetCore.Components; \nglobal using Microsoft.AspNetCore.Components.Rendering;\n"
        },
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": "Editor/MyEditorMenu.cs",
            "FileName": "MyEditorMenu.cs",
            "PackageType": "library",
            "CodeKind": "Editor",
            "AssetVersionId": 72176,
            "Code": "using Editor;\r\n"
        },
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": "UnitTests/UnitTest.cs",
            "FileName": "UnitTest.cs",
            "PackageType": "library",
            "CodeKind": "UnitTest",
            "AssetVersionId": 72176,
            "Code": "global using Microsoft.VisualStudio.TestTools.UnitTesting;\r\n\r\n[TestClass]\r\npublic class TestInit\r\n{\r\n\t[AssemblyInitialize]\r\n\tpublic static void ClassInitialize( TestContext context )\r\n\t{\r\n\t\tSandbox.Application.InitUnitTest();\r\n\t}\r\n}\r\n"
        },
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": "FootstepSoundsComponent.cs",
            "FileName": "FootstepSoundsComponent.cs",
            "PackageType": "library",
            "CodeKind": "Game",
            "AssetVersionId": 72176,
            "Code": "using Sandbox;\r\nusing Sandbox.Diagnostics;\r\nusing Sandbox.Services;\r\nusing System;\r\nusing System.Threading;\r\npublic sealed class FootstepSoundsComponent : Component\r\n{ \r\n\t[Property] SkinnedModelRenderer Source { get; set; }\r\n\r\n\t[Property] bool StaticSound { get; set; }\r\n\t[Property, ShowIf(\"StaticSound\", true)] SoundEvent FootstepSound { get; set; }\r\n\tprotected override void OnEnabled()\r\n\t{\r\n\t\tif ( Source is null )\r\n\t\t\treturn;\r\n\r\n\t\tSource.OnFootstepEvent += OnEvent;\r\n\t}\r\n\r\n\tprotected override void OnDisabled()\r\n\t{\r\n\t\tif ( Source is null )\r\n\t\t\treturn;\r\n\r\n\t\tSource.OnFootstepEvent -= OnEvent;\r\n\t}\r\n\r\n\tprivate void OnEvent( SceneModel.FootstepEvent e )\r\n\t{\r\n\t\tif ( !StaticSound )\r\n\t\t\tPhysicalFootstep(e);\r\n\t\telse\r\n\t\t\tSound.Play( FootstepSound, Transform.Position );\r\n\t}\r\n\r\n\tvoid PhysicalFootstep( SceneModel.FootstepEvent e )\r\n\t{\r\n\t\tvar tr = Scene.Trace\r\n\t\t\t.Ray( e.Transform.Position + Vector3.Up * 20, e.Transform.Position + Vector3.Up * -20 )\r\n\t\t\t.Run();\r\n\r\n\t\tif ( !tr.Hit )\r\n\t\t\treturn;\r\n\r\n\t\tvar snd = Sound.Play( tr.Surface.Sounds.FootLand, Transform.Position );\r\n\t\tsnd.Volume = 0.5f;\r\n\t}\r\n}\r\n"
        },
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": "GravityControllerComponent.cs",
            "FileName": "GravityControllerComponent.cs",
            "PackageType": "library",
            "CodeKind": "Game",
            "AssetVersionId": 72176,
            "Code": "using Sandbox;\r\n\r\n/// <summary>\r\n/// This is a component - in your library!\r\n/// </summary>\r\n[Title( \"Gravity Controller\" )]\r\npublic class GravityController : Component\r\n{\r\n\t[Property] [Range(0.0f, 10000, 0.5f, false, true)] float Strength { get; set; } = 850.0f;\r\n    protected override void OnUpdate()\r\n    {\r\n        base.OnUpdate();\r\n\t\tif (Scene.PhysicsWorld.Gravity != Transform.Rotation.Down * Strength)\r\n\t\t{\r\n\t\t\tScene.PhysicsWorld.Gravity = Transform.Rotation.Down * Strength;\r\n            foreach (var item in Scene.PhysicsWorld.Bodies)\r\n            {\r\n\t\t\t\titem.Sleeping = false;\r\n            }\r\n        }\r\n\t\t\r\n    }\r\n\r\n    protected override void DrawGizmos()\r\n    {\r\n        base.DrawGizmos();\r\n\t\tGizmo.Draw.Arrow( Vector3.Zero, Vector3.Down * Strength / 50.0f, 4, 1 );\r\n    }\r\n}\r\n"
        },
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": "UnitTests/LibraryTest.cs",
            "FileName": "LibraryTest.cs",
            "PackageType": "library",
            "CodeKind": "UnitTest",
            "AssetVersionId": 72176,
            "Code": "using Sandbox;\r\n\r\n[TestClass]\r\npublic partial class LibraryTests\r\n{\r\n\t[TestMethod]\r\n\tpublic void SceneTest()\r\n\t{\r\n\t\tvar scene = new Scene();\r\n\t\tusing ( scene.Push() )\r\n\t\t{\r\n\t\t\tvar go = new GameObject();\r\n\r\n\t\t\tAssert.AreEqual( 1, scene.Directory.GameObjectCount );\r\n\t\t}\r\n\t}\r\n\r\n}\r\n"
        },
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": "Code/FistsAnimationHelper.cs",
            "FileName": "FistsAnimationHelper.cs",
            "PackageType": "library",
            "CodeKind": "Game",
            "AssetVersionId": 72176,
            "Code": "using Sandbox;\r\n\r\n[Title( \"Fists Animation Helper\" )]\r\npublic sealed class FistsAnimationHelper : Component\r\n{\r\n\t[Property]\r\n\tSkinnedModelRenderer Target { get; set; }\r\n\r\n\tpublic bool IsGrounded\r\n\t{\r\n\t\tget => Target.GetBool( \"b_grounded\" );\r\n\t\tset => Target.Set( \"b_grounded\", value );\r\n\t}\r\n\r\n\tpublic bool IsRunning\r\n\t{\r\n\t\tget => Target.GetBool( \"b_sprint\" );\r\n\t\tset => Target.Set( \"b_sprint\", value );\r\n\t}\r\n\r\n\tpublic float ViewBob\r\n\t{\r\n\t\tget => Target.GetFloat( \"move_bob\" );\r\n\t\tset => Target.Set( \"move_bob\", System.Math.Clamp( value, 0f, 1f ) );\r\n\t}\r\n\r\n\tpublic void TriggerJump()\r\n\t{\r\n\t\tTarget.Set( \"b_jump\", true );\r\n\t}\r\n\r\n\tpublic void TriggerAttack()\r\n\t{\r\n\t\tTarget.Set( \"b_attack\", true );\r\n\t}\r\n\r\n\tpublic void TriggerHolster()\r\n\t{\r\n\t\tTarget.Set( \"b_holster\", true );\r\n\t}\r\n\r\n\tpublic void TriggerDeploy()\r\n\t{\r\n\t\tTarget.Set( \"b_deploy\", true );\r\n\t}\r\n}\r\n"
        },
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": "CitizenCustomisationComponent.cs",
            "FileName": "CitizenCustomisationComponent.cs",
            "PackageType": "library",
            "CodeKind": "Game",
            "AssetVersionId": 72176,
            "Code": "using Sandbox;\r\nusing Sandbox.Citizen;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\n\r\n[Title( \"Citizen Customisation\" )]\r\npublic sealed class CitizenCustomisationComponent : Component\r\n{\r\n\t[Property] SkinnedModelRenderer body { get; set; }\r\n\r\n\t[Property] bool UseClientClothes { get; set; } = true;\r\n\r\n\t[Property][HideIf( \"UseClientClothes\", true )] List<Clothing> Clothes { get; set; }\r\n\r\n\tprotected override void OnStart()\r\n\t{\r\n\t\tApplyClothes();\r\n\t}\r\n\r\n\tpublic void ApplyClothes()\r\n\t{\r\n\t\tif ( body == null )\r\n\t\t{\r\n\t\t\tif ( Components.TryGet<SkinnedModelRenderer>( out var test ) )\r\n\t\t\t{\r\n\t\t\t\tbody = test;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif ( UseClientClothes )\r\n\t\t\tLocalClothes();\r\n\t\telse\r\n\t\t\tListClothes();\r\n\t}\r\n\r\n\tpublic void RemoveClothes()\r\n\t{\r\n\t\tvar emptyContainer = new ClothingContainer();\r\n\t\temptyContainer.Apply( body );\r\n\t}\r\n\r\n\tvoid LocalClothes()\r\n\t{\r\n\t\tvar clothes = ClothingContainer.CreateFromLocalUser();\r\n\t\tclothes.Apply( body );\r\n\t}\r\n\r\n\tvoid ListClothes()\r\n\t{\r\n\t\tvar container = new ClothingContainer();\r\n\t\tforeach ( var item in Clothes )\r\n\t\t{\r\n\t\t\tcontainer.Clothing.Add( (new ClothingContainer.ClothingEntry( item )) );\r\n\t\t}\r\n\t\tcontainer.Apply( body );\r\n\t}\r\n\r\n\tprotected override void DrawGizmos()\r\n\t{\r\n\t\t// base.DrawGizmos();\r\n\t\t// foreach ( var item in Clothes )\r\n\t\t// {\r\n\t\t// \tGizmo.Draw.Model( item.Model );\r\n\t\t// }\r\n\t}\r\n\r\n}\r\n"
        },
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": "FistsAnimationHelper.cs",
            "FileName": "FistsAnimationHelper.cs",
            "PackageType": "library",
            "CodeKind": "Game",
            "AssetVersionId": 72176,
            "Code": "using Sandbox;\r\n\r\n[Title( \"Fists Animation Helper\" )]\r\npublic sealed class FistsAnimationHelper : Component\r\n{\r\n\t[Property]\r\n\tSkinnedModelRenderer Target { get; set; }\r\n\r\n\tpublic bool IsGrounded\r\n\t{\r\n\t\tget => Target.GetBool( \"b_grounded\" );\r\n\t\tset => Target.Set( \"b_grounded\", value );\r\n\t}\r\n\r\n\tpublic bool IsRunning\r\n\t{\r\n\t\tget => Target.GetBool( \"b_sprint\" );\r\n\t\tset => Target.Set( \"b_sprint\", value );\r\n\t}\r\n\r\n\tpublic float ViewBob\r\n\t{\r\n\t\tget => Target.GetFloat( \"move_bob\" );\r\n\t\tset => Target.Set( \"move_bob\", System.Math.Clamp( value, 0f, 1f ) );\r\n\t}\r\n\r\n\tpublic void TriggerJump()\r\n\t{\r\n\t\tTarget.Set( \"b_jump\", true );\r\n\t}\r\n\r\n\tpublic void TriggerAttack()\r\n\t{\r\n\t\tTarget.Set( \"b_attack\", true );\r\n\t}\r\n\r\n\tpublic void TriggerHolster()\r\n\t{\r\n\t\tTarget.Set( \"b_holster\", true );\r\n\t}\r\n\r\n\tpublic void TriggerDeploy()\r\n\t{\r\n\t\tTarget.Set( \"b_deploy\", true );\r\n\t}\r\n}\r\n"
        },
        {
            "Ident": "whiletruedoend.fistsanimationhelper",
            "Path": ".obj/__compiler_extra.cs",
            "FileName": "__compiler_extra.cs",
            "PackageType": "library",
            "CodeKind": "Game",
            "AssetVersionId": 72176,
            "Code": "global using static Sandbox.Internal.GlobalGameNamespace;\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"AddonTitle\", \"Fists Animation Helper\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"AddonIdent\", \"fistsanimationhelper\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"OrgIdent\", \"whiletruedoend\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"Ident\", \"whiletruedoend.fistsanimationhelper\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"CompileTime\", \"06-Sep-24 18:57:41\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"EngineVersion\", \"17\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"EngineMinorVersion\", \"1\" )]\r\n\r\n[assembly: System.Runtime.Versioning.TargetFramework( \".NETCoreApp,Version=v7.0\", FrameworkDisplayName = \".NET 7.0\" )]\r\n[assembly: global::System.Reflection.AssemblyVersion(\"0.0.147.0\")]\r\n[assembly: global::System.Reflection.AssemblyFileVersion(\"0.0.147.0\")]"
        }
    ]
}