mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-02 00:38:31 -04:00
https://sbox.game/dev/doc/gameplay/inventory-weapons/ Added InventoryComponent - a slot based inventory, hotbar or shared bucket slots, with a starting loadout BaseInventoryItem - base class for inventory items, with hooks to veto switching, holstering and dropping BaseWeapon - a GMod style base weapon - fire modes, magazines and reserve ammo, reloading, dry fire, ballistics, spread, crosshair and HUD BaseWeaponModel - view/world model base with muzzle flash, brass ejection, tracers and animation hooks Ammo types are resources (.ammo) - weapons share reserve pools by type, clamped to a max reserve BaseWeapon.ShootBullets / ShootBullet - bullet tracing with damage, impulse and hitbox tags Weapon hold types editor Animgraph enum parameters can be set by option name - Renderer.Set( "holdtype", "pistol" ) NpcUsage on BaseWeapon - engagement range and burst behaviour so NPCs can use any weapon ICameraModifier - cameras compose their view through an ordered modifier chain, read the result from CameraComponent.View CameraEffectSystem - screen shake, directional punches and tilts, with world epicenter falloff - camera.AddShake / AddPunch / AddTilt EnvShake component - shakes the view, rumbles controllers, kicks physics TracerEffect - an animated tracer line, ITargetedEffect for effects that fly at a target SceneAnchor - a world position that can follow an object or bone SkinnedModelRenderer.GetClosestBone( worldPosition ) Vector3.WithAimCone can take a custom Random for reproducible spread Improve/Fix PlayerController searches parents for IPressable when pressing PlayerController camera runs through the modifier chain - IEvents.PostCameraSetup is obsolete SoundPlayer preview uses shortcuts - Space toggles playback, Ctrl+Space restarts Fixed Radius( 0 ) traces missing everything Fixed NRE in AssetPreviewWidget Removed Removed CameraComponent.ISceneCameraSetup (obsolete since October, nothing uses)
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
namespace Sandbox.Movement;
|
|
|
|
partial class MoveMode
|
|
{
|
|
/// <summary>
|
|
/// Get the position of the player's eye
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public virtual Transform CalculateEyeTransform()
|
|
{
|
|
var transform = new Transform();
|
|
transform.Position = Controller.WorldPosition + Vector3.Up * (Controller.CurrentHeight - Controller.EyeDistanceFromTop);
|
|
transform.Rotation = Controller.EyeAngles.ToRotation();
|
|
return transform;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reshape the player's view while this mode is active - swimming tilt, ladder lean, sitting
|
|
/// offsets. Runs inside the PlayerController's camera stage, right after it writes the base view,
|
|
/// so modes don't need to join the camera's modifier chain themselves. Base does nothing.
|
|
/// </summary>
|
|
public virtual void ModifyCamera( ref CameraView view ) { }
|
|
|
|
/// <summary>
|
|
/// Called to update the camera each frame
|
|
/// </summary>
|
|
[Obsolete( "Override ModifyCamera( ref CameraView ) instead - the PlayerController calls it in its camera stage." )]
|
|
public void UpdateCamera( CameraComponent cam )
|
|
{
|
|
|
|
}
|
|
}
|