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.
- Listed in Creatures and AI
- Inherits or implements
NetworkEntityBehaviour,ITargetPointer - Nested types
BasicImpactSyncArguments,Seed - Documented in Combat, damage and death
Constructors
| Member | What it is |
|---|---|
SeedSpray() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
24 private and internal fields
| Member | What it is |
|---|---|
private AnimationCurve aliveCutoff | Curve over time of the share of seeds that should have expired by then. |
private float angle | Width of the spray cone in degrees (default 90). |
private SeedSpray.Seed[][] currentShots | Seed arrays for up to 8 shots in flight. |
private MethodSync destroyed | Method sync for a destroyed seed. |
private MethodSync finished | Method sync for a finished shot. |
private PooledObjectDefinition hitDefinition | Pooled effect played where a seed dies. |
private float maximumAngularVelocity | Highest spin given to a seed. |
private int maximumCount | Most seeds per shot (exclusive upper bound of the random count). |
private float maximumVelocity | Highest launch speed of a seed. |
private float minimumAngularVelocity | Lowest spin given to a seed. |
private int minimumCount | Fewest seeds per shot. |
private float minimumVelocity | Lowest launch speed of a seed. |
private int nextShot | Index of the next shot slot, wrapping at 8. |
private PositionHandler plantHandler | Called with the hit point when a seed lands somewhere it can plant. |
private LayerMask plantLayer | Layers a seed can plant on. |
private float plantNormalThreshold | How upward the hit surface must face to plant (default 0.6). |
private PooledObjectDefinition seedDefinition | Pooled object for each seed projectile. |
private MethodSync shoot | Method sync that starts a burst on clients. |
private int shootingCount | Number of shots still in flight. |
private MethodSyncStruct<SeedSpray.BasicImpactSyncArguments> syncBasicImpact | Method sync for seed hits. |
private MethodSync syncParent | Method sync for the spray's parent. |
private int syncSeed | Random seed of the shot being synced. |
private int syncSeedIndex | Index of the seed being synced as destroyed. |
private int syncShotIndex | Index of the shot being synced. |
Properties
| Member | What it is |
|---|---|
ITarget Shooter { get; set; } | The creature that fired the spray, set by SeedSprayManager. |
1 private and internal property
Methods
| Member | What 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
| Member | What 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: