Пример #1
0
        /// <summary>
        /// Method to get the interactable tier color from a ping target
        /// </summary>
        /// <param name="gameObject">The ping target</param>
        /// <returns>An Color instance of the tier color</returns>
        private Color GetTargetTierColor(GameObject gameObject)
        {
            Color color = Color.black;

            ShopTerminalBehavior shopTerminal = gameObject.GetComponent <ShopTerminalBehavior>();

            if (shopTerminal)
            {
                PickupIndex pickupIndex = shopTerminal.CurrentPickupIndex();
                PickupDef   pickup      = PickupCatalog.GetPickupDef(pickupIndex);

                if (pickup != null)
                {
                    color = pickup.baseColor;
                }
            }

            GenericPickupController pickupController = gameObject.GetComponent <GenericPickupController>();

            if (pickupController)
            {
                PickupDef pickup = PickupCatalog.GetPickupDef(pickupController.pickupIndex);

                if (pickup != null)
                {
                    color = pickup.baseColor;
                }
            }

            PurchaseInteraction purchaseInteraction = gameObject.GetComponent <PurchaseInteraction>();

            if (purchaseInteraction)
            {
                CostTypeDef costType = CostTypeCatalog.GetCostTypeDef(purchaseInteraction.costType);
                color = ColorCatalog.GetColor(costType.colorIndex);
            }

            PickupIndexNetworker pickupIndexNetworker = gameObject.GetComponent <PickupIndexNetworker>();

            if (pickupIndexNetworker)
            {
                PickupDef pickup = PickupCatalog.GetPickupDef(pickupIndexNetworker.NetworkpickupIndex);

                if (pickup != null)
                {
                    color = pickup.baseColor;
                }
            }

            if (color == Color.black)
            {
                color = _colors["InteractablePingColor"];
            }

            return(color);
        }
Пример #2
0
        /// <summary>
        /// Get the price from a <see cref="GameObject"/> if it is a <see cref="PurchaseInteraction"/>
        /// </summary>
        /// <param name="go">The target <see cref="GameObject"/></param>
        /// <returns>The price of the game object</returns>
        private static string GetPrice(GameObject go)
        {
            PurchaseInteraction purchaseInteraction = go.GetComponent <PurchaseInteraction>();

            if (purchaseInteraction)
            {
                StringBuilder sb = new StringBuilder();
                CostTypeCatalog.GetCostTypeDef(purchaseInteraction.costType)
                .BuildCostStringStyled(purchaseInteraction.cost, sb, true);

                return(sb.ToString());
            }

            return(null);
        }
Пример #3
0
        private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig,
                                           PurchaseInteraction self, Interactor activator)
        {
            if (!self.CanBeAffordedByInteractor(activator))
            {
                return;
            }

            if (!GeneralHooks.IsMultiplayer())
            {
                orig(self, activator);
                return;
            }

            var shop = self.GetComponent <ShopTerminalBehavior>();

            #region Cauldronfix

            if (ShareSuite.PrinterCauldronFixEnabled.Value)
            {
                var characterBody = activator.GetComponent <CharacterBody>();
                var inventory     = characterBody.inventory;

                if (self.costType == CostTypeIndex.WhiteItem ||
                    self.costType == CostTypeIndex.GreenItem ||
                    self.costType == CostTypeIndex.RedItem ||
                    self.costType == CostTypeIndex.BossItem ||
                    self.costType == CostTypeIndex.LunarItemOrEquipment)
                {
                    var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex;
                    inventory.GiveItem(item);
                    ChatHandler.SendRichCauldronMessage(inventory.GetComponent <CharacterMaster>(),
                                                        shop.CurrentPickupIndex());
                    orig(self, activator);
                    return;
                }
            }

            #endregion Cauldronfix

            #region EquipDronefix

            if (ShareSuite.EquipmentShared.Value)
            {
                var rng       = self.GetComponent <Xoroshiro128Plus>();
                var itemIndex = ItemIndex.None;

                var costTypeDef = CostTypeCatalog.GetCostTypeDef(self.costType);
                if (shop)
                {
                    itemIndex = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex;
                }

                var payCostResults = costTypeDef.PayCost(self.cost,
                                                         activator, self.gameObject, rng, itemIndex);

                foreach (var equipmentIndex in payCostResults.equipmentTaken)
                {
                    //TODO fix equipment drones here
                }
            }
            #endregion EquipDronefix

            orig(self, activator);
        }
