Ejemplo n.º 1
0
        private void OnTriggerEnter(Collider collider)
        {
            var handle = collider.GetComponentInParent<BowHandle>();

            if (handle != null && obj != null && handle.aim.IsHeld() && obj.IsGrabbed())
            {
                handle.nockSide = collider.transform;
                arrow.transform.parent = handle.arrowNockingPoint;

                CopyNotchToArrow();

                collider.GetComponentInParent<BowAim>().SetArrow(arrow);
                Destroy(gameObject);
            }
        }
Ejemplo n.º 2
0
        protected virtual void OnTriggerEnter(Collider collider)
        {
            Asteroid asteroid = collider.GetComponentInParent<Asteroid>();

            if (!Paused)
                TryCatchAsteroid(asteroid);
        }
 private void ToggleRigidbody(Collider collider, bool state)
 {
     var touch = collider.GetComponentInParent<VRTK_InteractTouch>();
     if (touch)
     {
         touch.ToggleControllerRigidBody(state, state);
     }
 }
Ejemplo n.º 4
0
 private void tryNotify(Collider other) {
   IInteractionBehaviour ib = other.GetComponentInParent<IInteractionBehaviour>();
   if (ib) {
     manager.EnsureActive(ib);
     _dislocatedCounter = 0;
     ib.NotifyBrushDislocated();
   }
 }
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Interactor")
     {
         switch (other.transform.parent.tag)
         {
             case "Customer":
                 Customer customer = other.GetComponentInParent<Customer>();
                 customer.OnInteract(this);
                 break;
             case "Staff":
                 Staff staff = other.GetComponentInParent<Staff>();
                 staff.OnInteract(this);
                 break;
         }
     }
 }
Ejemplo n.º 6
0
        private void Change(Collider target, bool targetValue)
        {
            if (target == null || !SmashGame.IsPlayer(target))
                return;

            var character = target.GetComponentInParent<Character>();

            character.IsGrounded = targetValue;
        }
 private void OnTriggerStay(Collider collider)
 {
     var controller = (collider.GetComponent<VRTK_ControllerEvents>() ? collider.GetComponent<VRTK_ControllerEvents>() : collider.GetComponentInParent<VRTK_ControllerEvents>());
     if (controller)
     {
         if (lastUsePressedState == true && !controller.usePressed)
         {
             var distance = Vector3.Distance(transform.position, destination.position);
             var controllerIndex = VRTK_DeviceFinder.GetControllerIndex(controller.gameObject);
             OnDestinationMarkerSet(SetDestinationMarkerEvent(distance, destination, new RaycastHit(), destination.position, controllerIndex));
         }
         lastUsePressedState = controller.usePressed;
     }
 }
 public void Pickup(Collider target)
 {
     // Check if target can be held
     IPickupable held = (IPickupable)target.GetComponentInParent(typeof(IPickupable));
     if (held != null)
     {
         hand.Pickup(held);
     }
     else
     {
         print("Not pickupable");
         print(target.tag);
     }
 }
Ejemplo n.º 9
0
        public void OnTriggerStay(Collider a_other)
        {
            Rigidbody rigid = a_other.GetComponent<Rigidbody>();

            if (rigid == null)
            {
                rigid = a_other.GetComponentInParent<Rigidbody>();
            }

            // Ensure that player has a rigidbody
            if (rigid != null)
            {
                //This seems to be the best value for the time being- adjust this as necessary.
                //rigid.velocity *= 0.985f;
                rigid.velocity *= (delayFactor/2);
                rigid.angularVelocity *= delayFactor; //-- Too much?
            }
        }
Ejemplo n.º 10
0
    void OnTriggerEnter(UnityEngine.Collider other)
    {
        thisPlayer = GetComponentInParent <Player>();
        Player collPlayer = other.GetComponentInParent <Player>();

        if (collPlayer == null)
        {
            return;
        }
        if (collPlayer.teamChoice == thisPlayer.teamChoice)
        {
            moveRight();
        }
        else
        {
            thisPlayer.TryToPassBall();
        }
    }
        void OnTriggerEnter(Collider other)
        {
            if (other.CompareTag("Player1_") || other.CompareTag("Player2_") || other.CompareTag("Player3_") || other.CompareTag("Player4_"))
            {
                ShipPartDestroy partScript = other.GetComponentInParent<ShipPartDestroy>();
                if (partScript != null)
                {
                    // Found in parent, repair
                    partScript.RepairAllParts();
                }
                else
                {
                    // Look to children for the part object
                    partScript = other.GetComponentInChildren<ShipPartDestroy>();
                    if (partScript != null)
                    {
                        partScript.RepairAllParts();
                    }
                }

            }
        }
