Skip to main content

SteelSong

A class in Root.Township, the global namespace.

Smithing skill: hitting a glowing forged item in rhythm with a pulse effect builds a hit streak that multiplies later hit damage on that item. The local player times the hits and the server applies the multiplier.

Constructors​

MemberWhat it is
SteelSong()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

16 private and internal fields
MemberWhat it is
private float[] activeDamageMultiplierPerHitDamage multiplier for each streak level, from 1.05 up to 1.5 by default.
private Dictionary<ImpactDetector, SteelSong.IdentifiedModel> activeDetectorsClient: the forged model being tracked for each impact detector.
private Dictionary<ImpactDetector, SteelSongEffect> activeEffectsClient: the pulse effect playing on each impact detector.
private float animationDurationLength of one pulse in seconds.
private PositionRotationEvent badHitEffectEffect played on a mistimed hit.
private Dictionary<ImpactDetector, int> detectorHitCountCurrent streak per impact detector, used for the damage multiplier.
private Dictionary<uint, ImpactDetector> detectorMapMaps held item entity ids to their impact detectors.
private TransformEvent dissipatedEffectEffect played when the pulse ends.
private PositionRotationEvent goodHitEffectEffect played on a well timed hit.
private int hitCountStreak count sent in the next message.
private bool isActiveWhether the skill is active, sent in the next message.
private int levelsCountNumber of streak levels; matches the multiplier array.
private SteelSong.MessageType messageTypeWho the next message is for: the local player, other players or the server.
private float minimumEffectivenessHits at or below this effectiveness are ignored.
private float precisionLeewayHow close to the end of the pulse (seconds left) a hit must land to count.
private PooledObjectDefinition pulseEffectPooled SteelSongEffect that shows the rhythm.

Methods​

MemberWhat it is
override void Deregister(ISkillInputMethod input)Stops tracking the held item and tells the player the skill is off.
override void Register(ISkillInputMethod input)Starts tracking the held item's impact detector and tells the local player the skill is on.
override void SendSerializedMessage(IPlayer player, Stream stream)Serializes the item id, hit count and message kind. The server stores counts from clients and runs the skill at the top level.
override bool ValidatePickup(HeldPickupHandler pickupHandler)True if the item has a forged point under 95% progress.
protected override void OnValidate()Sets levelsCount to the length of activeDamageMultiplierPerHit.
7 private and internal methods
MemberWhat it is
private void CheckHitCount(ImpactHit impact)Client: on the local player's tool hit, a well timed hit raises the streak and a mistimed one resets it, then reports the count to the server.
private void CheckHitDamage(ImpactHit impact)Multiplies a hit's damage by the entry in activeDamageMultiplierPerHit for the item's current streak.
private void MaxHitCountSoundEffect(ImpactHit impact)Plays the good hit effect for other players watching an active streak.
private void ReleaseImpactorEffect(PooledObject pooledObject)Ends a pulse effect: plays the dissipate effect, releases it and, on the server, stores the hit count.
private void ReleaseImpactorEffect(PooledObject pooledObject, ImpactDetector detector)Ends a pulse effect: plays the dissipate effect, releases it and, on the server, stores the hit count.
private void SendStatusToLocalPlayer(ISkillInputMethod input, bool isActive)Server: tells the holding player (and others, when turning off) whether the skill is active.
private void SetupForEntity(NetworkEntity entity, bool isActive, SteelSong.MessageType messageType)Client: hooks the hit handlers on the item's forged model, timing for the holder and sound only for others.