Esempio n. 1
0
        public static ModMedicine FindBestAndroidCompatMedicine(Pawn p)
        {
            ModMedicine bestMed = medList[0];

            if (DynGetMedicalCare(p) == MedicalCareCategory.NoMeds)
            {
                bestMed = medList[1];
            }
            if (IsAndroid(p))
            {
                List <ModMedicine> localMedList = androidMedList;
                if (MOARANDROIDS.Settings.androidsCanUseOrganicMedicine)
                {
                    localMedList = medList;
                }

                for (int i = 2; i < localMedList.Count; i++)
                {
                    if (!GetDynamicAllowsMedicine(DynGetMedicalCare(p), localMedList[i].thingDef))
                    {
                        continue;
                    }
                    if (localMedList[i].potency > bestMed.potency)
                    {
                        bestMed = localMedList[i];
                    }
                    else if (localMedList[i].potency == bestMed.potency)
                    {
                        if (IsAndroidMedicine(localMedList[i]))
                        {
                            bestMed = localMedList[i];
                        }
                    }
                }
            }
            else
            {
                List <ModMedicine> localMedList = humanMedList;

                for (int i = 2; i < localMedList.Count; i++)
                {
                    if (!GetDynamicAllowsMedicine(DynGetMedicalCare(p), localMedList[i].thingDef))
                    {
                        continue;
                    }
                    if (localMedList[i].potency > bestMed.potency)
                    {
                        bestMed = localMedList[i];
                    }
                    else if (localMedList[i].potency == bestMed.potency)
                    {
                        if (!IsAndroidMedicine(localMedList[i]))
                        {
                            bestMed = localMedList[i];
                        }
                    }
                }
            }
            return(bestMed);
        }
Esempio n. 2
0
        public static IEnumerable <Widgets.DropdownMenuElement <MedicalCareCategory> > DynMedGenerateMenu(Pawn p)
        {
            List <ModMedicine> localMedList = medList;

            if (androids)
            {
                localMedList = GetAndroidCompatMedList(p);
            }
            for (int i = 0; i < localMedList.Count; i++)
            {
                ModMedicine med = localMedList[i];

                yield return(new Widgets.DropdownMenuElement <MedicalCareCategory>
                {
                    /*
                     * option = new FloatMenuOption(med.care.GetLabel(), delegate
                     * {
                     *  p.playerSettings.medCare = med.care;
                     * }, MenuOptionPriority.Default, null, null, 30f, rect =>
                     * {
                     *  //Float menu medicine icon inspired by Fluffy's Pharmacist.
                     *  Rect iconRect = new Rect(0f, 0f, 24, 24).CenteredOnXIn(rect).CenteredOnYIn(rect);
                     *  GUI.DrawTexture(iconRect, med.tex);
                     *  return false;
                     * }, null),
                     * payload = med.care*/
                    option = new FloatMenuOption(med.care.GetLabel(), delegate
                    {
                        p.playerSettings.medCare = med.care;
                    }, med.tex, Color.white),
                    payload = med.care
                });
            }
        }
Esempio n. 3
0
        public static void DynamicMedicalCareSetter(Rect rect, ref MedicalCareCategory medCare)
        {
            //modified CareSetter/UI panel
            float scaleFacV = 0.5f;
            float scaleFacH = 5.0f / (medList.Count);
            int   nFirstRow = (int)Mathf.Ceil(0.5f * medList.Count);
            bool  row       = (scaleFacV > scaleFacH);

            if (row)
            {
                scaleFacH = 5.0f / nFirstRow;
            }
            float scaleFac = Mathf.Max(scaleFacV, scaleFacH);



            Rect rect2 = new Rect(rect.x, rect.y + (row ? scaleFac * -0.5f * rect.height : (1f - scaleFac) * rect.height * 0.5f), rect.width * scaleFac / 5, rect.height * scaleFac);

            for (int i = 0; i < medList.Count; i++)
            {
                ModMedicine med = medList[i];

                Widgets.DrawHighlightIfMouseover(rect2);
                GUI.DrawTexture(rect2, med.tex);

                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect2, false);
                if (draggableResult == Widgets.DraggableResult.Dragged)
                {
                    medicalCarePainting = true;
                }
                if ((medicalCarePainting && Mouse.IsOver(rect2) && medCare != med.care) || (draggableResult == Widgets.DraggableResult.Pressed || draggableResult == Widgets.DraggableResult.DraggedThenPressed))
                {
                    medCare = med.care;
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                }
                if (medCare == med.care)
                {
                    Widgets.DrawBox(rect2, 1);
                }
                TooltipHandler.TipRegion(rect2, () => med.care.GetLabel(), 632165 + (int)med.care * 17);

                rect2.x += rect2.width;
                if (row)
                {
                    if (i == nFirstRow - 1)
                    {
                        rect2.y += rect2.height;
                        rect2.x  = rect.x;
                    }
                }
            }
            if (!Input.GetMouseButton(0))
            {
                medicalCarePainting = false;
            }
        }
