Beispiel #1
0
        private void EquipmentSlot_UpdateTargets(On.RoR2.EquipmentSlot.orig_UpdateTargets orig, EquipmentSlot self, EquipmentIndex targetingEquipmentIndex, bool userShouldAnticipateTarget)
        {
            if (targetingEquipmentIndex != catalogIndex || self.subcooldownTimer > 0f || self.stock == 0)
            {
                orig(self, targetingEquipmentIndex, userShouldAnticipateTarget);
                if (targetingEquipmentIndex == catalogIndex)
                {
                    self.targetIndicator.active = false;
                }
                return;
            }

            var       res = FindNearestRerollable(self.gameObject, self.GetAimRay(), 10f, 20f, false);
            Transform tsf = null;

            if (res)
            {
                tsf = res.transform;
            }
            self.currentTarget = new EquipmentSlot.UserTargetInfo {
                transformToIndicateAt = tsf,
                pickupController      = null,
                hurtBox    = null,
                rootObject = res
            };

            if (self.currentTarget.rootObject != null)
            {
                var purch = res.GetComponent <PurchaseInteraction>();
                if (!res.GetComponent <RecombobulatorFlag>() && (!purch || purch.available))
                {
                    self.targetIndicator.visualizerPrefab = LegacyResourcesAPI.Load <GameObject>("Prefabs/RecyclerIndicator");
                }
                else
                {
                    self.targetIndicator.visualizerPrefab = LegacyResourcesAPI.Load <GameObject>("Prefabs/RecyclerBadIndicator");
                }

                self.targetIndicator.active          = true;
                self.targetIndicator.targetTransform = self.currentTarget.transformToIndicateAt;
            }
            else
            {
                self.targetIndicator.active = false;
            }
        }
Beispiel #2
0
        private void EquipmentSlot_UpdateTargets(On.RoR2.EquipmentSlot.orig_UpdateTargets orig, EquipmentSlot self, EquipmentIndex targetingEquipmentIndex, bool userShouldAnticipateTarget)
        {
            if (targetingEquipmentIndex != catalogIndex || self.subcooldownTimer > 0f || self.stock == 0)
            {
                orig(self, targetingEquipmentIndex, userShouldAnticipateTarget);
                if (targetingEquipmentIndex == catalogIndex)
                {
                    self.targetIndicator.active = false;
                }
                return;
            }

            var cpt = self.characterBody.GetComponent <PackBoxTracker>();

            if (!cpt)
            {
                cpt = self.characterBody.gameObject.AddComponent <PackBoxTracker>();
            }

            GameObject indPrefab;

            if (cpt.packedObject)
            {
                indPrefab = placeIndicatorPrefab;
                bool didPlace = TryGetBoxablePlacePos(self.GetAimRay(), out Vector3 loc, out bool didHitGround);
                if (didPlace || didHitGround)
                {
                    if (!didPlace)
                    {
                        indPrefab = placeIndicatorBadPrefab;
                    }
                    cpt.groundTarget.transform.position = loc;
                    self.currentTarget = new EquipmentSlot.UserTargetInfo {
                        transformToIndicateAt = cpt.groundTarget,
                        pickupController      = null,
                        hurtBox    = null,
                        rootObject = cpt.groundTarget.gameObject
                    };
                    //todo: on-ground indicator like engi blueprints, will need to track separately?
                }
                else
                {
                    self.currentTarget = new EquipmentSlot.UserTargetInfo {
                        transformToIndicateAt = null,
                        pickupController      = null,
                        hurtBox    = null,
                        rootObject = null
                    }
                };
            }
            else
            {
                indPrefab = packIndicatorPrefab;
                var       res = FindNearestBoxable(self.gameObject, self.GetAimRay(), 10f, 20f, false);
                Transform tsf = null;
                if (res)
                {
                    tsf = res.transform;
                }
                self.currentTarget = new EquipmentSlot.UserTargetInfo {
                    transformToIndicateAt = tsf,
                    pickupController      = null,
                    hurtBox    = null,
                    rootObject = res
                };
            }

            if (self.currentTarget.rootObject != null)
            {
                self.targetIndicator.visualizerPrefab = indPrefab;
                self.targetIndicator.active           = true;
                self.targetIndicator.targetTransform  = self.currentTarget.transformToIndicateAt;
            }
            else
            {
                self.targetIndicator.active = false;
            }
        }