private void TryPickupShinyTarget()
 {
     if (this.shinyTarget != null && this.shinyTarget.activeInHierarchy)
     {
         base.SendMessage("OnShinyPickUp", this.shinyTarget, SendMessageOptions.DontRequireReceiver);
         this.shinyTarget.gameObject.SendMessage("OnShinyPickUp", base.gameObject, SendMessageOptions.DontRequireReceiver);
         UWE.Utils.SetCollidersEnabled(this.shinyTarget, false);
         this.shinyTarget.transform.parent        = this.shinyTargetAttach;
         this.shinyTarget.transform.localPosition = Vector3.zero;
         this.targetPickedUp = true;
         UWE.Utils.SetIsKinematic(this.shinyTarget.GetComponent <Rigidbody>(), true);
         UWE.Utils.SetEnabled(this.shinyTarget.GetComponent <LargeWorldEntity>(), false);
         base.SendMessage("OnShinyPickedUp", this.shinyTarget, SendMessageOptions.DontRequireReceiver);
         base.swimBehaviour.SwimTo(base.transform.position + Vector3.up * 5f + UnityEngine.Random.onUnitSphere, Vector3.up, this.swimVelocity);
         this.timeNextSwim = Time.time + 1f;
         BehaviourUpdateUtils.Register(this);
     }
 }
Ejemplo n.º 2
0
        public void Drill(Vector3 position, Shark shark, out GameObject hitObj)
        {
            float totalhp = 0f;

            foreach (float hp in drill.health)
            {
                totalhp += hp;
            }
            drillingShark = shark;
            int meshindex = drill.FindClosestMesh(position, out Vector3 zero);

            hitObj = drill.renderers[meshindex].gameObject;
            drill.timeLastDrilled = Time.time;
            if (totalhp > 0)
            {
                float meshhealth = drill.health[meshindex];
                drill.health[meshindex] = Mathf.Max(0f, drill.health[meshindex] - 5f);
                totalhp -= meshhealth - drill.health[meshindex];
                if (meshhealth > 0f && drill.health[meshindex] <= 0f)
                {
                    drill.renderers[meshindex].gameObject.SetActive(false);
                    drill.SpawnFX(drill.breakFX, zero);
                    if (UnityEngine.Random.value < drill.kChanceToSpawnResources)
                    {
                        drill.SpawnLoot(zero);
                    }
                }
                if (totalhp <= 0f)
                {
                    drill.SpawnFX(drill.breakAllFX, zero);
                    if (typeof(Drillable).GetField("onDrilled").GetValue(drill) is Drillable.OnDrilled onDrilled)
                    {
                        onDrilled(drill);
                    }
                    if (drill.deleteWhenDrilled)
                    {
                        float time = drill.lootPinataOnSpawn ? 6f : 0f;
                        drill.Invoke("DestroySelf", time);
                    }
                }
            }
            BehaviourUpdateUtils.Register(this);
        }
Ejemplo n.º 3
0
        public void OnDrill(Vector3 position, Vehicle veh, out GameObject hitObject)
        {
            float num = 0f;

            for (int i = 0; i < health.Length; i++)
            {
                num += health[i];
            }
            this.drillingVehicle = veh;
            Vector3 zero = Vector3.zero;
            int     num2 = FindClosestMesh(position, out zero);

            hitObject            = this.renderers[num2].gameObject;
            this.timeLastDrilled = Time.time;
            if (num > 0f)
            {
                float num3 = health[num2];
                this.health[num2] = Mathf.Max(0f, this.health[num2] - 5f);
                num -= num3 - health[num2];
                if (num3 > 0f && this.health[num2] <= 0f)
                {
                    this.renderers[num2].gameObject.SetActive(false);
                    this.SpawnFX(breakFX, zero);
                    if (UnityEngine.Random.value < kChanceToSpawnResources)
                    {
                        SpawnLoot(zero);
                    }
                }
                if (num <= 0f)
                {
                    this.gameObject.SendMessage("OnBreakResource", null, SendMessageOptions.DontRequireReceiver);
                    this.SpawnFX(this.breakAllFX, zero);
                    onDrilled.Invoke(drillable);
                    if (deleteWhenDrilled)
                    {
                        float time = (!lootPinataOnSpawn) ? 0f : 6f;
                        this.Invoke("DestroySelf", time);
                    }
                }
            }
            BehaviourUpdateUtils.Register(drillable);
            drillable.health = health;
        }
 private void OnEnable()
 {
     BehaviourUpdateUtils.Register(this);
 }
        public void OnDrill(Vector3 position, SeaTruckHelper helper, out GameObject hitObject)
        {
            float num = 0f;

            for (int i = 0; i < drillable.health.Length; i++)
            {
                num += drillable.health[i];
            }

            this.helper = helper;

            Vector3 zero = Vector3.zero;

            int num2 = FindClosestMesh(position, out zero);

            hitObject = renderers[num2].gameObject;

            timeLastDrilled = Time.time;

            if (num > 0f)
            {
                float num3 = drillable.health[num2];

                drillable.health[num2] = Mathf.Max(0f, drillable.health[num2] - 5f);

                num -= num3 - drillable.health[num2];

                if (num3 > 0f && drillable.health[num2] <= 0f)
                {
                    renderers[num2].gameObject.SetActive(false);

                    SpawnFX(drillable.breakFX, zero);

                    if (drillable.resources.Length != 0)
                    {
                        StartCoroutine(SpawnLootAsync(zero));
                    }
                }

                if (num <= 0f)
                {
                    SpawnFX(drillable.breakAllFX, zero);

                    onDrilled?.Invoke(drillable);

                    if (drillable.deleteWhenDrilled)
                    {
                        ResourceTracker component = GetComponent <ResourceTracker>();

                        if (component)
                        {
                            component.OnBreakResource();
                        }

                        float time = (!drillable.lootPinataOnSpawn) ? 0f : 6f;
                        drillable.Invoke("DestroySelf", time);
                    }
                }
            }

            BehaviourUpdateUtils.Register(this);
        }