public void OnTriggerEnter(Collider other)
        {
            if (other.isTrigger)
            {
                return;
            }

            bool sendAvatarAction = false;

            if (WorldItems.GetIOIFromCollider(other, out mIoiCheck) && mIoiCheck.IOIType == ItemOfInterestType.WorldItem)
            {
                if (mIoiCheck.HasAtLeastOne(ObstructionTypes))
                {
                    LastItemsEncountered.Add(mIoiCheck.worlditem);
                    mCleanListNextFrame = true;
                    sendAvatarAction    = true;
                }
                //always send OnPlayerEncounter regardless of whether it's an obstruction
                //this is used by creatures and plants etc.
                mIoiCheck.worlditem.OnPlayerEncounter.SafeInvoke();
                if (sendAvatarAction)
                {
                    //only send the avatar action if we've encountered one of the obstruction types
                    Player.Get.AvatarActions.ReceiveAction((AvatarAction.PathEncounterObstruction), WorldClock.AdjustedRealTime);
                }
            }
        }
    public void OnTriggerExit(Collider other)
    {
        if (other.isTrigger || !GameManager.Is(FGameState.InGame))
        {
            return;
        }

        IItemOfInterest ioi = null;

        if (WorldItems.GetIOIFromCollider(other, out ioi))
        {
            if (LastExitedItemOfInterest != ioi)
            {
                LastExitedItemOfInterest = ioi;
                if (ioi.IOIType == ItemOfInterestType.Player)
                {
                    Debug.Log("Player exited water in 'WaterSubmergeObjects'");
                    Player.Get.AvatarActions.ReceiveAction(AvatarAction.MoveExitWater, WorldClock.AdjustedRealTime);
                }
                else if (ioi.IOIType == ItemOfInterestType.WorldItem && ioi.worlditem.Is(WILoadState.Initialized))
                {
                    ioi.worlditem.OnExitBodyOfWater.SafeInvoke();
                }
                OnItemOfInterestExitWater.SafeInvoke();
                if (LastSubmergedItemOfInterest == ioi)
                {
                    LastSubmergedItemOfInterest = null;
                }
            }
        }
    }
Exemple #3
0
        public void OnTriggerEnter(Collider other)
        {
            if (!IsInEffect)
            {
                return;
            }

            bool intersection = true;

            if (RequireLineOfSight)
            {
                Debug.Log("Requires line of sight, checking now...");
                //check if we can see it
                RaycastHit hitInfo;
                if (Physics.Raycast(
                        tr.position,
                        Vector3.Normalize(tr.position - other.transform.position),
                        out hitInfo,
                        Collider.radius * 1.25f,
                        OcclusionLayerMask))
                {
                    //we hit one of our occlusion layers on our way to the object
                    //so this doesn't count as a hit
                    intersection = false;
                }
            }
            IItemOfInterest ioi = null;

            if (WorldItems.GetIOIFromCollider(other, out ioi))
            {
                ItemsOfInterest.SafeEnqueue(ioi);
            }
        }
Exemple #4
0
        public void OnCollide(Collider withObject, Vector3 hitPoint)
        {
            CollidedWith = withObject;
            worlditem.ActiveStateLocked = false;
            worlditem.ActiveState       = WIActiveState.Active;
            worlditem.tr.position       = hitPoint;
            IItemOfInterest ioi      = null;
            BodyPart        bodyPart = null;

            if (gStuckToHelper == null)
            {
                gStuckToHelper = new GameObject("StuckToHelper").transform;
            }

            if (WorldItems.GetIOIFromCollider(withObject, out ioi, out bodyPart))
            {
                switch (ioi.IOIType)
                {
                case ItemOfInterestType.Player:
                    break;

                case ItemOfInterestType.Scenery:
                default:
                    StuckTo = withObject.transform;
                    break;

                case ItemOfInterestType.WorldItem:
                    ProjectileTarget projectileTarget = null;
                    if (ioi.worlditem.Is <ProjectileTarget>(out projectileTarget))
                    {
                        projectileTarget.OnHitByProjectile(this, hitPoint);
                    }
                    if (bodyPart != null)
                    {
                        StuckTo = bodyPart.tr;
                    }
                    else
                    {
                        StuckTo = ioi.worlditem.tr;
                    }
                    break;
                }
            }
            if (StuckTo != null)
            {
                gStuckToHelper.parent   = StuckTo;
                gStuckToHelper.position = worlditem.tr.position;
                gStuckToHelper.rotation = worlditem.tr.rotation;
                mStuckToLocalPosition   = gStuckToHelper.localPosition;
                mStuckToLocalRotation   = gStuckToHelper.localRotation;
                enabled = true;
            }
            worlditem.SetMode(WIMode.Frozen);
        }