Ejemplo n.º 12
0
 void OnTriggerEnter(Collider col)
 {
     if (col.GetComponentInParent<BasePlayer>())
     {
         inTrigger.Add(col.GetComponentInParent<BasePlayer>());
         OnEnterZone(this, col.GetComponentInParent<BasePlayer>());
     }
 }
        /// <summary>
        /// Selects the given gameObject. A selected gameObject is followed and highlighted by a visual effect, and has its
        /// statistics displayed on the UI. 
        /// </summary>
        /// <param name="target">The gameObject to highlight</param>
        void Select(Collider target)
        {
            // Check if the clicked thing is selectable
            selected = (ISelectable)target.GetComponentInParent(typeof(ISelectable));
            if (selected != null)
            {
                // Setting parent causes this object (and its children) to follow the parent
                transform.parent = target.transform;
                // This object floats just off the base of the selected object
                transform.localPosition = new Vector3(0, 1.5f, 0);
                // Turn on visual effects
                visualEffect.SetActive(true);

                selected.OnSelect();
            }
        }
 private void OnTriggerExit(Collider col)
 {
     //Interface.Oxide.LogInfo("Exit {0}: {1}", Info.ID, col.name);
     var player = col.GetComponentInParent<BasePlayer>();
     if (player != null)
     {
         if (!players.Remove(player)) return;
         ZoneManagerPlugin.OnPlayerExitZone(this, player);
     }
     else if(!col.transform.CompareTag("MeshColliderBatch"))
         CheckCollisionLeave(col);
     else
     {
         var colliderBatch = col.GetComponent<MeshColliderBatch>();
         if (colliderBatch != null)
         {
             var colliders = (ListDictionary<Component, ColliderCombineInstance>) InstancesField.GetValue(colliderBatch);
             foreach (var instance in colliders.Values)
                 CheckCollisionLeave(instance.collider);
         }
     }
 }
Ejemplo n.º 15
0
        public void OnTriggerStay(Collider other)
        {
            if (!IsAnimalAi(other))
            {
                return;
            }

            if (IsSelf(other))
            {
                return;
            }

            var direction = other.transform.position - gameObject.transform.position;
            var angle = Vector3.Angle(direction, transform.forward);
            if (angle < 0.5 * FieldOfViewAngle)
            {
                RaycastHit ray;
                if (Physics.Raycast(transform.position, direction, out ray))
                {
                    var otherAnimal = other.GetComponentInParent<AiRig>();
                    var collidedAnimal = ray.collider.GetComponentInParent<AiRig>();
                    if (collidedAnimal == otherAnimal)
                    {
                        ReportDetection(other);
                        return;
                    }
                }
            }
            if (Detected.Contains(other))
            {
                ReportUndetection(other);
            }
        }
Ejemplo n.º 16
0
 private void OnTriggerExit(Collider col)
 {
     var player = col.GetComponentInParent<BasePlayer>();
     if (player != null)
     {
         ZoneManagerPlugin.OnPlayerExitZone(this, player);
         Player.Remove(player);
     }
     else
     {
         CheckCollisionLeave(col);
         var colliderBatch = col.GetComponent<MeshColliderBatch>();
         if (colliderBatch != null)
         {
             var colliders = (ListDictionary<Component, ColliderCombineInstance>)InstancesField.GetValue(colliderBatch);
             foreach (var instance in colliders.Values)
                 CheckCollisionLeave(instance.collider);
         }
     }
 }
