Arrow
A class in Root.Township, the global namespace.
An arrow item's flight: aligns it with its velocity while flying and, with the newer precision mode, applies seeded deviation from ArrowFlightSettings that the server syncs so every side flies the same path.
- Listed in Global namespace: A to B
- Inherits or implements
NetworkEntityBehaviour,IShootable,IToolHitDependant - Derived types
ArrowEvent,ArrowUnityEvent - Nested types
ArrowFlightSync
Constructors
| Member | What it is |
|---|---|
Arrow() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
20 private and internal fields
| Member | What it is |
|---|---|
private IUnityUpdateMethod arrowFlight | Handle of the registered flight update. |
private ArrowFlightSettings arrowSettings | Backing field for ArrowSettings; flight curves used when useNewPrecision is on. |
private NetworkEntity arrowTip | Backing field for ArrowTip. |
private float basePrecisionDeviance | Max random angle in degrees added to a shot when useNewPrecision is off. |
private Rigidbody cachedRigidbody | Backing field for Rigidbody. |
private JointSlot[] craftedParts | Joint slots for the crafted parts. Not read in this class. |
private Embeddable embeddable | The arrow's Embeddable; embedding stops the flight. |
private float flightSpeed | Launch speed used by the complex flight. |
private float flightTime | Seconds since the complex flight started. |
private ImpactTool impactTool | Backing field for ImpactTool. |
private static Logger logger | NLog logger for this class. |
private float materialWeightModifier | Weight factor from the arrow's weight and material tightness, passed to the flight settings. |
private float maxExtra | Extra weight factor per unit of weight added to materialWeightModifier. Defaults to 0.1. |
private float minSquareVelocityForAligning | Squared speed above which the arrow is turned to face its velocity. Defaults to 10. |
private ArrowEvent onShotOnServer | Event behind ShotOnServer, invoked on the server when the arrow is shot. |
private PhysicalMaterialPart physicalMaterial | Material part whose tightness multiplier affects materialWeightModifier. |
private int randomSeed | Seed for the editor gizmo preview only. Flight seeds come from the shot. |
private Random.State randomState | The arrow's own random state, so the server and clients deviate the same way. |
private MethodSyncStruct<Arrow.ArrowFlightSync> syncFlight | Sync that sends flight speed and seed from the server to clients. |
private bool useNewPrecision | When on, flight uses arrowSettings and a synced seed. When off, a simple random angle at launch. |
Properties
| Member | What it is |
|---|---|
ArrowFlightSettings ArrowSettings { get; set; } | Flight settings used by the newer precision mode. |
NetworkEntity ArrowTip { get; } | The entity at the arrow's tip. Defaults to the arrow itself. |
float FinalWeight { get; } | The pickup's total weight, or 0.1 if there is no pickup. |
List<ArrowFlightSettingsModifier> FlightModifiers { get; } | Extra modifiers applied to the flight settings each step. |
bool HasBeenShot { get; private set; } | True from being shot until the flight stops. |
ImpactTool ImpactTool { get; } | The arrow's ImpactTool. |
bool IsInFlight { get; private set; } | True while the flight update is running. |
Rigidbody Rigidbody { get; } | The arrow's rigidbody. |
Events
| Member | What it is |
|---|---|
event Action<Arrow> ShotOnServer | Raised on the server when the arrow is shot. |
Methods
13 private and internal methods
| Member | What it is |
|---|---|
private void AlignWithFlightDirection() | Turns the rigidbody to face along its velocity. |
private void Awake() | Hooks StopArrowFlight to the embeddable's Embedded event. |
private void ComplexArrowFlight() | Fixed update for new-precision flight: sets velocity from arrowSettings with the arrow's own random state, then aligns it. |
private void DestroyByScene(NetworkEntity entity, bool isUnload) | Stops the flight update when the entity is destroyed by the scene. |
private bool EnsureArrowTip() | Inspector helper: sets arrowTip to this entity if it is empty. |
private void Alta.Impact.IToolHitDependant.OnCollided(Collision collision, bool isHitting, ImpactTool tool) | Stops the flight update when the arrow collides with something. |
private void OnDestroy() | Stops the flight update. |
private void OnDrawGizmosSelected() | Editor: draws the flight path preview from arrowSettings using randomSeed. |
private void Alta.Impact.IToolHitDependant.OnHit(ImpactHitWithTool hit, ImpactTool tool) | Stops the flight update when the arrow's tool hit lands. |
private void SimpleArrowFlight() | Fixed update for old-style flight: only aligns the arrow with its velocity when fast enough. |
private void StartArrowFlight(Action method) | Registers the given fixed-update flight method, marks the arrow in flight and turns on continuous collision. |
private void StopArrowFlight(Embeddable embeddable) | Stops the flight update when the arrow embeds. |
private void SyncFlight(IPlayer player, Stream stream, Arrow.ArrowFlightSync arguments) | Network handler for flight speed and seed. Clients start the same deviating flight the server did. |
Used in
Members of other types that take, return or hold a Arrow: