Skip to main content

SeedSpray

A class in Root.Township, Alta.Intelligence.

Fires a burst of pooled seed projectiles in a cone, used by plant creatures through SeedSprayManager. The server shoots and decides hits; clients replay each burst from a synced random seed.

Constructors​

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

Fields​

24 private and internal fields
MemberWhat it is
private AnimationCurve aliveCutoffCurve over time of the share of seeds that should have expired by then.
private float angleWidth of the spray cone in degrees (default 90).
private SeedSpray.Seed[][] currentShotsSeed arrays for up to 8 shots in flight.
private MethodSync destroyedMethod sync for a destroyed seed.
private MethodSync finishedMethod sync for a finished shot.
private PooledObjectDefinition hitDefinitionPooled effect played where a seed dies.
private float maximumAngularVelocityHighest spin given to a seed.
private int maximumCountMost seeds per shot (exclusive upper bound of the random count).
private float maximumVelocityHighest launch speed of a seed.
private float minimumAngularVelocityLowest spin given to a seed.
private int minimumCountFewest seeds per shot.
private float minimumVelocityLowest launch speed of a seed.
private int nextShotIndex of the next shot slot, wrapping at 8.
private PositionHandler plantHandlerCalled with the hit point when a seed lands somewhere it can plant.
private LayerMask plantLayerLayers a seed can plant on.
private float plantNormalThresholdHow upward the hit surface must face to plant (default 0.6).
private PooledObjectDefinition seedDefinitionPooled object for each seed projectile.
private MethodSync shootMethod sync that starts a burst on clients.
private int shootingCountNumber of shots still in flight.
private MethodSyncStruct<SeedSpray.BasicImpactSyncArguments> syncBasicImpactMethod sync for seed hits.
private MethodSync syncParentMethod sync for the spray's parent.
private int syncSeedRandom seed of the shot being synced.
private int syncSeedIndexIndex of the seed being synced as destroyed.
private int syncShotIndexIndex of the shot being synced.

Properties​

MemberWhat it is
ITarget Shooter { get; set; }The creature that fired the spray, set by SeedSprayManager.
1 private and internal property
MemberWhat it is
private ITarget Alta.Intelligence.ITargetPointer.Target { get; }Returns Shooter.

Methods​

MemberWhat it is
override void Initialize()Creates the method syncs for parent, shoot, destroyed, finished and impacts.
void InitializeSpray(HealthObject healthObject)Hooks the owner's health so the spray detaches when the owner dies mid-burst.
override void OnConnected(Player player)Sends a joining player the spray's parent.
void Shoot()Server: starts a new burst with a random seed, syncs it to the chunk and fires it. The private overload spawns and launches the seeds.
void SyncBasicImpact(IPlayer player, Stream stream, SeedSpray.BasicImpactSyncArguments hit)Method sync handler that rebuilds a seed's hit from its arguments and applies it to the struck detector on the receiving side.
11 private and internal methods
MemberWhat it is
private void CheckPlant(ImpactHitWithTool hit)If a seed hits an upward-facing surface on the plant layer, calls the plant handler at that point.
private void Destroy(SeedSpray.Seed seed)Kills a live seed: plays the hit effect and releases it to the pool.
private void OnDisable()Releases every live seed and clears all shots.
private void OnDrawGizmosSelected()Editor: draws the spray cone.
private void Shoot(int shotIndex, int seed, Vector3 position, Quaternion rotation)Server: starts a new burst with a random seed, syncs it to the chunk and fires it. The private overload spawns and launches the seeds.
private void SyncDestroyed(IPlayer player, Stream stream)Method sync handler that destroys one seed of a shot on clients.
private void SyncFinished(IPlayer player, Stream stream)Method sync handler that frees a finished shot's seed array on clients.
private void SyncParent(IPlayer player, Stream stream)Method sync handler for the spray's parent entity; clients reparent it, or move it to the spawned folder if none.
private void SyncShoot(IPlayer player, Stream stream)Method sync handler that sends shot index, random seed, position and rotation; clients fire the same burst.
private IEnumerator TimedShootItems(int shotIndex, SeedSpray.Seed[] seeds, int count) (iterator)Coroutine that arms the seeds after 0.3 s, handles their hits, and on the server expires them over time, then ends the shot.
private void Unchild(HealthObject healthObject)When the owner dies while shooting, detaches the spray so it can finish; it destroys itself once the shots are done.

Used in​

Members of other types that take, return or hold a SeedSpray: