DiggingImpactor
A class in Root.Township, the global namespace.
Makes a tool (shovel head) bury itself in the ground when it hits a target layer hard enough, then dig up IDigable objects nearby when it is levered out. The holder's client decides bury and unbury and syncs it; dig damage runs on the server; the buried state is saved.
- Listed in Global namespace: C to D
- Inherits or implements
NetworkEntityBehaviour,ISavable<DiggingImpactorSaveStructure>,ISavableSave<DiggingImpactorSaveStructure>,ISavableSaveBase,IToolHitDependant - Derived types
DiggingImpactorSaveStructure - Nested types
InteractorPositions
Constructors
| Member | What it is |
|---|---|
DiggingImpactor() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
18 private and internal fields
| Member | What it is |
|---|---|
private Vector3 buriedPosition | Where the tool sits while buried. |
private Quaternion buriedRotation | Tool rotation while buried. |
private Coroutine checkPull | The running CheckPull coroutine. |
private ImpactTool currentTool | The impact tool being buried. |
private Func<float> diggingDamageMultiplier | Server: returns the physical material's damage multiplier, or 1. |
private Transform digShereCastPosition | Where the digable search sphere is centred (at the pivot's height). |
private Pickup durabilityPickup | Pickup whose durability drops on each dig. |
private float efficiencyRatio | How well the hit landed, 0 to 1; drives depth, pull, radius and damage. Saved as -1 when not buried. |
private FakePickup fakePickup | Grab point that holds the tool in the ground and is pulled to unbury it. |
private Dictionary<Interactor, DiggingImpactor.InteractorPositions> interactorPositions | Start position and lever distance of each hand on the fake pickup. |
private static Logger logger | NLog logger. |
private Vector3 pivot | Ground hit point the tool levers around. |
private Vector3 pullOutDirection | Local direction for pulling the tool straight out. |
private Action receivedTool | Callback run when a tool is registered, used for DelayedBury. |
private Vector3 rotatingAxis | Local axis used with the pull-out direction to work out the lever torque axis. |
private DiggingImpactorSettings settings | DiggingImpactorSettings with thresholds, curves, layers and effects. |
private MethodSync syncBuried | Sync for the buried state. |
private MethodSyncStruct<bool> syncUnburied | Sync for unburying, with a dig flag. |
Properties
| Member | What it is |
|---|---|
bool IsBuried { get; private set; } | Whether the tool is stuck in the ground. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Sets up the buried and unburied syncs. |
override void InitializeAsServer(SpawnData data) | Server: sets the damage multiplier source and, if saved as buried, re-buries and syncs it next frame. |
override void OnConnected(Player player) | Server: sends the buried state to a joining player next frame. |
16 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Finds the impact tool, through the crafting root if there is one, and hooks the fake pickup's grab events. |
private void Bury() | Marks it buried, attaches the fake pickup to hold the tool in place, and plays the embed effect on clients. |
private IEnumerator CheckPull() (iterator) | While grabbed, totals hand movement; enough torque unburies and digs, enough straight pull unburies without digging. |
private void DelayedBury() | Applies a buried state that arrived before the tool was known, once the tool is registered. |
private void Dig() | Server: damages every digable in range by effectiveness and the material's damage multiplier, and wears the tool. |
private void EndCheckPull(Interactor interactor) | Stops tracking a hand, and stops CheckPull when no hands are left. |
private IEnumerable<IDigable> FoundDigables() (iterator) | Finds IDigable components on rigidbodies in a sphere at the dig point, sized by efficiency. |
private void Alta.Impact.IToolHitDependant.OnCollided(Collision collision, bool isHitting, ImpactTool tool) | On a hard enough ground hit (by the local holder, or the server if nobody holds it), buries the tool and syncs it. |
private void OnDrawGizmosSelected() | Draws the pull-out direction and torque axis. |
private void Alta.Impact.IToolHitDependant.OnHit(ImpactHitWithTool hit, ImpactTool tool) | Empty; only collisions matter. |
private void OnRootChanged(CraftingPart part) | Registers the new root's impact tool when the crafting root changes. |
private void RegisterTool(ImpactTool newTool) | Sets the current tool and points the fake pickup at its pickup. |
private void StartCheckPull(Interactor interactor) | When the local player grabs the fake pickup, records the hand's start and starts CheckPull; unburies if it wasn't buried. |
private void SyncBuried(IPlayer player, Stream stream) | Syncs efficiency, buried position, pivot and rotation, then buries the tool; the server relays it and notifies digables. |
private void SyncUnburied(IPlayer player, Stream stream, bool isDigging) | Syncs an unbury and whether it digs; the server relays it to others. |
private void Unbury(bool isDigging) | Marks it not buried, plays the dig effect and digs on the server if digging, and detaches the fake pickup. |