Ejemplo n.º 17
0
 /////////////////////////////////////////////////////
 ///  DoBuildUp(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 ///  Raw buildup, you can build anything on top of each other, exept the position, there is no AI
 /////////////////////////////////////////////////////
 private static void DoBuildUp(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 {
     var fbuildingblock = baseentity.GetComponentInParent<BuildingBlock>();
     if (fbuildingblock == null)
     {
         return;
     }
     newPos = fbuildingblock.transform.position + (VectorUP * buildplayer.currentHeightAdjustment);
     newRot = fbuildingblock.transform.rotation;
     if (isColliding(buildplayer.currentPrefab, newPos, 1f))
     {
         return;
     }
     SpawnStructure(buildplayer.currentPrefab, newPos, newRot, buildplayer.currentGrade, buildplayer.currentHealth);
 }
Ejemplo n.º 18
0
        private static void DoRotation(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        {
            var buildingblock = baseentity.GetComponentInParent<BuildingBlock>();
            if (buildingblock == null)
            {
                return;
            }
            DoRotation(buildingblock, buildplayer.currentRotate);
            if (buildplayer.selection == "select")
            {
                return;
            }

            houseList = new List<object>();
            checkFrom = new List<Vector3>();
            houseList.Add(buildingblock);
            checkFrom.Add(buildingblock.transform.position);

            int current = 0;
            while (true)
            {
                current++;
                if (current > checkFrom.Count)
                    break;
                var hits = Physics.OverlapSphere(checkFrom[current - 1], 3.1f);
                foreach (var hit in hits)
                {
                    var fbuildingblock = hit.GetComponentInParent<BuildingBlock>();
                    if (fbuildingblock != null && !(houseList.Contains(fbuildingblock)))
                    {
                        houseList.Add(fbuildingblock);
                        checkFrom.Add(fbuildingblock.transform.position);
                        DoRotation(fbuildingblock, buildplayer.currentRotate);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public void OnTriggerStay(Collider a_other)
        {
            Rigidbody playerBody = null;

            if (m_playerRigidBodies.Length > 0)
            {
                bool isPlayer = false;
                switch (a_other.tag)
                {
                    case "Player1_":
                        playerBody = m_playerRigidBodies[0];
                        isPlayer = true;
                        break;
                    case "Player2_":
                        playerBody = m_playerRigidBodies[1];
                        isPlayer = true;
                        break;
                    case "Player3_":
                        playerBody = m_playerRigidBodies[2];
                        isPlayer = true;
                        break;
                    case "Player4_":
                        playerBody = m_playerRigidBodies[3];
                        isPlayer = true;
                        break;
                    case "Passengers":
                        playerBody = a_other.GetComponentInParent<Rigidbody>();
                        break;
                    default:
                        // Not player
                        playerBody = a_other.GetComponent<Rigidbody>();
                        return;
                }

                // Ensure that player has a rigidbody
                if (playerBody != null)
                {
                    Vector3 forceDir = transform.forward;
                    float forceMag = force + Mathf.Sqrt(playerBody.velocity.magnitude * 0.001f);
                    playerBody.AddForce(forceDir * forceMag, ForceMode.VelocityChange);
                }

                if (isPlayer && rumbleCooldown <= 0)
                {
                    // Rumble and screenshake the player
                    InputManager.SetControllerVibrate(a_other.tag, rumbleStr, rumbleStr, rumbleDurr, true);

                    // Only rumble as often as it would be triggered
                    rumbleCooldown = rumbleDurr;

                    //Trigger a sound
                    if (m_AudioSource != null)
                    {
                        if (!m_AudioSource.isPlaying)
                        {
                            m_AudioSource.Play();
                        }
                    }
                }
            }
        }
 void OnTriggerEnter(Collider other)
 {
     string paintingTexture = other.GetComponentInParent<MeshRenderer>().material.mainTexture.name;
     PaintingManager_Second.instance.setPainting(paintingTexture);
 }
Ejemplo n.º 21
0
            private void CheckCollisionEnter(Collider col)
            {

                if (ZoneManagerPlugin.HasZoneFlag(this, ZoneFlags.NoDecay))
                {
                    var decay = col.GetComponentInParent<Decay>();
                    if (decay != null)
                    {
                        decay.CancelInvoke("RunDecay");
                        decay.enabled = false;
                    }
                }
                var resourceDispenser = col.GetComponentInParent<ResourceDispenser>();
                if (resourceDispenser != null) //also BaseCorpse
                {
                    ZoneManagerPlugin.OnResourceEnterZone(this, resourceDispenser);
                    Resource.Add(resourceDispenser);
                    return;
                }
                var combatEntity = col.GetComponentInParent<BaseCombatEntity>();
                if (combatEntity == null) return;
                if (combatEntity is BaseNPC)
                {
                    var baseNpc = (BaseNPC)combatEntity;
                    ZoneManagerPlugin.OnNpcEnterZone(this, baseNpc);
                    Npc.Add(baseNpc);
                }
                else if (!(combatEntity is LootContainer) && !(combatEntity is BaseHelicopter))
                {
                    ZoneManagerPlugin.OnBuildingEnterZone(this, combatEntity);
                    Building.Add(combatEntity);
                }
                else
                {
                    ZoneManagerPlugin.OnOtherEnterZone(this, combatEntity);
                    Other.Add(combatEntity);
                }
            }
Ejemplo n.º 22
0
        /// <summary>
        /// Called when a trigger enter begins to objects.
        /// </summary>
        /// <param name="a_otherCol">Other collider.</param>
        void OnTriggerEnter(Collider a_otherCol)
        {
            // Ignore losing parts to prisoners
            if (!a_otherCol.tag.Contains("Passengers"))
            {
                Rigidbody rbOther = a_otherCol.GetComponentInParent<Rigidbody>();
                if (rbOther != null)
                {
                    // Work out relative collision velocity
                    Vector3 offsetVel = (m_rb.velocity - rbOther.velocity);
                    float velDiffSqr = offsetVel.sqrMagnitude;

                    // Run on the other ship because OnTriggerEnter only allows us to get the other component, not our own collider
                    ShipPartDestroy scriptOther = a_otherCol.GetComponentInParent<ShipPartDestroy>();
                    if (scriptOther != null)
                    {
                        scriptOther.EvaluatePartCollision(a_otherCol, velDiffSqr);
                    }
                }
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Evaluates the collision with the input collider.
        /// </summary>
        /// <param name="a_colInfo">Collision information.</param>
        /// <param name="a_velDiff">Relative collision velocity.</param>
        /// <param name="a_colVelSqr">Squared relative collision velocity magnitude.</param>
        private void EvaluatePlayerCollision(Collider a_otherCol, Vector3 a_velDiff, float a_colVelSqr)
        {
            // Get scripts
            AirshipControlBehaviour ship = a_otherCol.GetComponentInParent<AirshipControlBehaviour>();
            if (ship != null)
            {
                PassengerTray otherTray = ship.gameObject.GetComponentInChildren<PassengerTray>();

                if (otherTray != null)
                {
                    // Establish collision direction
                    Transform otherTrans = a_otherCol.transform;
                    float forwardDot = Vector3.Dot(m_trans.forward, otherTrans.forward);
                    float rightDot = Vector3.Dot(m_trans.right, otherTrans.right);

                    // Get positions
                    Vector3 myPos = m_trans.position;
                    Vector3 otherPos = otherTrans.position;
                    Vector3 offset = otherPos - myPos;

                    Rigidbody rbOther = a_otherCol.GetComponent<Rigidbody>();

                    if (rbOther == null)
                    {
                        rbOther = a_otherCol.GetComponentInParent<Rigidbody>();
                    }

                    // For evaluating whether the collision is from below/above
                    float upDot = Vector3.Dot(offset.normalized, otherTrans.up);

                    /*Debug.Log("Front dot: " + Mathf.Abs(forwardDot) +
                        ", right dot: " + Mathf.Abs(rightDot) +
                        ", up dot: " + Mathf.Abs(upDot) +
                        ", threshold: " + colDirThreshold);*/

                    bool powerDownOther = false;
                    bool powerDownMe = false;

                    if (upDot >= 1 - colDirThreshold &&
                        offset.y > 0)
                    {
                        // Above - My ship onto them from above

                        // Make them lose passengers
                        //Debug.Log("Collision - From Above!");
                        powerDownOther = true;
                    }
                    else if (upDot <= -1 + colDirThreshold &&
                        offset.y < 0)
                    {
                        // Below - My ship onto them from below

                        // Make them lose passengers
                        //Debug.Log("Collision - From Below!");
                        powerDownOther = true;
                    }
                    else if (Mathf.Abs(forwardDot) <= colDirThreshold)
                    {
                        // T-Bone - My front into their side

                        // Make them lose passengers
                        //Debug.Log("Collision - From T-Bone!");
                        powerDownOther = true;
                    }
                    else if (forwardDot <= -1 + colDirThreshold)
                    {
                        // Head on - My front into their front

                        // Make both lose passengers
                        //Debug.Log("Collision - From Head On!");
                        powerDownMe = true;
                        powerDownOther = true;
                    }
                    else if (forwardDot >= 1 - colDirThreshold)
                    {
                        // Behind - My front into their back

                        // Make them lose passengers
                        //Debug.Log("Collision - From Behind!");
                        powerDownOther = true;
                    }
                    else if (Mathf.Abs(rightDot) >= 1 - colDirThreshold)
                    {
                        // Horizontal/Side by side - My ship gently bumping them

                        // Make nobody lose passengers
                        //Debug.Log("Collision - Horiztonal bump!");
                    }
                    else if (a_colVelSqr >= m_bumpVelSqr)
                    {
                        // Colliding above rumble threshold from random angle, both lose passengers
                        InputManager.SetControllerVibrate(gameObject.tag, bumpRumbleStr, bumpRumbleStr, bumpRumbleDurr, true);

                        // Turn off the passenger tray for a bit
                        powerDownMe = true;
                        powerDownOther = true;
                    }

                    if (powerDownMe)
                    {
                        m_shipTray.PowerDownTray();

                        // Launch passengers with relative velocity
                        Rigidbody rbTemp = null;
                        List<GameObject> contents = m_shipTray.trayContents;
                        foreach (GameObject passenger in contents)
                        {
                            rbTemp = passenger.GetComponent<Rigidbody>();
                            if (rbTemp != null)
                            {
                                rbTemp.AddForce(rbOther.velocity, ForceMode.VelocityChange);
                            }
                        }
                    }
                    if (powerDownOther)
                    {
                        m_shipTray.PowerDownTray();

                        // Launch passengers with relative velocity
                        Rigidbody rbTemp = null;
                        List<GameObject> contents = otherTray.trayContents;
                        foreach (GameObject passenger in contents)
                        {
                            rbTemp = passenger.GetComponent<Rigidbody>();
                            if (rbTemp != null)
                            {
                                rbTemp.AddForce(m_rb.velocity, ForceMode.VelocityChange);
                            }
                        }
                    }
                }
            }
        }
        void OnTriggerEnter(Collider other)
        {
            if(other.tag == "StreetArt")
            {
                string paintingTexture = other.GetComponentInParent<MeshRenderer>().material.mainTexture.name;
                PaintingManager.instance.setPainting(paintingTexture, other.transform.parent.transform);
            }

            if(other.tag == "SafeZone" && listAlertedGuards.Count == 0)
            {
                isSafe = true;
            }

            if(other.tag == "PaintingCreationZone")
            {
                GameController.instance.StartDrawOeuvre();
                ChangeState(PlayerState.CreateOeuvre, State.Dead, "Wave");
            }
            if(other.tag == "EndZone")
            {
                GameController.instance.FinishLevel();
                ChangeState(PlayerState.FinishedLvl, State.Dead, "Wave");
            }
        }
Ejemplo n.º 25
0
 void OnTriggerExit(Collider col)
 {
     if (col.GetComponentInParent<BasePlayer>())
     {
         inTrigger.Remove(col.GetComponentInParent<BasePlayer>());
         OnExitZone(this, col.GetComponentInParent<BasePlayer>());
     }
 }
Ejemplo n.º 26
0
 /////////////////////////////////////////////////////
 ///  DoErase(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 ///  Erase function
 /////////////////////////////////////////////////////
 private static void DoErase(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 {
     currentBaseNet = baseentity.GetComponentInParent<BaseNetworkable>();
     currentBaseNet?.Kill(BaseNetworkable.DestroyMode.Gib);
 }
        void OnTriggerStay(Collider otherCollider)
        {
            //Item interaction
            if (otherCollider.gameObject.tag == "GrabItem")
            {
                //Pick up item
                if ((Input.GetButton(xButton)) && (otherCollider.GetComponentInParent<PickUp>().thrown == false))
                {
                    pleaseWait = true;
                    pickUpItem = true;
                    itemName = otherCollider.transform.parent.name;

                    //Change item's info
                    otherCollider.GetComponentInParent<PickUp>().hasOwner = true;
                    otherCollider.GetComponentInParent<PickUp>().newOwner = gameObject.name;
                }

                //Get hit by item
                if (otherCollider.GetComponentInParent<PickUp>().thrown == true)
                    gotHit = true;
            }
        }
Ejemplo n.º 28
0
        /////////////////////////////////////////////////////
        ///  DoHeal(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        ///  Set max health to building
        /////////////////////////////////////////////////////
        private static void DoHeal(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        {
            var buildingblock = baseentity.GetComponentInParent<BuildingBlock>();
            if (buildingblock == null)
            {
                return;
            }
            SetHealth(buildingblock);
            if (buildplayer.selection == "select")
            {
                return;
            }

            houseList = new List<object>();
            checkFrom = new List<Vector3>();
            houseList.Add(buildingblock);
            checkFrom.Add(buildingblock.transform.position);
		int current = 0;
            while (true)
            {
                current++;
                if (current > checkFrom.Count)
                    break;
                List<BaseEntity> list = Pool.GetList<BaseEntity>();
                Vis.Entities<BaseEntity>(checkFrom[current - 1], 3f, list, constructionColl);
                 for (int i = 0; i < list.Count; i++)
                {
                    BaseEntity hit = list[i];
                    var fbuildingblock = hit.GetComponentInParent<BuildingBlock>();
                    if (fbuildingblock != null && !(houseList.Contains(fbuildingblock)))
                    {
                        houseList.Add(fbuildingblock);
                        checkFrom.Add(fbuildingblock.transform.position);
                        SetHealth(fbuildingblock);
                    }
                }
            }
        }
Ejemplo n.º 29
0
 protected bool IsSelf(Collider other)
 {
     var components = GetComponentInParent(AiBase);
     var otherAnimal = other.GetComponentInParent(AiBase);
     return components == otherAnimal;
 }
Ejemplo n.º 30
0
        /////////////////////////////////////////////////////
        ///  DoBuild(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        ///  Fully AIed Build :) see the InitializeSockets for more informations
        /////////////////////////////////////////////////////
        private static void DoBuild(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        {
            var fbuildingblock = baseentity.GetComponentInParent<BuildingBlock>();
            if (fbuildingblock == null)
            {
                return;
            }
            distance = 999999f;
            Vector3 newPos = new Vector3(0f, 0f, 0f);
            newRot = new Quaternion(0f, 0f, 0f, 0f);
            //  Checks if this building has a socket hooked to it self
            //  If not ... well it won't be able to be built via AI
            if (nameToSockets.ContainsKey(fbuildingblock.blockDefinition.fullName))
            {
                sourcesocket = nameToSockets[fbuildingblock.blockDefinition.fullName];
                // Gets all Sockets that can be connected to the source building
                if (TypeToType.ContainsKey(sourcesocket))
                {
                    sourceSockets = (Dictionary<SocketType, object>)TypeToType[sourcesocket];
                    targetsocket = nameToSockets[buildplayer.currentPrefab];
                    // Checks if the newly built structure can be connected to the source building
                    if (sourceSockets.ContainsKey(targetsocket))
                    {
                        newsockets = (Dictionary<Vector3, Quaternion>)sourceSockets[targetsocket];
                        // Get all the sockets that can be hooked to the source building via the new structure element
                        foreach (KeyValuePair<Vector3, Quaternion> pair in newsockets)
                        {
                            var currentrelativepos = (fbuildingblock.transform.rotation * pair.Key) + fbuildingblock.transform.position;
                            if (Vector3.Distance(currentrelativepos, closestHitpoint) < distance)
                            {
                                // Get the socket that is the closest to where the player is aiming at
                                distance = Vector3.Distance(currentrelativepos, closestHitpoint);
                                newPos = currentrelativepos + (VectorUP * buildplayer.currentHeightAdjustment);
                                newRot = (fbuildingblock.transform.rotation * pair.Value);
                            }
                        }
                    }
                }
            }
            if (newPos.x == 0f)
                return;
            // Checks if the element has already been built to prevent multiple structure elements on one spot
            if (isColliding(buildplayer.currentPrefab, newPos, 1f))
                return;

            SpawnStructure(buildplayer.currentPrefab, newPos, newRot, buildplayer.currentGrade, buildplayer.currentHealth);
        }
Ejemplo n.º 31
0
 private void CheckCollisionLeave(Collider col)
 {
     if (ZoneManagerPlugin.HasZoneFlag(this, ZoneFlags.NoDecay))
     {
         var decay = col.GetComponentInParent<Decay>();
         if (decay != null) decay.enabled = true;
     }
     var resourceDispenser = col.GetComponentInParent<ResourceDispenser>();
     if (resourceDispenser != null)
     {
         ZoneManagerPlugin.OnResourceExitZone(this, resourceDispenser);
         Resource.Remove(resourceDispenser);
         return;
     }
     var combatEntity = col.GetComponentInParent<BaseCombatEntity>();
     if (combatEntity == null) return;
     if (combatEntity is BaseNPC)
     {
         ZoneManagerPlugin.OnNpcExitZone(this, (BaseNPC)combatEntity);
         Npc.Remove((BaseNPC) combatEntity);
     }
     else if (!(combatEntity is LootContainer) && !(combatEntity is BaseHelicopter))
     {
         ZoneManagerPlugin.OnBuildingExitZone(this, combatEntity);
         Building.Remove(combatEntity);
     }
     else
     {
         ZoneManagerPlugin.OnOtherExitZone(this, combatEntity);
         Other.Remove(combatEntity);
     }
 }