Пример #4
0
        private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig,
                                           PurchaseInteraction self, Interactor activator)
        {
            if (!self.CanBeAffordedByInteractor(activator))
            {
                return;
            }

            if (!GeneralHooks.IsMultiplayer())
            {
                orig(self, activator);
                return;
            }

            if (self.costType == CostTypeIndex.None)
            {
                orig(self, activator);
                return;
            }

            var shop = self.GetComponent <ShopTerminalBehavior>();

            #region Cauldronfix

            if (printerCosts.Contains(self.costType))
            {
                if (ShareSuite.PrinterCauldronFixEnabled.Value)
                {
                    var characterBody = activator.GetComponent <CharacterBody>();
                    var inventory     = characterBody.inventory;


                    var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex())?.itemIndex;

                    if (item == null)
                    {
                        RoR2.Console.print("ShareSuite: PickupCatalog is null.");
                    }
                    else
                    {
                        inventory.GiveItem(item.Value);
                    }

                    orig(self, activator);
                    ChatHandler.SendRichCauldronMessage(inventory.GetComponent <CharacterMaster>(),
                                                        shop.CurrentPickupIndex());
                    return;
                }
            }

            #endregion Cauldronfix

            #region EquipDronefix

            if (ShareSuite.EquipmentShared.Value)
            {
                if (self.costType == CostTypeIndex.Equipment)
                {
                    var rng       = self.GetComponent <Xoroshiro128Plus>();
                    var itemIndex = ItemIndex.None;

                    var costTypeDef = CostTypeCatalog.GetCostTypeDef(self.costType);
                    if (shop)
                    {
                        itemIndex = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex;
                    }

                    var payCostResults = costTypeDef.PayCost(self.cost,
                                                             activator, self.gameObject, rng, itemIndex);

                    if (payCostResults.equipmentTaken.Count >= 1)
                    {
                        orig(self, activator);
                        EquipmentSharingHooks.RemoveAllUnBlacklistedEquipment();
                        return;
                    }
                }
            }

            #endregion

            orig(self, activator);
        }
