public void UpdateBounds(HurtBox[] hurtBoxes) { foreach(HurtBox hurtBox in hurtBoxes) if (hurtBox.followXBounds || hurtBox.followYBounds) hurtBox.rendererBounds = GetBounds(); }
/// <summary> /// Creates a "hurtbox", which are used to determine locations of damage /// </summary> /// <param name="bounds">The size of the rectangle to be created.</param> /// <param name="duration">how long the hurtbox persists.</param> /// <returns></returns> public HurtBox createHurtBox(Entity creator, Rectangle bounds, Vector2 origin, int damage, int duration, float rotation = 0f) { HurtBox h = new HurtBox(creator, bounds, origin, damage, duration, rotation); hurtboxes.Add(h); return h; }
public Vector3 TestCollision(HurtBox[] hurtBoxes, HitConfirmType hitConfirmType) { if (isHit && hitConfirmType == HitConfirmType.Hit) return Vector3.zero; foreach(HitBox hitbox in this.hitBoxes) if (hitbox.followXBounds || hitbox.followYBounds) hitbox.rendererBounds = GetBounds(); /*Vector3 result = HitBoxesScript.TestCollision(this.hitBoxes, hurtBoxes, hitConfirmType, controlsScript.mirror); if (result == Vector3.zero) { foreach (HitBox hitBox in hitBoxes) { if (hitBox.state == 1) hitBox.state = 0; } }*/ return HitBoxesScript.TestCollision(this.hitBoxes, hurtBoxes, hitConfirmType, controlsScript.mirror); }
public Vector3 TestCollision(BlockArea blockableArea) { HurtBox hurtBox = new HurtBox(); hurtBox.position = blockableArea.position; hurtBox.shape = blockableArea.shape; hurtBox.rect = blockableArea.rect; hurtBox.followXBounds = blockableArea.followXBounds; hurtBox.followYBounds = blockableArea.followYBounds; hurtBox.radius = blockableArea.radius; hurtBox.offSet = blockableArea.offSet; // We use throw confirmation type so the engine doesn't register the state of the stroke hitbox as hit return HitBoxesScript.TestCollision(this.hitBoxes, new HurtBox[]{hurtBox}, HitConfirmType.Hit, controlsScript.mirror); }
// Token: 0x06001F25 RID: 7973 RVA: 0x00087554 File Offset: 0x00085754 private bool PassesFilters(HurtBox result) { CharacterBody body = result.healthComponent.body; return(body && (!this.ignoreAir || !body.isFlying) && (!body.isFlying || float.IsInfinity(this.flierAltitudeTolerance) || this.flierAltitudeTolerance >= Mathf.Abs(result.transform.position.y - this.transform.position.y))); }
public static Vector3 TestCollision(HitBox[] hitBoxes, HurtBox[] hurtBoxes, HitConfirmType hitConfirmType, int mirror) { foreach (HitBox hitBox in hitBoxes) { if (hitBox.hide) continue; if (hitBox.collisionType == CollisionType.noCollider) continue; if (hitConfirmType == HitConfirmType.Throw && hitBox.collisionType != CollisionType.throwCollider) continue; if (hitConfirmType == HitConfirmType.Hit && hitBox.collisionType == CollisionType.throwCollider) continue; hitBox.state = 0; foreach (HurtBox hurtBox in hurtBoxes) { Vector3 hurtBoxPosition = hurtBox.position; Vector3 hitBoxPosition = hitBox.position.position; float dist = 0; bool collisionConfirm = false; if (!UFE.config.detect3D_Hits){ hurtBoxPosition.z = -1; hitBoxPosition.z = -1; } if (hurtBox.shape == HitBoxShape.circle){ if (hitBox.shape == HitBoxShape.circle){ dist = Vector3.Distance(hurtBoxPosition, hitBoxPosition); if (dist <= hurtBox.radius + hitBox.radius) collisionConfirm = true; }else if (hitBox.shape == HitBoxShape.rectangle){ float mirrorDiff = mirror > 0 ? hitBox.rect.width : 0f; Rect hitBoxRectanglePosition = new Rect(((hitBox.rect.x + mirrorDiff) * mirror) + hitBoxPosition.x, hitBox.rect.y + hitBoxPosition.y, hitBox.rect.width, hitBox.rect.height); if (hitBox.followXBounds){ hitBoxRectanglePosition.x = hitBox.rendererBounds.x - (hitBox.rect.width/2); hitBoxRectanglePosition.width = (hitBox.rendererBounds.width + hitBox.rect.width) - hitBox.rendererBounds.x; } if (hitBox.followYBounds){ hitBoxRectanglePosition.y = hitBox.rendererBounds.y - (hitBox.rect.height/2); hitBoxRectanglePosition.height = (hitBox.rendererBounds.height + hitBox.rect.height) - hitBox.rendererBounds.y; } dist = distancePointToRectangle(hurtBoxPosition, hitBoxRectanglePosition); if (dist <= hurtBox.radius) collisionConfirm = true; } }else if (hurtBox.shape == HitBoxShape.rectangle){ Rect hurtBoxRectanglePosition; if (hitBox.shape == HitBoxShape.circle){ float mirrorDiff = mirror < 0 ? hurtBox.rect.width : 0f; hurtBoxRectanglePosition = new Rect(((hurtBox.rect.x + mirrorDiff) * mirror) + hurtBoxPosition.x, hurtBox.rect.y + hurtBoxPosition.y, hurtBox.rect.width, hurtBox.rect.height); if (hurtBox.followXBounds){ hurtBoxRectanglePosition.x = hurtBox.rendererBounds.x - (hurtBox.rect.width/2); hurtBoxRectanglePosition.width = (hurtBox.rendererBounds.width + hurtBox.rect.width) - hurtBox.rendererBounds.x; } if (hurtBox.followYBounds){ hurtBoxRectanglePosition.y = hurtBox.rendererBounds.y - (hurtBox.rect.height/2); hurtBoxRectanglePosition.height = (hurtBox.rendererBounds.height + hurtBox.rect.height) - hurtBox.rendererBounds.y; } dist = distancePointToRectangle(hitBoxPosition, hurtBoxRectanglePosition); if (dist <= hitBox.radius) collisionConfirm = true; }else if (hitBox.shape == HitBoxShape.rectangle){ float mirrorDiff = mirror < 0 ? hurtBox.rect.width : 0f; hurtBoxRectanglePosition = new Rect(((hurtBox.rect.x + mirrorDiff) * mirror) + hurtBoxPosition.x, hurtBox.rect.y + hurtBoxPosition.y, hurtBox.rect.width, hurtBox.rect.height); mirrorDiff = mirror > 0 ? hitBox.rect.width : 0f; Rect hitBoxRectanglePosition = new Rect(((hitBox.rect.x + mirrorDiff) * - mirror) + hitBoxPosition.x, hitBox.rect.y + hitBoxPosition.y, hitBox.rect.width, hitBox.rect.height); if (hitBox.followXBounds){ hitBoxRectanglePosition.x = hitBox.rendererBounds.x - (hitBox.rect.width/2); hitBoxRectanglePosition.width = (hitBox.rendererBounds.width + hitBox.rect.width) - hitBox.rendererBounds.x; } if (hitBox.followYBounds){ hitBoxRectanglePosition.y = hitBox.rendererBounds.y - (hitBox.rect.height/2); hitBoxRectanglePosition.height = (hitBox.rendererBounds.height + hitBox.rect.height) - hitBox.rendererBounds.y; } if (hurtBox.followXBounds){ hurtBoxRectanglePosition.x = hurtBox.rendererBounds.x - (hurtBox.rect.width/2); hurtBoxRectanglePosition.width = (hurtBox.rendererBounds.width + hurtBox.rect.width) - hurtBox.rendererBounds.x; } if (hurtBox.followYBounds){ hurtBoxRectanglePosition.y = hurtBox.rendererBounds.y - (hurtBox.rect.height/2); hurtBoxRectanglePosition.height = (hurtBox.rendererBounds.height + hurtBox.rect.height) - hurtBox.rendererBounds.y; } if (hurtBoxRectanglePosition.Overlaps(hitBoxRectanglePosition)) collisionConfirm = true; } } if (collisionConfirm) { if (hitConfirmType == HitConfirmType.Hit) { hitBox.state = 1; } return (hurtBoxPosition + hitBoxPosition)/2; } } } foreach (HitBox hitBox in hitBoxes) { if (hitBox.state == 1) hitBox.state = 0; } return Vector3.zero; }
public void FixedUpdate() { if (NetworkServer.active) { while (enemyFollowers.Count < stack) { GameObject enemyFollower = Object.Instantiate(enemyFollowerPrefab, body.corePosition, Quaternion.identity); enemyFollower.GetComponent <GenericOwnership>().ownerObject = gameObject; NetworkServer.Spawn(enemyFollower); enemyFollowers.Add(enemyFollower.GetComponent <MysticsItemsSpotterController>()); } while (enemyFollowers.Count > stack) { MysticsItemsSpotterController enemyFollower = enemyFollowers.Last(); NetworkServer.UnSpawn(enemyFollower.gameObject); Object.Destroy(enemyFollower.gameObject); enemyFollowers.Remove(enemyFollower); } } cooldown -= Time.fixedDeltaTime; if (cooldown <= 0f) { cooldown = cooldownMax; if (NetworkServer.active) { bullseyeSearch.teamMaskFilter = TeamMask.allButNeutral; bullseyeSearch.teamMaskFilter.RemoveTeam(body.teamComponent.teamIndex); Ray ray = CameraRigController.ModifyAimRayIfApplicable(new Ray { origin = body.inputBank.aimOrigin, direction = body.inputBank.aimDirection }, body.gameObject, out _); bullseyeSearch.searchOrigin = ray.origin; bullseyeSearch.searchDirection = ray.direction; bullseyeSearch.viewer = body; bullseyeSearch.maxDistanceFilter = 200f; bullseyeSearch.RefreshCandidates(); bullseyeSearch.FilterOutGameObject(body.gameObject); List <HurtBox> enemies = bullseyeSearch.GetResults().ToList(); foreach (MysticsItemsSpotterController enemyFollower in enemyFollowers) { enemyFollower.ClearTarget(); } if (enemies.Count > 0) { Util.PlaySound("Play_item_proc_spotter", gameObject); foreach (MysticsItemsSpotterController enemyFollower in enemyFollowers) { GameObject newTarget = null; while (newTarget == null && enemies.Count > 0) { int index = Mathf.FloorToInt(enemies.Count * (Random.value * 0.99f)); HurtBox newTargetHurtBox = enemies.ElementAt(index); enemies.RemoveAt(index); if (newTargetHurtBox.healthComponent && newTargetHurtBox.healthComponent.body) { CharacterBody newTargetBody = newTargetHurtBox.healthComponent.body; if (!newTargetBody.HasBuff(buffDef)) { newTarget = newTargetBody.gameObject; } } } if (newTarget) { enemyFollower.SetTarget(newTarget); } else { enemyFollower.ClearTarget(); } } } else { cooldown = cooldownIfNoEnemiesFound; } } } }
// Token: 0x06001F27 RID: 7975 RVA: 0x000876D0 File Offset: 0x000858D0 private void SetTarget(HurtBox hurtBox) { this.lastFoundHurtBox = hurtBox; this.lastFoundTransform = ((hurtBox != null) ? hurtBox.transform : null); this.targetComponent.target = this.lastFoundTransform; }
public Hit(HurtBox box, Single distance) { this.distance = distance; this.box = box; }
// Token: 0x0600318A RID: 12682 RVA: 0x00090218 File Offset: 0x0008E418 private static bool IsHurt(HurtBox hurtBox) { return(hurtBox.healthComponent.alive && hurtBox.healthComponent.health < hurtBox.healthComponent.fullHealth); }
// Token: 0x06003189 RID: 12681 RVA: 0x000D571F File Offset: 0x000D391F private bool NotAlreadyHealingTarget(HurtBox hurtBox) { return(!HealBeamController.HealBeamAlreadyExists(base.gameObject, hurtBox)); }
protected void InitializeComponents() { Rigidbody2D = GetComponent <Rigidbody2D>(); HurtBox = GetComponentInChildren <HurtBox>(); }
public override void _Ready() { this.hurtBox = this.GetNode <HurtBox>("./HurtBox"); this.hurtBox.AttackHealthComponent(this.HealthComponent); this.hurtBox.OnHurtHandler = this.UpdateHealth; }