DecraftingComponent
An abstract class in Root.Township, Alta.Crafting.
Base for a station that takes crafted items apart by hitting them with a chisel tool. Hits near a joint knock off the outermost part there. The hit runs on the server and the effect syncs to clients.
- Listed in Crafting and making
- Inherits or implements
NetworkEntityBehaviour - Derived types
DecraftingDeck,GenericAssemblyStation - Nested types
HitTypePosition - Documented in Crafting
Constructors
| Member | What it is |
|---|---|
protected DecraftingComponent() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private List<JointSlot> availableSlots | Slots whose attached part can be knocked off now. |
private Chiselable currentChiseleable | Chiselable added to the current part so it can be hit. |
private CraftingPart currentPart | The crafting part being decrafted. |
private PositionEvent decraftingHitEffect | Effect for a hit that lands near a removable part. |
private PositionEvent innefectiveHitEffect | Effect for a hit that is too weak or misses every slot. |
private float maxDistanceFromInsertSquared | Squared distance from a slot a hit must land within. |
private float minimumHitToDecraft | Least damage a hit needs to knock a part off. |
private MethodSyncStruct<DecraftingComponent.HitTypePosition> syncDecraftingHit | Message sync for hit effects. |
Properties
| Member | What it is |
|---|---|
virtual bool CanPickupChangeWhileAdded { get; } | Whether non-crafted items may be added. False by default. |
Methods
| Member | What it is |
|---|---|
void AddPickup(Pickup newPickup) | Starts tracking a crafted item: adds a Chiselable to it and maps its joint slots. Uncrafted items need the forced overload or CanPickupChangeWhileAdded. |
void AddPickup(Pickup newPickup, bool isForced) | Starts tracking a crafted item: adds a Chiselable to it and maps its joint slots. Uncrafted items need the forced overload or CanPickupChangeWhileAdded. |
override void Initialize() | Sets up the synced hit effect message. |
void RemoveCurrentPickup() | Stops tracking the current item and removes its Chiselable. |
protected void TryDecraft(float damage, Vector3 position, Vector3 direction, ChiselingTool tool, Collider hitCollider) | Server: handles a chisel hit. A strong enough hit near a joint of an outer part fully disconnects that part; otherwise plays the ineffective effect. |
protected virtual bool ValidateCraftingPart(CraftingPart part) | Override to refuse removing a given part. Returns true by default. |
5 private and internal methods
| Member | What it is |
|---|---|
private bool AddPartSlots(CraftingPart part) | Adds the slots holding outermost parts (ones with nothing attached) to availableSlots. Returns true if the part has nothing attached. |
private bool GetClosestSlot(ref JointSlot closestSlot, Vector3 position) | Finds the available slot nearest the hit, within maxDistanceFromInsertSquared. |
private void MapSlots() | Rebuilds the list of slots that can be knocked off. |
private void ReMapSlots(CraftingPart part, bool isLoad) | Handler for the part being crafted: rebuilds the slot list. |
private void SyncDecraftingHit(IPlayer player, Stream stream, DecraftingComponent.HitTypePosition hitTypePosition) | Network message that plays the effective or ineffective hit effect on clients. |