Esempio n. 4
0
        public static IEnumerable <Widgets.DropdownMenuElement <MedicalCareCategory> > DynMedGenerateMenu(Pawn p)
        {
            for (int i = 0; i < medList.Count; i++)
            {
                ModMedicine med = medList[i];

                yield return(new Widgets.DropdownMenuElement <MedicalCareCategory>
                {
                    option = new FloatMenuOption(med.care.GetLabel(), delegate
                    {
                        p.playerSettings.medCare = med.care;
                    }, MenuOptionPriority.Default, null, null, 30f, rect =>
                    {
                        //Float menu medicine icon inspired by Fluffy's Pharmacist.
                        Rect iconRect = new Rect(0f, 0f, 24, 24).CenteredOnXIn(rect).CenteredOnYIn(rect);
                        GUI.DrawTexture(iconRect, med.tex);
                        return false;
                    }, null),
                    payload = med.care
                });
            }
        }
Esempio n. 5
0
 public static bool IsAndroidMedicine(ModMedicine m)
 {
     return(MOARANDROIDS.Utils.ExceptionNanoKits.Contains(m.thingDef.defName));
 }
Esempio n. 6
0
        public static void DynamicMedicalCareSetter(Rect rect, ref MedicalCareCategory medCare)
        {
            //modified CareSetter/UI panel
            Widgets.DrawHighlightIfMouseover(rect);

            //aspect = number of squares rect fits along the width that are height x height
            int aspect = Mathf.FloorToInt(rect.width / rect.height);

            //initialScaleFac is how much to scale the texture to make it the height of the rect
            float initialScaleFac = medList[0].tex.height / rect.height;

            List <ModMedicine> localMedList = medList;

            if (androids && currentMedCarePawn != null)
            {
                localMedList = GetAndroidCompatMedList(currentMedCarePawn);
            }

            int nRows  = 1;
            int nInRow = 0;

            if (localMedList.Count > aspect * 2)
            {
                nRows = Mathf.CeilToInt(Mathf.Sqrt((float)localMedList.Count / (float)aspect));
            }
            int nPerRow = Mathf.CeilToInt((float)localMedList.Count / (float)nRows);


            float scaleFac = Mathf.Min((float)aspect / (localMedList.Count), 1.0f);

            if (nRows > 1)
            {
                scaleFac = 1.0f / nRows;
            }
            //scaleFac *= initialScaleFac;

            Rect rect2 = new Rect(rect.x + 0.5f * (rect.width - (nPerRow * scaleFac * rect.height)), rect.y + (1 - scaleFac * nRows) * 0.5f * rect.height, rect.height * scaleFac, rect.height * scaleFac);

            for (int i = 0; i < localMedList.Count; i++)
            {
                ModMedicine med = localMedList[i];

                //if (medCare == med.care)
                if ((i > 1 && med.potency == indexedMedList[(int)medCare].potency) || medCare == med.care)
                {
                    Widgets.DrawBox(rect2, 1);
                }

                if ((med.potency <= indexedMedList[(int)medCare].potency && i != 0 && (int)medCare != 0) || medCare == med.care)
                {
                    Widgets.DrawBoxSolid(rect2, new Color(0, 1, 1, 0.3f));
                }

                Widgets.DrawHighlightIfMouseover(rect2);
                GUI.DrawTexture(rect2, med.tex);

                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect2, false);
                if (draggableResult == Widgets.DraggableResult.Dragged)
                {
                    medicalCarePainting = true;
                }
                if ((medicalCarePainting && Mouse.IsOver(rect2) && medCare != med.care) || (draggableResult == Widgets.DraggableResult.Pressed || draggableResult == Widgets.DraggableResult.DraggedThenPressed))
                {
                    medCare = med.care;
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                }
                TooltipHandler.TipRegion(rect2, () => med.care.GetLabel(), 632165 + (int)med.care * 17);

                nInRow++;

                rect2.x += rect2.width;
                if (nInRow == nPerRow)
                {
                    nInRow   = 0;
                    rect2.y += rect2.height;
                    rect2.x  = rect.x + 0.5f * (rect.width - (nPerRow * scaleFac * rect.height));
                }
            }
            if (!Input.GetMouseButton(0))
            {
                medicalCarePainting = false;
            }
        }