Extending the Toolkit
The Decorating Toolkit is built so you can swap parts out. Most things use interfaces, so if you dont like how it works, you can write your own.
TODO: Add simple diagram
Main things you can change
1. Custom Dragging
Want your objects to rotate while dragging or move in a weird way? Use IDragMotor.
public class MyCustomDragMotor : IDragMotor {
public void Begin(DragSession session) {
// When drag starts
}
public void Tick(DragSession session, float deltaTime) {
// Update session.TargetPosition or session.TargetRotation here
}
public void End(DragSession session, bool committed) {
// When drag stops
}
}
2. Custom Rules
If you need rules like "you can only put this chair on a rug", use IPlacementValidator.
public class MyPlacementValidator : IPlacementValidator {
public PlacementValidationResult Validate(DragSession session) {
// Check your rules
bool isOk = CheckMyRules(session);
return isOk ? PlacementValidationResult.Valid() : PlacementValidationResult.Invalid("Not on rug!");
}
}
3. Custom Input
If you use VR or something else, use IPointerSource to tell the toolkit where you're pointing.
public class MyInputSource : MonoBehaviour, IPointerSource {
public bool TryGetPointer(out PointerState pointerState) {
// Find your pointer position (exmp, world ray)
pointerState = new PointerState { ... };
return true;
}
}
4. Custom Snapping
You can make your own snapping logic with IGrid. Like hex grids or whatever.
public class HexGrid : MonoBehaviour, IGrid {
public Vector3 Snap(Vector3 position) {
// Do your hex snapping math here
return SnapToHex(position);
}
}
How to use your new scripts
Once you've written your code, you can use it:
- MonoBehaviours: If your script is a
MonoBehaviour, put it on a GameObject and drag it into the right slot on the Player Decorating Controller or your settings asset. - Normal C# Classes: For things like
IDragMotor, you might need to make a new controller or a factory to use them.