示例#1
0
        public void AdjustSlotElement(MechLabItemSlotElement instance, MechLabPanel panel)
        {
            var weights = instance.ComponentRef?.Def?.GetComponent <Weights>();

            if (weights == null)
            {
                return;
            }

            var mechDef = panel.activeMechDef;

            if (mechDef == null)
            {
                return;
            }

            var tonnageChanges = CalculateWeightChanges(mechDef, weights);
            var adapter        = new MechLabItemSlotElementAdapter(instance);

            if (!Mathf.Approximately(tonnageChanges, 0))
            {
                adapter.bonusTextA.text = $"{FloatToText(tonnageChanges)} ton";
            }
            else if (adapter.bonusTextA.text.EndsWith("ton"))
            {
                adapter.bonusTextA.text = instance.ComponentRef.Def.BonusValueA;
            }
        }
        public void AdjustSlotElement(MechLabItemSlotElement instance, MechLabPanel panel)
        {
            var def = instance.ComponentRef.GetComponent <EngineHeatBlockDef>();

            if (def == null)
            {
                return;
            }

            if (panel.activeMechDef == null || panel.activeMechDef.Chassis == null)
            {
                return;
            }

            var engine = panel.GetEngine();

            if (engine == null)
            {
                return;
            }

            var adapter = new MechLabItemSlotElementAdapter(instance);

            adapter.bonusTextA.text = BonusValueEngineHeatDissipation(engine);
            adapter.bonusTextB.text = BonusValueEngineHeatSinkCounts(engine);
        }
示例#3
0
        internal void ApplyTo(MechLabItemSlotElement element, bool isReservedSlot)
        {
            var adapter = new MechLabItemSlotElementAdapter(element);

            if (NameText == "")
            {
                adapter.nameText.gameObject.SetActive(false);
            }
            else if (NameText != null)
            {
                adapter.nameText.text = NameText;
                adapter.nameText.gameObject.SetActive(true);
            }

            if (BonusAText == "")
            {
                adapter.bonusTextA.gameObject.SetActive(false);
            }
            else if (BonusAText != null)
            {
                adapter.bonusTextA.text = BonusAText;
                adapter.bonusTextA.gameObject.SetActive(true);
            }

            if (BonusBText == "")
            {
                adapter.bonusTextB.gameObject.SetActive(false);
            }
            else if (BonusBText != null)
            {
                adapter.bonusTextB.text = BonusBText;
                adapter.bonusTextB.gameObject.SetActive(true);
            }

            if (!string.IsNullOrEmpty(BackgroundColor))
            {
                adapter.backgroundColor.SetColorFromString(BackgroundColor);
            }

            if (ShowIcon.HasValue)
            {
                adapter.icon.gameObject.SetActive(ShowIcon.Value);
            }

            if (ShowFixedEquipmentOverlay.HasValue)
            {
                adapter.fixedEquipmentOverlay.gameObject.SetActive(ShowFixedEquipmentOverlay.Value);
            }

            var text = isReservedSlot ? DynamicSlotsFeature.settings.ReservedSlotText : DynamicSlotsFeature.settings.MovableSlotText;

            adapter.bonusTextA.SetText(new Text(text).ToString());
            adapter.bonusTextA.gameObject.SetActive(true);
        }
            internal void Show(DynamicSlots.DynamicSlots dynamicSlots)
            {
                var def  = dynamicSlots.Def;
                var @ref = new MechComponentRef(def.Description.Id, null, def.ComponentType, ChassisLocations.None)
                {
                    DataManager = def.DataManager
                };

                @ref.RefreshComponentDef();
                element.SetData(@ref, ChassisLocations.None, def.DataManager, null);
                var adapter = new MechLabItemSlotElementAdapter(element);

                if (dynamicSlots.NameText != null)
                {
                    adapter.nameText.text = dynamicSlots.NameText;
                }

                if (dynamicSlots.BonusAText == "")
                {
                    adapter.bonusTextA.gameObject.SetActive(false);
                }
                else if (dynamicSlots.BonusAText != null)
                {
                    adapter.bonusTextA.text = dynamicSlots.BonusAText;
                    adapter.bonusTextA.gameObject.SetActive(true);
                }

                if (dynamicSlots.BonusBText == "")
                {
                    adapter.bonusTextB.gameObject.SetActive(false);
                }
                else if (dynamicSlots.BonusBText != null)
                {
                    adapter.bonusTextB.text = dynamicSlots.BonusBText;
                    adapter.bonusTextB.gameObject.SetActive(true);
                }

                if (dynamicSlots.BackgroundColor != null)
                {
                    adapter.backgroundColor.SetUIColor(dynamicSlots.BackgroundColor.Value);
                }

                adapter.icon.gameObject.SetActive(dynamicSlots.ShowIcon);

                gameObject.SetActive(true);
                element.SetDraggable(false);
            }
示例#5
0
        public void AdjustSlotElement(MechLabItemSlotElement instance, MechLabPanel panel)
        {
            var def = instance.ComponentRef.GetComponent<CoolingDef>();
            if (def == null)
            {
                return;
            }

            var mechDef = panel.activeMechDef;
            if (mechDef == null)
            {
                return;
            }

            var engine = mechDef.GetEngine();

            var adapter = new MechLabItemSlotElementAdapter(instance);
            adapter.bonusTextB.text = BonusValueEngineHeatSinkCounts(engine);
        }
示例#6
0
            internal void Show(DynamicSlots.DynamicSlots dynamicSlots)
            {
                var def  = dynamicSlots.Def;
                var @ref = new MechComponentRef(def.Description.Id, null, def.ComponentType, ChassisLocations.None)
                {
                    DataManager = def.DataManager
                };

                @ref.RefreshComponentDef();
                element.SetData(@ref, ChassisLocations.None, def.DataManager, null);

                var adapter = new MechLabItemSlotElementAdapter(element);

                if (dynamicSlots.NameText != null)
                {
                    adapter.nameText.text = dynamicSlots.NameText;
                }

                if (dynamicSlots.BonusAText == "")
                {
                    adapter.bonusTextA.gameObject.SetActive(false);
                }
                else if (dynamicSlots.BonusAText != null)
                {
                    adapter.bonusTextA.text = dynamicSlots.BonusAText;
                    adapter.bonusTextA.gameObject.SetActive(true);
                }

                if (dynamicSlots.BonusBText == "")
                {
                    adapter.bonusTextB.gameObject.SetActive(false);
                }
                else if (dynamicSlots.BonusBText != null)
                {
                    adapter.bonusTextB.text = dynamicSlots.BonusBText;
                    adapter.bonusTextB.gameObject.SetActive(true);
                }

                if (!string.IsNullOrEmpty(dynamicSlots.BackgroundColor))
                {
                    adapter.backgroundColor.SetColorFromString(dynamicSlots.BackgroundColor);
                }

                if (dynamicSlots.ShowIcon.HasValue)
                {
                    adapter.icon.gameObject.SetActive(dynamicSlots.ShowIcon.Value);
                }

                if (dynamicSlots.ShowFixedEquipmentOverlay.HasValue)
                {
                    adapter.fixedEquipmentOverlay.gameObject.SetActive(dynamicSlots.ShowFixedEquipmentOverlay.Value);
                }

                {
                    adapter.spacers[0].SetActive(true);
                    foreach (var spacer in adapter.spacers)
                    {
                        spacer.SetActive(false);
                    }
                    element.thisRectTransform.sizeDelta = new Vector2(element.thisRectTransform.sizeDelta.x, 32f * 1);
                }
                gameObject.SetActive(true);
                element.SetDraggable(false);
            }