Пример #5
0
        // Token: 0x060024C0 RID: 9408 RVA: 0x000A0134 File Offset: 0x0009E334
        public void RebuildPing()
        {
            base.transform.rotation   = Util.QuaternionSafeLookRotation(this.pingNormal);
            base.transform.position   = (this.pingTarget ? this.pingTarget.transform.position : this.pingOrigin);
            base.transform.localScale = Vector3.one;
            this.positionIndicator.targetTransform = (this.pingTarget ? this.pingTarget.transform : null);
            this.positionIndicator.defaultPosition = base.transform.position;
            IDisplayNameProvider displayNameProvider = this.pingTarget ? this.pingTarget.GetComponentInParent <IDisplayNameProvider>() : null;
            ModelLocator         modelLocator        = null;

            this.pingType = PingIndicator.PingType.Default;
            this.pingObjectScaleCurve.enabled = false;
            this.pingObjectScaleCurve.enabled = true;
            GameObject[] array = this.defaultPingGameObjects;
            for (int i = 0; i < array.Length; i++)
            {
                array[i].SetActive(false);
            }
            array = this.enemyPingGameObjects;
            for (int i = 0; i < array.Length; i++)
            {
                array[i].SetActive(false);
            }
            array = this.interactablePingGameObjects;
            for (int i = 0; i < array.Length; i++)
            {
                array[i].SetActive(false);
            }
            if (this.pingTarget)
            {
                Debug.LogFormat("Ping target {0}", new object[]
                {
                    this.pingTarget
                });
                modelLocator = this.pingTarget.GetComponent <ModelLocator>();
                if (displayNameProvider != null)
                {
                    CharacterBody component = this.pingTarget.GetComponent <CharacterBody>();
                    if (component)
                    {
                        this.pingType = PingIndicator.PingType.Enemy;
                        this.targetTransformToFollow = component.coreTransform;
                    }
                    else
                    {
                        this.pingType = PingIndicator.PingType.Interactable;
                    }
                }
            }
            string bestMasterName = Util.GetBestMasterName(this.pingOwner.GetComponent <CharacterMaster>());
            string text           = ((MonoBehaviour)displayNameProvider) ? Util.GetBestBodyName(((MonoBehaviour)displayNameProvider).gameObject) : "";

            this.pingText.enabled = true;
            this.pingText.text    = bestMasterName;
            switch (this.pingType)
            {
            case PingIndicator.PingType.Default:
                this.pingColor          = this.defaultPingColor;
                this.pingDuration       = this.defaultPingDuration;
                this.pingHighlight.isOn = false;
                array = this.defaultPingGameObjects;
                for (int i = 0; i < array.Length; i++)
                {
                    array[i].SetActive(true);
                }
                Chat.AddMessage(string.Format(Language.GetString("PLAYER_PING_DEFAULT"), bestMasterName));
                break;

            case PingIndicator.PingType.Enemy:
                this.pingColor    = this.enemyPingColor;
                this.pingDuration = this.enemyPingDuration;
                array             = this.enemyPingGameObjects;
                for (int i = 0; i < array.Length; i++)
                {
                    array[i].SetActive(true);
                }
                if (modelLocator)
                {
                    Transform modelTransform = modelLocator.modelTransform;
                    if (modelTransform)
                    {
                        CharacterModel component2 = modelTransform.GetComponent <CharacterModel>();
                        if (component2)
                        {
                            bool flag = false;
                            foreach (CharacterModel.RendererInfo rendererInfo in component2.baseRendererInfos)
                            {
                                if (!rendererInfo.ignoreOverlays && !flag)
                                {
                                    this.pingHighlight.highlightColor = Highlight.HighlightColor.teleporter;
                                    this.pingHighlight.targetRenderer = rendererInfo.renderer;
                                    this.pingHighlight.strength       = 1f;
                                    this.pingHighlight.isOn           = true;
                                    flag = true;
                                }
                            }
                        }
                    }
                    Chat.AddMessage(string.Format(Language.GetString("PLAYER_PING_ENEMY"), bestMasterName, text));
                }
                break;

            case PingIndicator.PingType.Interactable:
            {
                this.pingColor    = this.interactablePingColor;
                this.pingDuration = this.interactablePingDuration;
                this.pingTargetPurchaseInteraction = this.pingTarget.GetComponent <PurchaseInteraction>();
                Sprite               sprite     = Resources.Load <Sprite>("Textures/MiscIcons/texInventoryIconOutlined");
                SpriteRenderer       component3 = this.interactablePingGameObjects[0].GetComponent <SpriteRenderer>();
                ShopTerminalBehavior component4 = this.pingTarget.GetComponent <ShopTerminalBehavior>();
                if (component4)
                {
                    PickupIndex pickupIndex = component4.CurrentPickupIndex();
                    text = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", text, component4.pickupIndexIsHidden ? "?" : Language.GetString(pickupIndex.GetPickupNameToken()));
                }
                else if (this.pingTarget.gameObject.name.Contains("Shrine"))
                {
                    sprite = Resources.Load <Sprite>("Textures/MiscIcons/texShrineIconOutlined");
                }
                else if (this.pingTarget.GetComponent <GenericPickupController>())
                {
                    sprite            = Resources.Load <Sprite>("Textures/MiscIcons/texLootIconOutlined");
                    this.pingDuration = 60f;
                }
                else if (this.pingTarget.GetComponent <TeleporterInteraction>())
                {
                    sprite            = Resources.Load <Sprite>("Textures/MiscIcons/texTeleporterIconOutlined");
                    this.pingDuration = 60f;
                }
                else if (this.pingTarget.GetComponent <SummonMasterBehavior>())
                {
                    sprite = Resources.Load <Sprite>("Textures/MiscIcons/texDroneIconOutlined");
                }
                array = this.interactablePingGameObjects;
                for (int i = 0; i < array.Length; i++)
                {
                    array[i].SetActive(true);
                }
                Renderer componentInChildren;
                if (modelLocator)
                {
                    componentInChildren = modelLocator.modelTransform.GetComponentInChildren <Renderer>();
                }
                else
                {
                    componentInChildren = this.pingTarget.GetComponentInChildren <Renderer>();
                }
                if (componentInChildren)
                {
                    this.pingHighlight.highlightColor = Highlight.HighlightColor.interactive;
                    this.pingHighlight.targetRenderer = componentInChildren;
                    this.pingHighlight.strength       = 1f;
                    this.pingHighlight.isOn           = true;
                }
                component3.sprite = sprite;
                if (this.pingTargetPurchaseInteraction && this.pingTargetPurchaseInteraction.costType != CostTypeIndex.None)
                {
                    PingIndicator.sharedStringBuilder.Clear();
                    CostTypeCatalog.GetCostTypeDef(this.pingTargetPurchaseInteraction.costType).BuildCostStringStyled(this.pingTargetPurchaseInteraction.cost, PingIndicator.sharedStringBuilder, false, true);
                    Chat.AddMessage(string.Format(Language.GetString("PLAYER_PING_INTERACTABLE_WITH_COST"), bestMasterName, text, PingIndicator.sharedStringBuilder.ToString()));
                }
                else
                {
                    Chat.AddMessage(string.Format(Language.GetString("PLAYER_PING_INTERACTABLE"), bestMasterName, text));
                }
                break;
            }
            }
            this.pingText.color = this.textBaseColor * this.pingColor;
            this.fixedTimer     = this.pingDuration;
        }