Files
sbox-public/engine/Sandbox.Engine/Scene/Components/Game/PlayerController/PlayerController.Events.cs
Garry Newman ca96c2a945 Make Inventory, BaseWeapon, AmmoResource, Screenshake first party (#5245)
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)
2026-07-04 12:46:59 +01:00

61 lines
1.6 KiB
C#

namespace Sandbox;
public sealed partial class PlayerController : Component
{
/// <summary>
/// Events from the PlayerController
/// </summary>
public interface IEvents : ISceneEvent<IEvents>
{
/// <summary>
/// Our eye angles are changing. Allows you to change the sensitivity, or stomp all together.
/// </summary>
void OnEyeAngles( ref Angles angles ) { }
/// <summary>
/// Called after we've set the camera up
/// </summary>
[Obsolete( "Implement ICameraModifier instead - it runs in the camera's ordered modifier chain, after the player's view (order 0)." )]
void PostCameraSetup( CameraComponent cam ) { }
/// <summary>
/// The player has just jumped
/// </summary>
void OnJumped() { }
/// <summary>
/// The player has landed on the ground, after falling this distance.
/// </summary>
void OnLanded( float distance, Vector3 impactVelocity ) { }
/// <summary>
/// Used by the Using system to find components we can interact with.
/// By default we can only interact with IPressable components.
/// Return a component if we can use it, or else return null.
/// </summary>
Component GetUsableComponent( GameObject go ) { return default; }
/// <summary>
/// We have started using something (use was pressed)
/// </summary>
void StartPressing( Component target ) { }
/// <summary>
/// We have stopped using something
/// </summary>
void StopPressing( Component target ) { }
/// <summary>
/// We pressed USE but it did nothing
/// </summary>
void FailPressing() { }
/// <summary>
/// We have a chance to do something before input is processed
/// </summary>
void PreInput() { }
}
}