Exemple #5
0
        public void OnTriggerEnter(Collider other)
        {
            IItemOfInterest target = null;

            if (!WorldItems.GetIOIFromCollider(other, out target))
            {
                return;
            }

            switch (Mode)
            {
            case TrapMode.Set:
                //uh oh
                //what kind of object are we
                switch (target.IOIType)
                {
                case ItemOfInterestType.Player:
                    //there's a chance it won't trigger
                    Skill lightStepSkill = null;
                    if (Skills.Get.LearnedSkill("LightStep", out lightStepSkill))
                    {
                        //TODO this is kind of a kludge, it should be a player script modifier
                        //a la motor or visibility
                        //we may be able to make it not trigger at all
                        if (lightStepSkill.State.MasteryLevel > UnityEngine.Random.value)
                        {
                            //don't trigger the trap, just alert the player
                            //SKILL USE
                            lightStepSkill.Use(true);
                            //the skill use will announce what happens
                            //we don't trigger it!
                            return;
                        }
                    }
                    if (TryToTrigger(target))
                    {
                        Player.Local.Status.AddCondition("BrokenBone");
                    }
                    break;

                case ItemOfInterestType.WorldItem:
                    TryToTrigger(target);
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
        }
Exemple #6
0
        public void OnTriggerEnter(Collider other)
        {
            if (other.isTrigger)
            {
                return;                //lights will be handled elsewhere
            }
            if (mIsDispersed | mDispersing)
            {
                return;
            }

            switch (other.gameObject.layer)
            {
            case Globals.LayerNumPlayer:
                if (Vector3.Distance(Player.Local.Position, Position) > Collider.radius)
                {
                    Player.Local.Status.AddCondition("Darkrot");
                    MasterAudio.PlaySound(MasterAudio.SoundType.Darkrot, mTr, "DarkrotInfect");
                    FXManager.Get.SpawnFX(Position, "AcidShower");
                    DarkrotAmount = 0f;
                    Disperse(Mathf.Infinity);
                }
                break;

            case Globals.LayerNumWorldItemActive:
                //maybe we're Luminte?
                mIoiCheck = null;
                if (WorldItems.GetIOIFromCollider(other, out mIoiCheck) && mIoiCheck.IOIType == ItemOfInterestType.WorldItem)
                {
                    mluminiteCheck     = null;
                    mluminiteNodeCheck = null;
                    if (mIoiCheck.worlditem.Is <Luminite> (out mluminiteCheck) && !mluminiteCheck.IsDark)
                    {
                        DarkrotAmount = mluminiteCheck.AbsorbDarkrot(DarkrotAmount);
                        MasterAudio.PlaySound(MasterAudio.SoundType.Darkrot, mTr, "DarkrotAbsorb");
                    }
                    else if (mIoiCheck.worlditem.Is <LuminiteNode> (out mluminiteNodeCheck) && !mluminiteNodeCheck.IsDark)
                    {
                        DarkrotAmount = mluminiteNodeCheck.AbsorbDarkrot(DarkrotAmount);
                        MasterAudio.PlaySound(MasterAudio.SoundType.Darkrot, mTr, "DarkrotAbsorb");
                    }
                    if (DarkrotAmount <= 0f)
                    {
                        Disperse(Mathf.Infinity);
                    }
                }
                break;

            default:
                break;
            }
        }
 public void HandleControllerCollision(Collider other)
 {
     if (WorldItems.GetIOIFromCollider(other, out mIoiCheck) && mIoiCheck.IOIType == ItemOfInterestType.WorldItem)
     {
         if (mIoiCheck.HasAtLeastOne(ObstructionTypes))
         {
             LastItemsEncountered.Add(mIoiCheck.worlditem);
         }
         //always send OnPlayerCollide regardless of whether it's an obstruction
         //this is used by creatures and plants etc.
         mIoiCheck.worlditem.OnPlayerCollide.SafeInvoke();
     }
 }
Exemple #8
0
        public void OnCollisionEnter(Collision other)
        {
            if (other.collider == null || other.collider.isTrigger)
            {
                return;
            }

            if (HasPlantProps && Props.HasThorns)
            {
                if (WorldItems.GetIOIFromCollider(other.collider, out Plants.Get.ThornDamage.Target))
                {
                    DamageManager.Get.SendDamage(Plants.Get.ThornDamage);
                }
            }
        }
Exemple #9
0
 public void OnTriggerEnter(Collider other)
 {
     if (State.ForceCharacterToSleepOnStartup)
     {
         IItemOfInterest potentialOccupant = null;
         if (WorldItems.GetIOIFromCollider(other, out potentialOccupant))
         {
             if (potentialOccupant.IOIType == ItemOfInterestType.WorldItem && potentialOccupant.worlditem.Is <Character>(out Occupant))
             {
                 Occupant.SleepInBed(this);
                 BedTrigger.enabled = false;
             }
         }
     }
 }
Exemple #10
0
        public void Update()
        {
            CameraFX.Get.SetSpyglass(true);
            //from now on we'll control where the player looks
            if (worlditem.State == "Extended")
            {
                Player.Local.ZoomCamera(mFieldOfView, ExtendedCameraSensitivity);
            }
            else
            {
                Player.Local.ZoomCamera(mFieldOfViewCollapsed, ExtendedCameraSensitivity);
            }

            CanPlaceMarker = false;
            RaycastHit[] hits                 = Physics.RaycastAll(Player.Local.HeadPosition, Player.Local.FocusVector, SpyglassSkill.EffectRadius * Globals.RaycastSpyGlassDistanceMultiplier, Globals.LayersActive);
            bool         hitSomething         = false;
            float        closestDistanceSoFar = Mathf.Infinity;
            float        currentDistance;

            for (int i = 0; i < hits.Length; i++)
            {
                CanPlaceMarker  = true;
                currentDistance = Vector3.Distance(hits[i].point, LookerRoot.position);
                if (currentDistance < closestDistanceSoFar)
                {
                    //this is where we'll add our marker
                    closestDistanceSoFar = currentDistance;
                    MapMarkerLocation    = hits[i].point;
                }
                //now see if we reveal anything
                if (WorldItems.GetIOIFromCollider(hits[i].collider, out ioi) && ioi.IOIType == ItemOfInterestType.WorldItem)
                {
                    if (ioi.worlditem.Is <Revealable>(out revealable) && !revealable.State.HasBeenRevealed)
                    {
                        MasterAudio.PlaySound(MasterAudio.SoundType.Notifications, "PathMarkerReveal");
                        GUIManager.PostInfo("Revealed location");
                        revealable.Reveal(LocationRevealMethod.ByTool);
                    }
                    if (ioi.worlditem.Is <Location>(out location))
                    {
                        if (location.IsCivilized)
                        {
                            Player.Local.Surroundings.AddCivilizationBoost(SpyglassSkill.EffectTime);
                        }
                    }
                }
            }
        }
Exemple #11
0
        public void OnTriggerEnter(Collider other)
        {
            IItemOfInterest ioi = null;

            if (WorldItems.GetIOIFromCollider(other, out ioi) && ioi != worlditem)
            {
                State.TrapDamage.Target = ioi;
                State.TrapDamage.Origin = worlditem.Position;
                State.TrapDamage.Point  = worlditem.Position;
                DamageManager.Get.SendDamage(State.TrapDamage);
                if (State.TrapDamage.HitTarget)
                {
                    State.NumTargetsHit++;
                }
            }
        }
Exemple #12
0
        public void OnTriggerEnter(Collider other)
        {
            IItemOfInterest ioi = null;
            ComradeRing     otherComradeRing;

            if (WorldItems.GetIOIFromCollider(other, out ioi))
            {
                if (ioi.IOIType == ItemOfInterestType.WorldItem && ioi.worlditem.Is <ComradeRing>(out otherComradeRing))
                {
                    NearbyRings.SafeAdd(otherComradeRing);
                    worlditem.State      = "Glowing";
                    GlowingFlare.enabled = true;
                    enabled = true;
                }
            }
        }
    public void OnTriggerEnter(Collider other)
    {
        if (other.isTrigger || !GameManager.Is(FGameState.InGame))
        {
            return;
        }

        IItemOfInterest ioi = null;

        if (WorldItems.GetIOIFromCollider(other, out ioi))
        {
            if (ioi != LastSubmergedItemOfInterest)
            {
                LastSubmergedItemOfInterest = ioi;
                if (ioi.IOIType == ItemOfInterestType.Player)
                {
                    Debug.Log("Submerging player in 'WaterSubmergeObjects'");
                    Player.Get.AvatarActions.ReceiveAction(AvatarAction.MoveEnterWater, WorldClock.AdjustedRealTime);
                    FXManager.Get.SpawnFX(ioi.Position, "Water Splash 1");
                    AudioManager.MakeWorldSound(ioi, MasterAudio.SoundType.JumpLandWater, "Land");
                }
                else if (ioi.IOIType == ItemOfInterestType.WorldItem && ioi.worlditem.Is(WILoadState.Initialized))
                {
                    FXManager.Get.SpawnFX(ioi.Position, "Water Splash 1");
                    AudioManager.MakeWorldSound(ioi, MasterAudio.SoundType.JumpLandWater, "Land");
                    Buoyant b = null;
                    if (ioi.worlditem.Is <Buoyant> (out b))
                    {
                        b.Water = Water;
                    }
                    if (ioi.worlditem.CanBeCarried)
                    {
                        ioi.worlditem.SetMode(WIMode.World);
                    }
                    ioi.worlditem.OnEnterBodyOfWater.SafeInvoke();
                }
                OnItemOfInterestEnterWater.SafeInvoke();
                if (LastExitedItemOfInterest == ioi)
                {
                    LastExitedItemOfInterest = null;
                }
            }
        }
    }
Exemple #14
0
        protected override void HandleEncounter(UnityEngine.Collider other)
        {
            //this will cover most cases including the player
            mVisibleItemCheck = (IVisible)other.GetComponent(typeof(IVisible));
            if (mVisibleItemCheck == null)
            {
                //whoops, we have to do some heavy lifting
                //see if it's a world item
                mIoiCheck = null;
                if (WorldItems.GetIOIFromCollider(other, out mIoiCheck) && mIoiCheck.IOIType == ItemOfInterestType.WorldItem)
                {
                    mVisibleItemCheck = mIoiCheck.worlditem;
                }
            }

            //make sure our parent object gives a damn
            if (mVisibleItemCheck != null &&
                Flags.Check((uint)mVisibleItemCheck.IOIType, (uint)ParentObject.State.VisibleTypesOfInterest, Flags.CheckType.MatchAny) &&
                mVisibleItemCheck.HasAtLeastOne(ParentObject.State.ItemsOfInterest))
            {
                VisibleItems.SafeAdd(mVisibleItemCheck);
            }
        }