Skip to main content

ImpactModifier

A class in Root.Township, Alta.Impact.

Server: changes hits made by a crafted tool (damage multipliers, stat changes) by running a list of ImpactModifierComponents on them. Covers either the whole tool or the parts attached to its slots.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private CraftingPart basePartThe crafting part whose root or slots are watched.
private bool isForWholeToolWhen on, modifies every hit of the whole tool instead of only attached parts.
private bool isOnlyWhenWieldedWhen on, only modifies hits while the tool's pickup is held.
private static Logger loggerNLog logger; logs when a slot is registered twice.
private Dictionary<JointPoint, ImpactorMap> mapsThe ImpactorMap registered for each slot.
private ImpactModifierComponent[] modifiersThe modifier assets run on each hit.
private ImpactTool trackedToolThe root impact tool hooked when isForWholeTool is on.

Events​

MemberWhat it is
event Action<ImpactHitWithTool> OnModifiedHitRaised after the modifiers have changed a hit.

Methods​

MemberWhat it is
override void InitializeAsServer(SpawnData spawnData)Server: hooks the root tool, or each slot's attached part, plus any ImpactorMap on this object.
5 private and internal methods
MemberWhat it is
private void DeregisterSlot(JointPoint point)Unhooks the impact generators of the part that left a slot.
private void ModifyHit(ImpactHitWithTool hitWithTool)Runs every modifier on the hit and raises OnModifiedHit, if wielding isn't required or the tool is held.
private void OnRootChanged(CraftingPart craftingPart)Moves the hit hook to the new root's ImpactTool.
private void RegisterImpactorMap(ImpactorMap map)Hooks every impact generator in an ImpactorMap so its hits get modified.
private void RegisterSlot(JointPoint point)Hooks the ImpactorMap of the part just attached to a slot.