public void OnTriggerExit(Collider other) { if (VisitableLocation == null || !VisitableLocation.Initialized) { return; } if (other.isTrigger) { return; } if (other.gameObject.layer == Globals.LayerNumPlayer) { VisitableLocation.PlayerLeave(); if (VisitableLocation.PlayerOnly) { return; } } //do we care about any world items? if (other.gameObject.layer == Globals.LayerNumWorldItemActive && VisitableLocation.ItemsOfInterest.Count > 0) { mIoiCheck = null; if (WorldItems.GetIOIFromCollider(other, out mIoiCheck) && mIoiCheck.IOIType == ItemOfInterestType.WorldItem && mIoiCheck.worlditem.HasAtLeastOne(VisitableLocation.ItemsOfInterest)) { VisitableLocation.ItemOfInterestLeave(mIoiCheck.worlditem); } } }
public void OnTriggerEnter(Collider other) { if (other.isTrigger) { return; } if (WorldItems.GetIOIFromCollider(other, out LastItemOfInterest) && Flags.Check((uint)TriggeredBy, (uint)LastItemOfInterest.IOIType, Flags.CheckType.MatchAny)) { trigger.TryToTrigger(); } }
public void OnCollisionEnter(Collision other) { if (other.gameObject.collider.isTrigger) { return; } if (Props.HasThorns) { if (WorldItems.GetIOIFromCollider(other.collider, out Plants.Get.ThornDamage.Target)) { DamageManager.Get.SendDamage(Plants.Get.ThornDamage); } } }
protected override void HandleEncounter(UnityEngine.Collider other) { //this will cover most cases including the player mlisteningItemCheck = (IListener)other.GetComponent(typeof(IListener)); if (mlisteningItemCheck == null) { //whoops, we have to do some heavy lifting //see if it's a world item mIoiCheck = null; mlistenerCheck = null; if (WorldItems.GetIOIFromCollider(other, out mIoiCheck) && mIoiCheck.IOIType == ItemOfInterestType.WorldItem && mIoiCheck.worlditem.Is <Listener>(out mlistenerCheck)) { mlisteningItemCheck = mlistenerCheck; } } //unlike the visibility bubble //listeners are responsible for figuring out whether they can hear the item //so just add it to the list and it'll be pushed in OnUpdateAwareness Listeners.SafeAdd(mlisteningItemCheck); }
public void OnTriggerEnter(Collider other) { if (mStartedDestroying || mDestroyed) { return; } IItemOfInterest ioi = null; if (WorldItems.GetIOIFromCollider(other, out ioi)) { Listener listener = null; if (ioi.IOIType == ItemOfInterestType.WorldItem && ioi.worlditem.Is <Listener> (out listener) && !Listeners.Contains(listener)) { Listeners.Add(listener); if (!string.IsNullOrEmpty(ParentSpeech.OnAudibleCommand)) { listener.HearCommand(this, ParentSpeech.OnAudibleCommand); } } } }
public void Update() { if (!mInitialized) { return; } if (Cooldown) { if (Trail == null || LaunchedProjectile == null) { //trail has self-destructed enabled = false; GameObject.Destroy(this); GameObject.Destroy(ProjectileDoppleganger); } else { ProjectileDoppleganger.transform.position = LaunchedProjectile.worlditem.tr.position; ProjectileDoppleganger.transform.rotation = LaunchedProjectile.worlditem.tr.rotation; } return; } //send the projectile along the parameter CurrentTime += WorldClock.RTDeltaTime; Last3DPosition = Current3DPosition; UpdatePositionAlongTrajectory(CurrentTime); ProjectileDoppleganger.transform.localPosition = new Vector3(0f, Current2DPosition.y, Current2DPosition.x); Current3DPosition = ProjectileDoppleganger.transform.position; ProjectileDoppleganger.transform.position = Current3DPosition; CurrentForce = Vector3.Distance(Current3DPosition, Last3DPosition); CurrentOrientation = (Current3DPosition - Last3DPosition).normalized; if (CurrentOrientation != Vector3.zero) { ProjectileDoppleganger.transform.rotation = Quaternion.LookRotation(CurrentOrientation, Vector3.up); } //let worlditems in our potential path know that the need to be 'active' //otherwise the projectile might go right through them WorldItems.Get.SetActiveStateOverride(Current3DPosition, CurrentForce * 2); RaycastHit hitInfo; if (Physics.Linecast(Last3DPosition, Current3DPosition, out hitInfo, Globals.LayersActive)) { IItemOfInterest target = null; BodyPart bodyPart = null; if (!hitInfo.collider.isTrigger) { if (WorldItems.GetIOIFromCollider(hitInfo.collider, out target, out bodyPart)) { if (target.IOIType == ItemOfInterestType.Player) { //Debug.Log ("Was player"); return; } mDamage.Point = hitInfo.point; mDamage.ForceSent = (CurrentForce + InitialLaunchForce) / 2; mDamage.Target = target; DamageManager.Get.SendDamage(mDamage, bodyPart); } LaunchedProjectile.worlditem.tr.position = ProjectileDoppleganger.transform.position; LaunchedProjectile.worlditem.tr.rotation = ProjectileDoppleganger.transform.rotation; LaunchedProjectile.OnCollide(hitInfo.collider, hitInfo.point); OnReachEnd(); } } }