// Token: 0x06002147 RID: 8519 RVA: 0x00090090 File Offset: 0x0008E290 private void DoSearch() { if (this.ai.body) { Ray aimRay = this.ai.bodyInputBank.GetAimRay(); this.search.viewer = this.ai.body; this.search.filterByDistinctEntity = true; this.search.filterByLoS = false; this.search.maxDistanceFilter = float.PositiveInfinity; this.search.minDistanceFilter = 0f; this.search.maxAngleFilter = 360f; this.search.searchDirection = aimRay.direction; this.search.searchOrigin = aimRay.origin; this.search.sortMode = BullseyeSearch.SortMode.Distance; this.search.queryTriggerInteraction = QueryTriggerInteraction.UseGlobal; TeamMask none = TeamMask.none; none.AddTeam(this.ai.master.teamIndex); this.search.teamMaskFilter = none; this.search.RefreshCandidates(); this.search.FilterOutGameObject(this.ai.body.gameObject); BaseAI.Target customTarget = this.ai.customTarget; HurtBox hurtBox = this.search.GetResults().Where(new Func <HurtBox, bool>(this.TargetPassesFilters)).FirstOrDefault <HurtBox>(); customTarget.gameObject = ((hurtBox != null) ? hurtBox.healthComponent.gameObject : null); } }
private void GenerateSphereSearch(CharacterBody origin, bool getSameTeam = false) { List <HurtBox> hurtBoxesList = new List <HurtBox>(); TeamMask enemyTeams = TeamMask.GetEnemyTeams(origin.teamComponent.teamIndex); SphereSearch sphereSearch = new RoR2.SphereSearch() { mask = LayerIndex.entityPrecise.mask, origin = origin.transform.position, queryTriggerInteraction = QueryTriggerInteraction.Collide, radius = sphereSearchRadius }; #if DEBUG TurboEdition._logger.LogWarning(EquipmentName + ": generated " + sphereSearch + " with radius " + sphereSearchRadius + " and origin " + origin.transform); #endif if (!getSameTeam) { #if DEBUG TurboEdition._logger.LogWarning(EquipmentName + ": filtering the sphereSearch by enemy teams."); #endif sphereSearch.RefreshCandidates().FilterCandidatesByHurtBoxTeam(enemyTeams).FilterCandidatesByDistinctHurtBoxEntities().GetHurtBoxes(hurtBoxesList); } else { #if DEBUG TurboEdition._logger.LogWarning(EquipmentName + ": filtering the sphereSearch by SAME TEAM as origin."); #endif TeamMask selfdestructionguaranteed = new TeamMask(); selfdestructionguaranteed.AddTeam(origin.teamComponent.teamIndex); sphereSearch.RefreshCandidates().FilterCandidatesByHurtBoxTeam(selfdestructionguaranteed).FilterCandidatesByDistinctHurtBoxEntities().GetHurtBoxes(hurtBoxesList); } for (int i = 0, j = 0; i < hurtBoxesList.Count && j < sphereLinkCount; i++) { var hc = hurtBoxesList[i].healthComponent; if (hc) { var body = hc.body; if (body) { var linkGameObject = body.GetComponentInChildren <LinkComponent>()?.gameObject; #if DEBUG TurboEdition._logger.LogWarning(EquipmentName + ": adding linkedBuff to someone, theres " + (i + 1) + " out of " + hurtBoxesList.Count + " hurtboxes with max " + sphereLinkCount); #endif body.AddTimedBuff(linkedBuff, linkedBuffDuration); if (!linkGameObject) { //If they dont have a component that means they are brand new and unique //If they do, this doesn't get executed and they just get their debuff updated j++; } } } } }
private void DoTether() { if (this.hasFired) { return; } this.hasFired = true; Debug.Log("Setting tether handler!"); //base.isAuthority -> will only run on local machine //if (base.isAuthority) //{ tetherHandler = base.GetComponent <TetherHandler>(); HurtBox closestHurtbox = null; Debug.Log("Raycasting!"); //First check to see if we're aiming at a valid target Ray aimRay = base.GetAimRay(); RaycastHit raycastHit = new RaycastHit(); bool foundTarget = Physics.Raycast(aimRay, out raycastHit, maxDistanceFilter); if (foundTarget && raycastHit.collider.GetComponent <HurtBox>()) { TeamIndex targetTeamIndex = raycastHit.collider.GetComponent <HurtBox>().healthComponent.body.teamComponent.teamIndex; //Make sure we're not targeting the enemy team if (base.GetTeam() == targetTeamIndex) { closestHurtbox = raycastHit.collider.GetComponent <HurtBox>(); Debug.Log("Found aimed at object " + closestHurtbox.transform.root.name); } } //If we weren't aiming at something, just search for a valid nearby target else { //Search for all nearby targets BullseyeSearch bullseyeSearch = new BullseyeSearch(); bullseyeSearch.searchOrigin = base.transform.position; bullseyeSearch.searchDirection = UnityEngine.Random.onUnitSphere; bullseyeSearch.maxDistanceFilter = maxDistanceFilter; TeamMask sameTeamMask = new TeamMask(); sameTeamMask.AddTeam(base.GetTeam()); bullseyeSearch.teamMaskFilter = sameTeamMask; //Sort by distance bullseyeSearch.sortMode = BullseyeSearch.SortMode.Distance; bullseyeSearch.RefreshCandidates(); //Remove ourselves from the search results //(shouldn't be there in the first place, but hey) bullseyeSearch.FilterOutGameObject(base.gameObject); //Get the closest hurtbox closestHurtbox = bullseyeSearch.GetResults().FirstOrDefault <HurtBox>(); Debug.Log("Found local object " + closestHurtbox.transform.root.name); if (closestHurtbox == default(HurtBox)) { Debug.LogError("Default value!"); } if (closestHurtbox == null) { Debug.LogError("Null value!"); } } //Set up our grapple handler if (tetherHandler == null) { tetherHandler = base.gameObject.AddComponent <TetherHandler>(); Debug.LogWarning("Added grapple handler via tether function"); return; } //Then establish our grapple target if (closestHurtbox == null) { Debug.LogError("Null hurtbox"); return; } //If we've successfully established a tether else if (closestHurtbox) { Debug.Log("Attempting to establish tether"); //If adding a new grapple target would go beyond our max stock int curNumGrappled = tetherHandler.GetGrappleTargets().Count; if (curNumGrappled + 1 > base.activatorSkillSlot.maxStock) { //Remove the oldest grapple target tetherHandler.ClearGrappleTarget(tetherHandler.GetGrappleTargets()[0]); } tetherHandler.SetGrappleTarget(closestHurtbox); tetherHandler.TETHER_TYPE = TETHER_TYPE.TETHER; Debug.Log("Set grapple target"); base.characterBody.AddBuff(WispSurvivor.Modules.Buffs.sustainSelf); closestHurtbox.healthComponent.body.AddBuff(WispSurvivor.Modules.Buffs.sustainTarget); } //} /* * this.animator = base.GetModelAnimator(); * this.muzzleString = "Muzzle"; * * * base.PlayAnimation("Gesture, Override", "FireGrapple", "FireGrapple.playbackRate", this.duration); */ }