Skip to main content

PaintBrush

A class in Root.Township, the global namespace.

Client-side brush in the character customisation room: dip it in a colour board item, then touch the character dummy to paint that cosmetic part's primary or secondary colour.

Constructors​

MemberWhat it is
PaintBrush()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

14 private and internal fields
MemberWhat it is
private CosmeticColor colorBacking field for Color.
private AltaEvent ColorAppliedEvent fired after the brush changes a colour.
private TransformSave defaultPositionThe brush's starting transform.
private TriggerShape dippingShapeTrigger at the tip that detects colour board items and is the ray origin.
private CharacterDummyPointer dummyPointer to the character dummy being painted.
private PlayerCustomizationHandler handlerCustomisation handler whose dummy's cosmetic packer is repacked after painting.
private bool isPrimaryTrue paints the primary colour, false the secondary.
private bool isSelectingUnused flag.
private static readonly Logger loggerNLog logger for this class.
private CosmeticCustomizationManager managerCosmetic customisation manager that holds the player's cosmetics.
private Pickup pickupThe brush's pickup.
private float rayLengthLength of the paint ray from the tip (0.05 by default).
private MeshRenderer tipRenderer of the brush tip, tinted to the current colour.
private UvRaycaster uvRaycasterRaycaster that finds the UV coordinate hit on the dummy.

Properties​

MemberWhat it is
static PaintBrush Active { get; private set; }The brush currently held, or null.
CosmeticColor Color { get; set; }The brush's current colour. Setting it also tints the tip material.

Methods​

11 private and internal methods
MemberWhat it is
private async void Apply()Each frame, raycasts from the tip onto the dummy and recolours the cosmetic part it hits, firing ColorApplied if anything changed.
private async Task Apply(Vector3 position, Vector3 direction, float distance)Each frame, raycasts from the tip onto the dummy and recolours the cosmetic part it hits, firing ColorApplied if anything changed.
private bool ApplyColor(PlayerCustomizationSlot slot)Sets the brush colour on a cosmetic slot or part's colour arguments; returns true if something changed.
private async Task<bool> ApplyColor(CosmeticPacker.PartId part)Sets the brush colour on a cosmetic slot or part's colour arguments; returns true if something changed.
private void Dipped(Collider collider)Takes the colour from a ColorBoardItem the dipping shape touched.
private void InteractEnded(Interactable arg1, Interactor arg2)Clears Active and stops painting when the brush is let go.
private void InteractStarted(Interactable arg1, Interactor arg2)Sets Active, lifts the brush a little and starts painting when it's picked up.
private void OnDestroy()Cleans up the tip's material copy.
private void OnDrawGizmos()Draws the paint ray in the editor.
private void Start()Saves the start position, makes the brush kinematic, hooks pickup events and copies the tip material.
private void Update()Calls Apply every frame while held.