Esempio n. 1
0
 /// <summary>
 /// Perform a sphere overlap against Ascension hiboxes
 /// </summary>
 /// <param name="origin">The origin of the sphere</param>
 /// <param name="radius">The radius of the sphere</param>
 /// <param name="frame">The frame to rollback to for calculation</param>
 /// <returns>The hitboxes that overlapped with the sphere</returns>
 /// <example>
 /// *Example:* Calculating the blast radius of a grenade.
 ///
 /// ```csharp
 /// void GrenadeOwner(PlayerCommand cmd, AscensionEntity entity, IThrownWeapon grenade) {
 ///   if(entity.isOwner) {
 ///     using(var hits = AscensionNetwork.OverlapSphereAll(cmd.targetPos, grenade.explosionRadius, cmd.ServerFrame)) {
 ///       for(int i = 0; i < hits.count; i++) {
 ///         var hit = hits.GetHit(i);
 ///         var targetEntity = hit.body.GetComponent&ltAscensionEntity&gt();
 ///
 ///         if(targetEntity != entity && targetEntity.StateIs&ltILivingEntity&gt()) {
 ///             targetEntity.GetState&ltILivingEntity&gt().Modify().HP -= grenade.damage;
 ///         }
 ///       }
 ///     }
 ///   }
 /// }
 /// ```
 /// </example>
 public static AscensionPhysicsHits OverlapSphereAll(Vector3 origin, float radius, int frame)
 {
     AscensionNetwork.VerifyIsRunning();
     return(AscensionPhysics.OverlapSphere(origin, radius, frame));
 }
Esempio n. 2
0
 /// <summary>
 /// Perform a raycast against Ascension hitboxes
 /// </summary>
 /// <param name="ray"><The ray to/param>
 /// <param name="frame">The frame to roll back to when performing this raycast</param>
 /// <returns>The hitboxes that intersected the ray</returns>
 /// <example>
 /// *Example:* Using RaycastAll to detect a hit event on a specific previous frame and then apply damage in a player weapon firing method.
 ///
 /// ```csharp
 /// void FireWeaponOwner(PlayerCommand cmd, AscensionEntity entity) {
 ///   if(entity.isOwner) {
 ///     using(var hits = AscensionNetwork.RaycastAll(new Ray(entity.transform.position, cmd.Input.targetPos),
 ///       cmd.ServerFrame)) {
 ///       var hit = hits.GetHit(0);
 ///       var targetEntity = hit.body.GetComponent&ltAscensionEntity&gt();
 ///
 ///       if(targetEntity.StateIs&ltILivingEntity&gt()) {
 ///         targetEntity.GetState&ltILivingEntity&gt().Modify().HP -= activeWeapon.damage;
 ///       }
 ///     }
 ///   }
 /// }
 /// ```
 /// </example>
 public static AscensionPhysicsHits RaycastAll(Ray ray, int frame)
 {
     AscensionNetwork.VerifyIsRunning();
     return(AscensionPhysics.Raycast(ray, frame));
 }