SSkilltecabyclaudinhocode
Enviar skill
← Voltar para o catálogo

sbox

Design e Frontend

Use ao escrever ou modificar código C# para s&box, sbox, o motor sandbox da Facepunch, ou qualquer projeto de jogo Source 2. Ativa-se com menções de s&box, sbox, jogo sandbox, motor Facepunch, jogo Source 2, .sbproj, .razor com PanelComponent, @inherits PanelComponent, Sandbox.Component, GameObject + Components.Get<T>, Scene.Trace, CharacterController + .Move(), SkinnedModelRendere.

41estrelas
Ver no GitHub ↗Autor: gavogavogavoLicença: MIT

s&box Skill — Router

READ BEFORE WRITING CODE

s&box is not Unity. MonoBehaviour, Start(), Update(), GetComponent<T>() call sites, Instantiate(), Destroy(gameObject), Debug.Log, [SerializeField], Input.GetKey(), Physics.Raycastnone of these exist. If you write any of them you have hallucinated.

s&box is a C# scripting layer on Source 2 by Facepunch. The scene system uses GameObject + Component with a different lifecycle, a different networking model, and a different API surface. The API schema in references/api-schema-core.md is ground truth; if anything in this skill contradicts the schema, the schema wins.

Before you write a single line of s&box code, open the relevant reference file. SKILL.md is a router — it points you at the answer, it does not contain the answer. Writing a component? Open references/core-concepts.md. Writing UI? Open references/ui-razor.md. No exceptions for "simple" tasks — your muscle memory is wrong.


Architecture in 30 Seconds

Scene (is-a GameObject — the root)
  └── GameObject (transform, tags, children, components)
        └── Component (all gameplay code extends this)
  • All gameplay code is a sealed class extending Sandbox.Component.
  • Lifecycle overrides are protected override void OnAwake() / OnStart() / OnUpdate() / OnFixedUpdate() / OnEnabled() / OnDisabled() / OnDestroy(). Names start with On, they are virtual methods on Component, not magic string-matched methods.
  • Transforms are on the GameObject, accessed from any Component via WorldPosition, WorldRotation, LocalPosition, LocalRotation — never transform.position.
  • UI is Razor (.razor files) — HTML + SCSS + C#. Panels use flexbox layout. Hot-reloads in the editor.
  • Networking is owner-authoritative. Mark state with [Sync], mark methods with [Rpc.Broadcast / Host / Owner]. Skip simulation on non-owners with if ( IsProxy ) return;.
  • Physics uses Rigidbody + Collider components. Raycasts are Scene.Trace.Ray(from, to).Run() — a builder-pattern API. Collisions come through Component.ICollisionListener and Component.ITriggerListener interfaces.
  • Coordinate system is Z-up: Vector3.Forward = (1,0,0), Vector3.Right = (0,-1,0), Vector3.Up = (0,0,1).
  • Restricted .NET: System.IO.File, raw sockets, Console, Thread, Process — all blocked. Use FileSystem.Data, Http, Log, async/await.

Routing Table — "I need to…"

Match the task, open the file. Do not guess; open the file.

TaskRead
Understand the scene/GameObject/Component modelreferences/core-concepts.md
Write a Component (lifecycle, [Property], Tags, async)references/core-concepts.md
Spawn / clone / destroy a prefabreferences/core-concepts.mdPrefabs
Fire a scene event (ISceneEvent<T>)references/core-concepts.mdScene Events
Write a GameObjectSystemreferences/core-concepts.mdGameObjectSystem
Use ModelRenderer / SkinnedModelRenderer / bones / animgraphreferences/components-builtin.mdRendering
Use Rigidbody, any Collider, jointsreferences/components-builtin.mdPhysics
Use CharacterController for movementreferences/components-builtin.mdCharacterController
Use the full PlayerController (built-in FPS/TPS)references/components-builtin.mdGameplay
Set up a camera, HUD painter, post-processingreferences/components-builtin.mdCamera, Post-Processing
Use lights, fog, envmap probes, skyboxreferences/components-builtin.mdLighting, Environment
Add audio (SoundPointComponent, Sound.Play)references/components-builtin.mdAudio
Use NavMeshAgent, NavMeshLink, query NavMeshreferences/components-builtin.mdNavigation
Create particles, decals, trails, beamsreferences/components-builtin.mdEffects, Rendering
Write a Razor UI panel (.razor, PanelComponent, BuildHash)references/ui-razor.md
Style with SCSS — flexbox, transitions, :intro / :outro, :bindreferences/ui-razor.mdStyling, Layout System, Transitions
Use built-in controls (Button, TextEntry, DropDown, VirtualList)references/ui-razor.mdBuilt-in Controls
Build a world-space panel or a NavigationHost appreferences/ui-razor.mdWorldPanel, Navigation
Set up a lobby, connect/disconnect, query Connectionreferences/networking.mdLobby & Connection
Network an object (NetworkMode, NetworkSpawn, ownership)references/networking.mdNetworked Objects, Ownership
Use [Sync] / [Sync(SyncFlags.X)] / [Change] / NetList / NetDictionaryreferences/networking.md[Sync] Properties
Write RPCs ([Rpc.Broadcast/Host/Owner], NetFlags, caller info, filtering)references/networking.mdRPC Messages
React to connections (INetworkListener, INetworkSpawn, snapshot data)references/networking.mdNetwork Events
Use ISceneStartup for host vs client initializationreferences/networking.mdScene Startup
Dedicated server / #if SERVER / user permissionsreferences/networking.mdDedicated Servers
Poll keyboard/mouse/controller input, haptics, glyphsreferences/input-and-physics.mdInput
Raycast / sphere / box / capsule trace with tag filtersreferences/input-and-physics.mdSceneTrace
Access PhysicsWorld, gravity, physics eventsreferences/input-and-physics.mdPhysics World
Implement collision/trigger listenersreferences/input-and-physics.mdCollision System
Use Vector3 / Rotation / Angles / Transform / BBox / Ray / Capsulereferences/input-and-physics.mdMath Types
Use Time.Now, Time.Delta, TimeSince, TimeUntilreferences/input-and-physics.mdTime
Draw debug gizmos (DrawGizmos, Gizmo.Draw)references/input-and-physics.mdGizmo
Need the full signature of GameObject, Component, Scene, Input, etc.references/api-schema-core.md
Look up whether a given type exists & what it doesreferences/api-schema-extended.md
See a complete worked example of a pattern before writing your ownreferences/patterns-and-examples.md

Unity → s&box Translation Table

Any time you write one of the left column, you are hallucinating. Use the right column.

Unity / Wrongs&box / Correct
class Foo : MonoBehaviourpublic sealed class Foo : Component
void Awake()protected override void OnAwake()
void Start()protected override void OnStart()
void Update()protected override void OnUpdate()
void FixedUpdate()protected override void OnFixedUpdate()
void OnEnable() / OnDisable()protected override void OnEnabled() / OnDisabled()
void OnDestroy()protected override void OnDestroy()
[SerializeField] float speed[Property] public float Speed { get; set; }
[HideInInspector][Hide]
transform.positionWorldPosition (or GameObject.WorldPosition)
transform.localPositionLocalPosition
transform.rotationWorldRotation
transform.forwardWorldRotation.Forward
gameObject.SetActive(false)GameObject.Enabled = false
Destroy(gameObject) / Destroy(this)GameObject.Destroy() / Component.Destroy() / DestroyGameObject()
Instantiate(prefab, pos, rot)prefab.Clone( pos, rot )
Instantiate(prefab); NetworkServer.Spawn(...)prefab.Clone(pos).NetworkSpawn( owner )
GetComponent<T>() in Start/UpdateGetComponent<T>() is fine; also Components.Get<T>( FindMode ) for ancestor/descendant searches
FindObjectOfType<T>() / FindObjectsOfType<T>()Scene.Get<T>() / Scene.GetAll<T>() / Scene.GetAllComponents<T>()
`GameObject.Find("Nam

Como adicionar

/plugin marketplace add gavogavogavo/claude-sbox

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Comentários · Nenhum comentário

Entre para comentar. Entrar

  • Ainda não há comentários. Seja o primeiro.