コード例 #1
0
        /// <summary>
        ///     Get a texture for the def, where defined.
        /// </summary>
        /// <param name="def"></param>
        /// <returns></returns>
        public static Texture2D IconTexture(this Def def)
        {
            // garbage in, garbage out
            if (def == null)
            {
                return(null);
            }

            // check cache
            if (_cachedDefIcons.ContainsKey(def))
            {
                return(_cachedDefIcons[def]);
            }

            // otherwise try to determine icon
            var buildableDef = def as BuildableDef;
            var thingDef     = def as ThingDef;
            var pawnKindDef  = def as PawnKindDef;
            var recipeDef    = def as RecipeDef;

            // recipes will be passed icon of first product, if defined.
            if (
                recipeDef != null &&
                !recipeDef.products.NullOrEmpty()
                )
            {
                _cachedDefIcons.Add(def, recipeDef.products.First().thingDef.IconTexture());
                return(_cachedDefIcons[def]);
            }

            // animals need special treatment ( this will still only work for animals, pawns are a whole different can o' worms ).
            if (pawnKindDef != null)
            {
                try
                {
                    _cachedDefIcons.Add(
                        def, pawnKindDef.lifeStages.Last().bodyGraphicData.Graphic.MatSouth.mainTexture as Texture2D);
                    return(_cachedDefIcons[def]);
                }
                catch
                {
                    // ignored
                }
            }

            if (buildableDef != null)
            {
                // if def built != def listed.
                if (thingDef?.entityDefToBuild != null)
                {
                    _cachedDefIcons.Add(def, thingDef.entityDefToBuild.IconTexture());
                    return(_cachedDefIcons[def]);
                }

                _cachedDefIcons.Add(def, buildableDef.uiIcon);
                return(buildableDef.uiIcon);
            }

            // nothing stuck
            Texture2D defaultText = ContentFinder <Texture2D> .Get("Icons/circle-fill");

            _cachedDefIcons.Add(def, defaultText);
            return(defaultText);
        }
コード例 #2
0
        static Comp_LaserDrill()
        {
            UI_LASER_ACTIVATE = ContentFinder <Texture2D> .Get("UI/Power/SteamGeyser", true);

            UI_LASER_ACTIVATEFILL = ContentFinder <Texture2D> .Get("UI/Power/RemoveSteamGeyser", true);
        }
コード例 #3
0
 public static Texture2D Icon()
 {
     return(ContentFinder <Texture2D> .Get("alarmbell", true));
 }
コード例 #4
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            float offsetN10 = RoundedToCurrentTempModeOffset(-10f);
            float offsetN1  = RoundedToCurrentTempModeOffset(-1f);
            float offset1   = RoundedToCurrentTempModeOffset(1f);
            float offset10  = RoundedToCurrentTempModeOffset(10f);

            foreach (Gizmo g in base.CompGetGizmosExtra())
            {
                yield return(g);
            }
            yield return(new Command_Action
            {
                action = delegate { Find.WindowStack.Add(new Dialog_RenameFridge(this)); },
                defaultLabel = "CommandRenameZoneLabel".Translate(),
                defaultDesc = "RimFridge.RenameTheRefrigerator".Translate(),
                hotKey = KeyBindingDefOf.Misc1,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/RenameZone", true),
            });

            yield return(new Command_Action
            {
                action = delegate { InterfaceChangeTargetTemperature(offsetN10); },
                defaultLabel = offsetN10.ToStringTemperatureOffset("F0"),
                defaultDesc = "CommandLowerTempDesc".Translate(),
                //hotKey = KeyBindingDefOf.Misc5,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempLower", true)
            });

            yield return(new Command_Action
            {
                action = delegate { InterfaceChangeTargetTemperature(offsetN1); },
                defaultLabel = offsetN1.ToStringTemperatureOffset("F0"),
                defaultDesc = "CommandLowerTempDesc".Translate(),
                //hotKey = KeyBindingDefOf.Misc4,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempLower", true)
            });

            yield return(new Command_Action
            {
                action = delegate { desiredTemp = defaultDesiredTemperature; },
                defaultLabel = "CommandResetTemp".Translate(),
                defaultDesc = "CommandResetTempDesc".Translate(),
                //hotKey = KeyBindingDefOf.Misc1,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempReset", true)
            });

            yield return(new Command_Action
            {
                action = delegate { InterfaceChangeTargetTemperature(offset1); },
                defaultLabel = "+" + offset1.ToStringTemperatureOffset("F0"),
                defaultDesc = "CommandRaiseTempDesc".Translate(),
                //hotKey = KeyBindingDefOf.Misc2,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempRaise", true)
            });

            yield return(new Command_Action
            {
                action = delegate { InterfaceChangeTargetTemperature(offset10); },
                defaultLabel = "+" + offset10.ToStringTemperatureOffset("F0"),
                defaultDesc = "CommandRaiseTempDesc".Translate(),
                //hotKey = KeyBindingDefOf.Misc3,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempRaise", true)
            });
        }
コード例 #5
0
        public override void DoWindowContents(Rect inRect)
        {
            var  contentRect      = new Rect(0, 0, inRect.width, inRect.height - (CloseButSize.y + 10f)).ContractedBy(10f);
            bool scrollBarVisible = totalContentHeight > contentRect.height;
            var  scrollViewTotal  = new Rect(0f, 0f, contentRect.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight);

            Widgets.DrawHighlight(contentRect);
            Widgets.BeginScrollView(contentRect, ref scrollPosition, scrollViewTotal);
            float curY = 0f;
            Rect  r    = new Rect(0, curY, scrollViewTotal.width, LabelHeight);

            Widgets.CheckboxLabeled(r, "LWMDSperDSUturnOn".Translate(), ref Settings.allowPerDSUSettings);//TODO
            TooltipHandler.TipRegion(r, "LWMDSperDSUturnOnDesc".Translate());
            curY += LabelHeight + 1f;
            if (!Settings.allowPerDSUSettings)
            {
                r = new Rect(5f, curY, scrollViewTotal.width - 10f, LabelHeight);
                Widgets.Label(r, "LWMDSperDSUWarning".Translate());
                curY += LabelHeight;
            }
            Widgets.DrawLineHorizontal(0f, curY, scrollViewTotal.width);
            curY += 10f;

            // todo: make this static?
            //List<ThingDef> l=DefDatabase<ThingDef>.AllDefsListForReading.Where(ThingDef d => d.Has

            // Roll my own buttons, because dammit, I want left-justified buttons:
            //   (mirroring Widgets.ButtonTextWorker)
            GenUI.SetLabelAlign(TextAnchor.MiddleLeft);
            var bg = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBG", true);

            var bgmouseover = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGMouseover", true);

            var bgclick = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGClick", true);

            //  note: make own list b/c this can modify what's in the DefDatabase.
            foreach (ThingDef u in Settings.AllDeepStorageUnits.ToList())
            {
                //////////////// Disble button: //////////////////
                // disabled if it's already been disabled previously
                //   or if it's slated to be disabled on window close
                bool isEnabled = !tracker.HasDefaultValueFor(u.defName, "def") &&
                                 (this.unitsToBeDisabled == null || !unitsToBeDisabled.Contains(u));
                bool wasEnabled  = isEnabled;
                Rect disableRect = new Rect(5f, curY, LabelHeight, LabelHeight);
                TooltipHandler.TipRegion(disableRect, "TODO: Add description. But basically, you can disable some units and they won't show up in game.\n\nVERY likely to cause unimportant errors in saved games.");
                Widgets.Checkbox(disableRect.x, disableRect.y, ref isEnabled, LabelHeight, false, true, null, null);
                if (!isEnabled && wasEnabled)   // newly disabled
                {
                    Utils.Warn(Utils.DBF.Settings, "Marking unit for disabling: " + u.defName);
                    if (unitsToBeDisabled == null)
                    {
                        unitsToBeDisabled = new HashSet <ThingDef>();
                    }
                    unitsToBeDisabled.Add(u); // hash sets don't care if it's already there!
                }
                if (isEnabled && !wasEnabled) // add back:
                {
                    Utils.Warn(Utils.DBF.Settings, "Restoring disabled unit: " + u.defName);
                    if (unitsToBeDisabled != null && unitsToBeDisabled.Contains(u))
                    {
                        unitsToBeDisabled.Remove(u);
                    }
                    if (tracker.HasDefaultValueFor(u.defName, "def"))
                    {
                        tracker.Remove(u.defName, "def");
                    }
                    if (!DefDatabase <ThingDef> .AllDefsListForReading.Contains(u))
                    {
                        ReturnDefToUse(u);
                    }
                }
                //////////////// Select def: //////////////////
                r = new Rect(10f + LabelHeight, curY, (scrollViewTotal.width) * 2 / 3 - 12f - LabelHeight, LabelHeight);
                // Draw button-ish background:
                Texture2D atlas = bg;
                if (Mouse.IsOver(r))
                {
                    atlas = bgmouseover;
                    if (Input.GetMouseButton(0))
                    {
                        atlas = bgclick;
                    }
                }
                Widgets.DrawAtlas(r, atlas);
                // button text:
                Widgets.Label(r, u.label + " (defName: " + u.defName + ")");
                // button clickiness:
                if (Widgets.ButtonInvisible(r))
                {
                    Find.WindowStack.Add(new Dialog_DSU_Settings(u));
                }
                //////////////// Reset button: //////////////////
                r = new Rect((scrollViewTotal.width) * 2 / 3 + 2f, curY, (scrollViewTotal.width) / 3 - 7f, LabelHeight);
                if (tracker.IsChanged(u.defName) && Widgets.ButtonText(r, "ResetBinding".Translate()))
                {
                    ResetDSUToDefaults(u.defName);
                }
                curY += LabelHeight + 2f;
            }
            GenUI.ResetLabelAlign();
            // end buttons

            Widgets.EndScrollView();
            // close button:
            r = new Rect(inRect.width / 2 - (CloseButSize.x / 2), inRect.height - CloseButSize.y - 5f, CloseButSize.x, CloseButSize.y);
            if (Widgets.ButtonText(r, "CloseButton".Translate()))
            {
                if (unitsToBeDisabled != null && unitsToBeDisabled.Count > 0)
                {
                    //TODO: add out-of-order flag.
                    foreach (ThingDef d in unitsToBeDisabled)
                    {
                        Utils.Warn(Utils.DBF.Settings, "Closing Window: Removing def: " + d.defName);
                        RemoveDefFromUse(d);
                        tracker.AddDefaultValue(d.defName, "def", d);
                    }
                    unitsToBeDisabled = null;
                }
                Close();
            }
            r = new Rect(10f, inRect.height - CloseButSize.y - 5f, 2 * CloseButSize.x, CloseButSize.y);
            if (tracker.HasAnyDefaultValues && Widgets.ButtonText(r, "LWM.ResetAllToDefault".Translate()))
            {
                Utils.Mess(Utils.DBF.Settings, "Resetting all per-building storage settings to default:");
                ResetAllToDefaults();
            }
            totalContentHeight = curY;
        }
コード例 #6
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())             // added
            {
                yield return(c);
            }

            // added
            if (this.def.defName == "AvaliTurretLarge")
            {
                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(-1f);
                    },
                    defaultLabel = "-1",
                    defaultDesc = "CommandDecreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc5,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DecreaseDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(-0.1f);
                    },
                    defaultLabel = "-0.1",
                    defaultDesc = "CommandDecreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc4,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DecreaseDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        turretBurstCooldownTime = defaultDelay;
                        def.building.turretBurstCooldownTime = turretBurstCooldownTime;
                        SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                        MoteMaker.ThrowText(this.TrueCenter() + new Vector3(0.5f, 0f, 0.5f), this.Map, turretBurstCooldownTime.ToString(), Color.white, -1f);
                    },
                    defaultLabel = "CommandDefaultTurretShootDelay".Translate(),
                    defaultDesc = "CommandDefaultTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc1,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DefaultDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(0.1f);
                    },
                    defaultLabel = "+0.1",
                    defaultDesc = "CommandIncreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc2,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/IncreaseDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(1f);
                    },
                    defaultLabel = "+1",
                    defaultDesc = "CommandIncreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc3,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/IncreaseDelay", true)
                });
            }
            // added

            if (this.CanExtractShell)
            {
                CompChangeableProjectile changeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();
                yield return(new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = changeableProjectile.LoadedShell.uiIcon,
                    iconAngle = changeableProjectile.LoadedShell.uiIconAngle,
                    iconOffset = changeableProjectile.LoadedShell.uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(changeableProjectile.LoadedShell),
                    alsoClickIfOtherInGroupClicked = false,
                    action = delegate
                    {
                        GenPlace.TryPlaceThing(changeableProjectile.RemoveShell(), this.Position, this.Map, ThingPlaceMode.Near, null, null);
                    }
                });
            }
            if (this.CanSetForcedTarget)
            {
                Command_VerbTarget attack = new Command_VerbTarget();
                attack.defaultLabel = "CommandSetForceAttackTarget".Translate();
                attack.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                attack.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true);

                attack.verb   = this.AttackVerb;
                attack.hotKey = KeyBindingDefOf.Misc4;
                if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    attack.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return(attack);
            }
            if (this.forcedTarget.IsValid)
            {
                Command_Action stop = new Command_Action();
                stop.defaultLabel = "CommandStopForceAttack".Translate();
                stop.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                stop.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true);

                stop.action = delegate
                {
                    this.ResetForcedTarget();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                };
                if (!this.forcedTarget.IsValid)
                {
                    stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                stop.hotKey = KeyBindingDefOf.Misc5;
                yield return(stop);
            }
            if (this.CanToggleHoldFire)
            {
                yield return(new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate
                    {
                        this.holdFire = !this.holdFire;
                        if (this.holdFire)
                        {
                            this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => this.holdFire)
                });
            }
            yield break;
        }
コード例 #7
0
 public static Texture2D Icon()
 {
     return(ContentFinder <Texture2D> .Get("NaturalLightMap", true));
 }
コード例 #8
0
        //咖喱技能3
        public static Command_CastSkill Skill3()
        {
            var ck = new Command_CastSkillTargetingFloor
            {
                defaultLabel    = "VoltSkill3.name".Translate(),
                icon            = ContentFinder <Texture2D> .Get("Skills/VoltSkill3"),
                targetingParams = WarframeStaticMethods.JumpTP(),
                cooldownTime    = 0.2f,
                range           = 2f,
                hotKey          = KeyBindingDefOf.Misc4
            };

            ck.finishAction = delegate { GenDraw.DrawFieldEdges(ck.self.CellsAdjacent8WayAndInside().ToList()); };
            ck.action       = delegate(Pawn self, LocalTargetInfo target)
            {
                if (!self.CellsAdjacent8WayAndInside().Contains(target.Cell) || target.Cell == self.Position)
                {
                    SoundDefOf.ClickReject.PlayOneShotOnCamera();
                    return;
                }

                var dire = new List <IntVec3> {
                    target.Cell
                };
                var rotat = 0f;
                if (target.Cell.x == self.Position.x)
                {
                    dire.Add(target.Cell + new IntVec3(-1, 0, 0));
                    dire.Add(target.Cell + new IntVec3(1, 0, 0));
                }
                else if (target.Cell.z == self.Position.z)
                {
                    dire.Add(target.Cell + new IntVec3(0, 0, -1));
                    dire.Add(target.Cell + new IntVec3(0, 0, 1));
                    rotat = 90f;
                }
                else if (target.Cell.x > self.Position.x)
                {
                    if (target.Cell.z > self.Position.z)
                    {
                        dire.Add(target.Cell + new IntVec3(-1, 0, 1));
                        dire.Add(target.Cell + new IntVec3(1, 0, -1));
                        dire.Add(target.Cell + new IntVec3(-1, 0, 0));
                        dire.Add(target.Cell + new IntVec3(0, 0, -1));
                        rotat = 45f;
                    }
                    else
                    {
                        dire.Add(target.Cell + new IntVec3(-1, 0, -1));
                        dire.Add(target.Cell + new IntVec3(1, 0, 1));
                        dire.Add(target.Cell + new IntVec3(-1, 0, 0));
                        dire.Add(target.Cell + new IntVec3(0, 0, 1));
                        rotat = 135f;
                    }
                }
                else if (target.Cell.x < self.Position.x)
                {
                    if (target.Cell.z > self.Position.z)
                    {
                        dire.Add(target.Cell + new IntVec3(-1, 0, -1));
                        dire.Add(target.Cell + new IntVec3(1, 0, 1));
                        dire.Add(target.Cell + new IntVec3(1, 0, 0));
                        dire.Add(target.Cell + new IntVec3(0, 0, -1));
                        rotat = 135f;
                    }
                    else
                    {
                        dire.Add(target.Cell + new IntVec3(-1, 0, 1));
                        dire.Add(target.Cell + new IntVec3(1, 0, -1));
                        dire.Add(target.Cell + new IntVec3(1, 0, 0));
                        dire.Add(target.Cell + new IntVec3(0, 0, 1));
                        rotat = 45f;
                    }
                }


                var Volt3s = (Volt3SkillThing)ThingMaker.MakeThing(ThingDef.Named("VoltSkill3Item"));
                Volt3s.self  = self;
                Volt3s.dire  = dire;
                Volt3s.rotat = rotat;
                GenSpawn.Spawn(Volt3s, target.Cell, self.Map);
                SoundDef.Named("Volt_3Skill").PlayOneShot(self);

                WarframeStaticMethods.StartCooldown(self, ck.cooldownTime, 3,
                                                    WarframeStaticMethods.GetArmor(self).TryGetComp <CompWarframeSkill>().skill3mana);
            };


            return(ck);
        }
コード例 #9
0
        //咖喱技能1
        public static Command_CastSkill Skill1()
        {
            var ck = new Command_CastSkillTargetingFloor
            {
                defaultLabel    = "VoltSkill1.name".Translate(),
                icon            = ContentFinder <Texture2D> .Get("Skills/VoltSkill1"),
                targetingParams = WarframeStaticMethods.JumpTP(),
                cooldownTime    = 0.2f,
                range           = 11f
            };

            ck.finishAction = delegate
            {
                GenDraw.DrawRadiusRing(UI.MouseCell(), 5f * (1 + (ck.self.GetLevel() * 1f / 30f)));
                GenDraw.DrawFieldEdges(WarframeStaticMethods.GetCellsAround(ck.self.Position, ck.self.Map, ck.range));
            };
            ck.hotKey = KeyBindingDefOf.Misc5;
            ck.action = delegate(Pawn self, LocalTargetInfo target)
            {
                // GenExplosion.DoExplosion(self.Position, self.Map, 3.5f, DaVolteDefOf.Bomb, self, -1, -1, null, null, null, null, null, 0, 1, false, null, 0, 1, 0, false);
                if (!WarframeStaticMethods.GetCellsAround(self.Position, self.Map, ck.range).Contains(target.Cell))
                {
                    SoundDefOf.ClickReject.PlayOneShotOnCamera();
                    return;
                }

                var cells = new List <IntVec3>();
                var num   = GenRadial.NumCellsInRadius(5f * (1 + (ck.self.GetLevel() * 1f / 30f)));
                for (var i = 0; i < num; i++)
                {
                    cells.Add(target.Cell + GenRadial.RadialPattern[i]);
                }

                var   ps     = 0;
                float damage = 20 + (2 * WarframeStaticMethods.GetWFLevel(self) / 5);
                var   dinfo  = new DamageInfo(DefDatabase <DamageDef> .GetNamed("Mag"), damage, 0, -1, self);
                foreach (var ic in cells)
                {
                    foreach (var th in self.Map.thingGrid.ThingsAt(ic))
                    {
                        if (th is not Pawn pawn || pawn.Faction == self.Faction)
                        {
                            continue;
                        }

                        ps++;
                        pawn.stances.stunner.StunFor(180, self);
                        pawn.TakeDamage(dinfo);
                        WarframeStaticMethods.ShowDamageAmount(pawn, damage.ToString("f0"));
                        if (ps >= 2 * (1 + (self.GetLevel() * 1f / 10f)))
                        {
                            break;
                        }
                    }

                    if (ps >= 2 * (1 + (self.GetLevel() * 1f / 10f)))
                    {
                        break;
                    }
                }


                SoundDef.Named("Volt_1Skill").PlayOneShot(self);

                WarframeStaticMethods.StartCooldown(self, ck.cooldownTime, 1,
                                                    WarframeStaticMethods.GetArmor(self).TryGetComp <CompWarframeSkill>().Props.mana1);
            };


            return(ck);
        }
コード例 #10
0
        private void MainContents(Rect mainRect)
        {
            boxstyle.hover    = boxstyle.normal;
            boxstyle.onHover  = boxstyle.normal;
            boxstyle.onNormal = boxstyle.normal;

            buttonstyle.onHover  = buttonstyle.onNormal;
            buttonstyle.hover    = buttonstyle.normal;
            boxstyle.border.left = 4; boxstyle.border.right = 4; boxstyle.border.bottom = 4; boxstyle.border.top = 4;

            fontstyleleft.normal.textColor = Color.white;

            float  preginfoheight = 0f;
            bool   pregnant       = pawn.IsPregnant();
            Hediff hediff         = PregnancyHelper.GetPregnancy(pawn);

            if (pregnant && Utility.ShowFetusImage((Hediff_BasePregnancy)hediff))
            {
                womb = comp.GetPregnancyIcon(hediff);
                if (hediff is Hediff_MultiplePregnancy)
                {
                    Hediff_MultiplePregnancy h = (Hediff_MultiplePregnancy)hediff;
                    if (h.GestationProgress < 0.2f)
                    {
                        cum = comp.GetCumIcon();
                    }
                    else
                    {
                        cum = ContentFinder <Texture2D> .Get(("Womb/Empty"), true);
                    }
                    Pawn fetus = pawn.GetFetus();
                    if (fetus != null && Utility.ShowFetusInfo())
                    {
                        string feinfo = h.GetBabyInfo();
                        string fainfo = h.GetFatherInfo() + "  ";
                        if (feinfo.Length + fainfo.Length > 45)
                        {
                            preginfoheight           = fontheight + 2;
                            buttonstyle.alignment    = TextAnchor.UpperLeft;
                            fontstyleright.alignment = TextAnchor.LowerRight;
                        }
                        else
                        {
                            preginfoheight        = fontheight;
                            buttonstyle.alignment = TextAnchor.MiddleLeft;
                        }
                        Rect preginfo = new Rect(0f, mainRect.yMax - wombRectHeight - 2, wombRectWidth, preginfoheight);
                        fontstyleright.normal.textColor = Color.white;
                        GUI.Box(preginfo, feinfo, buttonstyle);
                        GUI.Label(preginfo, fainfo, fontstyleright);
                    }
                }
                else if (hediff is Hediff_BasePregnancy)
                {
                    Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff;
                    if (h.GestationProgress < 0.2f)
                    {
                        cum = comp.GetCumIcon();
                    }
                    else
                    {
                        cum = ContentFinder <Texture2D> .Get(("Womb/Empty"), true);
                    }
                    Pawn fetus = pawn.GetFetus();
                    if (fetus != null && Utility.ShowFetusInfo())
                    {
                        preginfoheight = fontheight;
                        Rect preginfo = new Rect(0f, mainRect.yMax - wombRectHeight - 2, wombRectWidth, preginfoheight);
                        fontstyleright.normal.textColor = Color.white;
                        fontstyleright.alignment        = TextAnchor.MiddleRight;
                        buttonstyle.alignment           = TextAnchor.MiddleLeft;

                        GUI.Box(preginfo, h.babies.Count + " " + fetus.def.label + " " + Translations.Dialog_WombInfo02, buttonstyle);
                        GUI.Label(preginfo, Translations.Dialog_WombInfo03 + ": " + h.father.LabelShort + "  ", fontstyleright);
                    }
                }
                else
                {
                    cum = ContentFinder <Texture2D> .Get(("Womb/Empty"), true);
                }
            }
            else
            {
                womb = comp.GetWombIcon();
                cum  = comp.GetCumIcon();
            }


            Rect pawnRect = new Rect(0, 0, pawnRectWidth, pawnRectHeight);

            Widgets.DrawTextureFitted(pawnRect, PortraitsCache.Get(pawn, pawnRect.size), 1.0f);
            Rect pawnLabelRect  = new Rect(0, pawnRectHeight, pawnRectWidth, fontheight - 10);
            Rect pawnLabel2Rect = new Rect(0, pawnRectHeight + fontheight - 10, pawnRectWidth, fontheight - 10);

            fontstylecenter.normal.textColor = pawn.DrawColor;
            GUI.Label(pawnLabelRect, pawn.Name.ToStringFull, fontstylecenter);
            if (pawn.story != null)
            {
                GUI.Label(pawnLabel2Rect, pawn.story.Title, fontstylecenter);
            }
            GUI.color = Color.white;

            float wombrecth = 0;

            if (Configurations.DrawWombStatus)
            {
                wombrecth = wombRectHeight;
                cumcolor  = comp.GetCumMixtureColor;
                Rect wombRect = new Rect(0f, mainRect.yMax - wombRectHeight + preginfoheight, wombRectWidth, wombRectWidth * 0.9f);
                DrawWomb(wombRect);


                if (Configurations.DrawEggOverlay)
                {
                    comp.DrawEggOverlay(wombRect);
                }
            }

            Rect wombInfoRect = new Rect(0f, mainRect.yMax - wombrecth - fontheight - 2, wombRectWidth, fontheight);

            buttonstyle.normal.textColor = Color.white;
            //boxstyle.normal.background = Texture2D.whiteTexture;
            buttonstyle.alignment = TextAnchor.MiddleLeft;
            GUI.backgroundColor   = new Color(0.24f, 0.29f, 0.35f, 1);
            GUI.Box(wombInfoRect, Translations.Dialog_WombInfo01 + ": " + comp.GetCurStageLabel, buttonstyle);
            GUI.color = Color.white;


            fontstyleright.normal.textColor = Color.red;
            fontstyleright.alignment        = TextAnchor.MiddleRight;
            //if (comp.GetFertilization) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo05 + "  ", fontstyleright);
            //else if (comp.GetEggFertilizing) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo06 + "  ", fontstyleright);
            //else if (comp.GetEgg) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo07 + "  ", fontstyleright);
            GUI.Label(wombInfoRect, comp.GetFertilizingInfo + "  ", fontstyleright);


            //Widgets.Label(wombInfoRect,Translations.Dialog_WombInfo01 + ": " + comp.GetCurStageLabel);

            Rect cumlistTitle, cumlistRect;

            if (Configurations.DrawVaginaStatus && !pawn.IsAnimal())
            {
                Rect genitalRect = new Rect(pawnRectWidth + 24, pawnRectHeight + 2 * fontheight, genitalRectWidth, genitalRectHeight + fontheight * 2);
                Rect breastRect  = new Rect(pawnRectWidth + 24, 40f, breastRectWidth, breastRectHeight + fontheight);
                DrawVagina(genitalRect);
                DrawBreast(breastRect);
                cumlistTitle = new Rect(wombRectWidth + 4f, 0, 150f, fontheight);
                cumlistRect  = new Rect(wombRectWidth + 4f, fontheight, 150f, mainRect.yMax - fontheight + preginfoheight + 3);
            }
            else
            {
                cumlistTitle = new Rect(pawnRectWidth, 0, 150f, fontheight);
                cumlistRect  = new Rect(pawnRectWidth, fontheight, 150f, mainRect.yMax - wombRectHeight - fontheight);
            }

            Rect infoRect = new Rect(0, pawnRectHeight + 2 * fontheight, pawnRectWidth, pawnRect.yMax + 2 * fontheight - wombInfoRect.y);

            DrawInfos(infoRect);



            GUI.Label(cumlistTitle, Translations.Dialog_WombInfo04);
            DrawCumlist(cumlistRect);
        }
コード例 #11
0
        private void DrawOrderEntry(Order order, float currentScrollY)
        {
            Rect currentEntryRect = new Rect(0f, currentScrollY, this.orderEntrySize.x, this.orderEntrySize.y);

            Widgets.DrawMenuSection(currentEntryRect);
            Rect    texRect   = currentEntryRect.ContractedBy(2f);
            Rect    innerRect = currentEntryRect.ContractedBy(6f);
            Vector2 butSize   = new Vector2(30f, 30f);
            float   padding   = 2f;

            if ((selectedOrder != null && order == selectedOrder) && (currentEntryRect.Contains(Event.current.mousePosition)))
            {
                if (order.Config.Suspended)
                {
                    GUI.color = Widget.SuspendedItemSelectedHoverColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = Widget.SelectedItemHoverColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
            }
            else if (currentEntryRect.Contains(Event.current.mousePosition))
            {
                if (order.Config.Suspended)
                {
                    GUI.color = Widget.SuspendedItemHoverColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = Widget.ItemHoverColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
            }
            else if (selectedOrder != null && order == selectedOrder)
            {
                if (order.Config.Suspended)
                {
                    GUI.color = Widget.SuspendedItemSelectedColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = Widget.SelectedItemColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
            }
            else
            {
                if (order.Config.Suspended)
                {
                    GUI.color = Widget.SuspendedItemColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = Widget.ItemColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
            }

            try
            {
                GUI.BeginGroup(innerRect);

                float innerRectCentreY = (innerRect.yMax - innerRect.y) / 2;
                float innerRectCentreX = innerRect.width / 2;

                //Do the label
                Rect labelRect = new Rect(0f, 0f, innerRect.width / 3 - padding, innerRect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                Text.Font   = GameFont.Small;
                GUI.color   = Color.white;
                Widgets.Label(labelRect, order.Recipe.LabelCap);

                //Do the time remaining label
                Rect   timeRect = new Rect(innerRect.width / 3 + padding, 0f, innerRect.width / 3 - padding * 2, innerRect.height);
                string s;
                if (order.ShoppingList.HasAllMats)
                {
                    s = "TimeRemaining".Translate() + ": " + order.GetTimeRemaining;
                }
                else
                {
                    s = "AwaitingMaterials".Translate();
                }
                Widgets.Label(timeRect, s);

                //Do the count label
                Rect   countRect = new Rect((innerRect.width / 3) * 2 + padding, 0f, innerRect.width / 3 - butSize.x - padding * 2, innerRect.height);
                string count     = string.Empty;
                if (order.Config.RepeatMode == RimWorld.BillRepeatMode.Forever)
                {
                    count = "MD2Infinite".Translate();
                }
                if (order.Config.RepeatMode == RimWorld.BillRepeatMode.RepeatCount)
                {
                    count = order.Config.Cycles.ToString() + "x";
                }
                if (order.Config.RepeatMode == RimWorld.BillRepeatMode.TargetCount)
                {
                    count = "MD2Until".Translate() + " " + order.Config.TargetCount.ToString();
                }
                Widgets.Label(countRect, count);

                //Do the delete button
                Rect deleteButRect = new Rect(innerRect.width - butSize.x, 0f, butSize.x, butSize.y);
                if (Widgets.ImageButton(deleteButRect, ContentFinder <Texture2D> .Get("UI/Buttons/Delete", true)))
                {
                    order.Delete();
                    this.orders        = line.OrderStack.All.ToList();
                    this.selectedOrder = line.CurrentOrder;
                }
                TooltipHandler.TipRegion(deleteButRect, "MD2Delete".Translate());

                //Do the suspend button
                Rect suspendButrect = new Rect(innerRect.width - butSize.x, innerRect.height - butSize.y, butSize.x, butSize.y);
                if (Widgets.ImageButton(suspendButrect, Widget.Suspend))
                {
                    order.Config.Suspended = !order.Config.Suspended;
                }
                TooltipHandler.TipRegion(suspendButrect, "MD2Suspend".Translate());

                //Do the move up button
                Rect upButRect = new Rect(innerRectCentreX - butSize.x, 0f, butSize.x, butSize.y);
                if (order.CanMoveUp)
                {
                    if (Widgets.ImageButton(upButRect, Widget.ReorderUp))
                    {
                        line.OrderStack.Reorder(order, MoveDir.Up);
                        this.orders = line.OrderStack.All.ToList();
                    }
                }
                else
                {
                    GUI.color = Widget.InactiveButtonColor;
                    GUI.DrawTexture(upButRect, Widget.ReorderUp);
                    GUI.color = Color.white;
                }
                TooltipHandler.TipRegion(upButRect, "MoveUp".Translate());


                //Do the move down button
                Rect downButRect = new Rect(innerRectCentreX - butSize.x, innerRect.height - butSize.y, butSize.x, butSize.y);
                if (order.CanMoveDown)
                {
                    if (Widgets.ImageButton(downButRect, Widget.ReorderDown))
                    {
                        line.OrderStack.Reorder(order, MoveDir.Down);
                        this.orders = line.OrderStack.All.ToList();
                    }
                }
                else
                {
                    GUI.color = Widget.InactiveButtonColor;
                    GUI.DrawTexture(downButRect, Widget.ReorderDown);
                    GUI.color = Color.white;
                }
                TooltipHandler.TipRegion(downButRect, "MoveDown".Translate());


                //Do the invisible button which selects the order.This needs to go last
                Rect invisButRect = new Rect(0f, 0f, innerRect.width, innerRect.height);
                if (Widgets.InvisibleButton(invisButRect))
                {
                    this.selectedOrder = order;
                }
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
                GUI.color   = Color.white;
            }
        }
コード例 #12
0
        private static void ResolveErroredHairDefs()
        {
            var hairDefs = DefDatabase <HairDef> .AllDefsListForReading;

            for (int i = 0; i < hairDefs.Count; i++)
            {
                var hDef = hairDefs[i];
                if (ContentFinder <Texture2D> .Get(hDef.texPath + "_north", false) == null && ContentFinder <Texture2D> .Get(hDef.texPath + "_south", false) == null &&
                    ContentFinder <Texture2D> .Get(hDef.texPath + "_east", false) == null && ContentFinder <Texture2D> .Get(hDef.texPath + "_west", false) == null)
                {
                    badHairDefs.Add(hDef);
                }
            }
            if (badHairDefs.Any())
            {
                var errorStrings = new List <string>();
                badHairDefs.ForEach(h => errorStrings.Add($"{h.defName} (from {h.modContentPack?.Name ?? "unknown source"})"));
                Log.Error($"The following HairDefs have misconfigured texPaths or missing textures: {errorStrings.ToCommaList()}");
            }
        }
コード例 #13
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                if (!GizmoInhibitor(gizmo))
                {
                    yield return(gizmo);
                }
            }
            yield return(new Command_Toggle
            {
                icon = ContentFinder <Texture2D> .Get("UI/AutoVentIcon_" + ventComp.Props.signal, true),
                defaultLabel = "CommandAutoVentilation".Translate(),
                defaultDesc = "CommandAutoVentilationDesc".Translate(),
                isActive = () => autoVent,
                disabled = alarmReact && AlertManagerProxy.onAlert,
                disabledReason = "DisabledByEmergency".Translate(),
                toggleAction = delegate()
                {
                    autoVent = !autoVent;
                }
            });

            if (HarmonyPatcher.BetterPawnControl)
            {
                yield return(new Command_Toggle
                {
                    icon = ContentFinder <Texture2D> .Get("UI/Buttons/EmergencyOn", true),
                    iconDrawScale = 0.75f,
                    defaultLabel = "CommandCloseOnEmergency".Translate(),
                    defaultDesc = "CommandCloseOnEmergencyDesc".Translate() + mainComp.ManualNote,
                    isActive = () => alarmReact,
                    toggleAction = delegate()
                    {
                        alarmReact = !alarmReact;
                        if (AlertManagerProxy.onAlert)
                        {
                            mainComp.FlickFor(false);
                            ventComp.FlickFor(false);
                        }
                        if (!alarmReact && emergencyShut)
                        {
                            emergencyShut = false;
                        }
                    }
                });
            }
            if (Prefs.DevMode)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Diagnostics",
                    action = delegate()
                    {
                        Log.Warning(SelfDiagnotics());
                    }
                });

                yield return(new Command_Action
                {
                    defaultLabel = "Reset",
                    action = delegate()
                    {
                        SetScanLines();
                        CastLight();
                        needsUpdate = true;
                    }
                });
            }
        }
コード例 #14
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                bool flag = false;

                switch (num)
                {
                case 0u:
                    enumerator = base.< GetGizmos > __BaseCallProxy0().GetEnumerator();
                    num        = 4294967293u;
                    break;

                case 1u:
                    break;

                case 2u:
                    goto IL_15B;

                default:
                    return(false);
                }
                try
                {
                    switch (num)
                    {
                    }
                    if (enumerator.MoveNext())
                    {
                        baseGizmo     = enumerator.Current;
                        this.$current = baseGizmo;
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        flag = true;
                        return(true);
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        if (enumerator != null)
                        {
                            enumerator.Dispose();
                        }
                    }
                }
                if (DesignatorUtility.FindAllowedDesignator <Designator_ZoneAdd_Growing>() == null)
                {
                    goto IL_15B;
                }
                Command_Action makeGrowZone = new Command_Action();

                makeGrowZone.action      = new Action(base.MakeMatchingGrowZone);
                makeGrowZone.hotKey      = KeyBindingDefOf.Misc2;
                makeGrowZone.defaultDesc = "CommandSunLampMakeGrowingZoneDesc".Translate();
                makeGrowZone.icon        = ContentFinder <Texture2D> .Get("UI/Designators/ZoneCreate_Growing", true);

                makeGrowZone.defaultLabel = "CommandSunLampMakeGrowingZoneLabel".Translate();
                this.$current             = makeGrowZone;
                if (!this.$disposing)
                {
                    this.$PC = 2;
                }
                return(true);

IL_15B:
                this.$PC = -1;
                return(false);
            }
コード例 #15
0
        public override void        PostLoad()
        {
            base.PostLoad();

            if (enableButton)
            {
                if (
                    (string.IsNullOrEmpty(labelKey)) &&
                    (string.IsNullOrEmpty(label))
                    )
                {
                    CCL_Log.TraceMod(
                        this,
                        Verbosity.NonFatalErrors,
                        "Def must have a valid label or labelKey for translation"
                        );
                    label = defName;
                }
                if (string.IsNullOrEmpty(iconTexture))
                {
                    CCL_Log.TraceMod(
                        this,
                        Verbosity.FatalErrors,
                        "Def must have a valid icon texture if enableButton is true"
                        );
                }
            }

            if (
                (exposeValue) &&
                (string.IsNullOrEmpty(saveKey))
                )
            {
                CCL_Log.TraceMod(
                    this,
                    Verbosity.FatalErrors,
                    "Def must have a valid saveKey if exposeValue is true, must not be null"
                    );
            }

            if (!toggleClass.IsSubclassOf(typeof(ToggleSetting)))
            {
                CCL_Log.TraceMod(
                    this,
                    Verbosity.FatalErrors,
                    string.Format("{0} is not a valid toggle class, does not inherit from ToggleSetting", toggleClass.ToString())
                    );
            }
            else
            {
                toggleWorker = (ToggleSetting)Activator.CreateInstance(toggleClass);
                if (toggleWorker == null)
                {
                    CCL_Log.TraceMod(
                        this,
                        Verbosity.FatalErrors,
                        string.Format("Unable to create instance of {0}", toggleClass.ToString()),
                        "ToggleSettingDef");
                }
            }

            if (
                (enableButton) &&
                (!string.IsNullOrEmpty(iconTexture))
                )
            {
                LongEventHandler.ExecuteWhenFinished(() =>
                {
                    icon = ContentFinder <Texture2D> .Get(iconTexture);
                });
            }
        }
コード例 #16
0
            public static bool DrawCharacterCardP(ref Rect rect, ref Pawn pawn, ref Action randomizeCallback, ref Rect creationRect)
            {
                rect.position = new Vector2(17f, 17f);
                rect.size     = new Vector2(cardX, cardY);
                bool flag = randomizeCallback != null;

                GUI.BeginGroup((!flag) ? rect : creationRect);
                Rect       rectLabel  = new Rect(0f, 0f, 300f, 30f);
                NameTriple nameTriple = pawn.Name as NameTriple;

                if (flag && nameTriple != null)
                {
                    Rect rect3 = new Rect(rectLabel);
                    rect3.width *= 0.333f;
                    Rect rect4 = new Rect(rectLabel);
                    rect4.width *= 0.333f;
                    rect4.x     += rect4.width;
                    Rect rect5 = new Rect(rectLabel);
                    rect5.width *= 0.333f;
                    rect5.x     += rect4.width * 2f;
                    string first = nameTriple.First;
                    string nick  = nameTriple.Nick;
                    string last  = nameTriple.Last;
                    CharacterCardUtility.DoNameInputRect(rect3, ref first, 12);
                    if (nameTriple.Nick == nameTriple.First || nameTriple.Nick == nameTriple.Last)
                    {
                        GUI.color = new Color(1f, 1f, 1f, 0.5f);
                    }
                    CharacterCardUtility.DoNameInputRect(rect4, ref nick, 9);
                    GUI.color = Color.white;
                    CharacterCardUtility.DoNameInputRect(rect5, ref last, 12);
                    if (nameTriple.First != first || nameTriple.Nick != nick || nameTriple.Last != last)
                    {
                        pawn.Name = new NameTriple(first, nick, last);
                    }
                    TooltipHandler.TipRegion(rect3, "FirstNameDesc".Translate());
                    TooltipHandler.TipRegion(rect4, "ShortIdentifierDesc".Translate());
                    TooltipHandler.TipRegion(rect5, "LastNameDesc".Translate());
                }
                else
                {
                    rectLabel.width = 999f;
                    Text.Font       = GameFont.Medium;
                    Widgets.Label(rectLabel, pawn.Name.ToStringFull);
                    Text.Font = GameFont.Small;
                }
                if (randomizeCallback != null)
                {
                    Rect rectRandomise = new Rect(creationRect.width - 24f - 100f, 0f, 100f, rectLabel.height);
                    if (Widgets.ButtonText(rectRandomise, "Randomize".Translate(), true, false, true))
                    {
                        SoundDefOf.TickTiny.PlayOneShotOnCamera(null);
                        randomizeCallback();
                    }
                    UIHighlighter.HighlightOpportunity(rectRandomise, "RandomizePawn");
                }
                if (flag)
                {
                    Widgets.InfoCardButton(creationRect.width - 24f, 0f, pawn);
                }
                else if (!pawn.health.Dead)
                {
                    float num = CharacterCardUtility.PawnCardSize.x - 85f;
                    if ((pawn.Faction == Faction.OfPlayer || pawn.IsPrisonerOfColony) && pawn.Spawned)
                    {
                        Rect rectBanish = new Rect(num, 0f, 30f, 30f);
                        TooltipHandler.TipRegion(rectBanish, PawnBanishUtility.GetBanishButtonTip(pawn));
                        if (Widgets.ButtonImage(rectBanish, ContentFinder <Texture2D> .Get("UI/Buttons/Banish", true)))
                        {
                            if (pawn.Downed)
                            {
                                Messages.Message("MessageCantBanishDownedPawn".Translate(new object[]
                                {
                                    pawn.LabelShort
                                }).AdjustedFor(pawn), pawn, MessageTypeDefOf.RejectInput);
                            }
                            else
                            {
                                PawnBanishUtility.ShowBanishPawnConfirmationDialog(pawn);
                            }
                        }
                        num -= 40f;
                    }
                    if (pawn.IsColonist)
                    {
                        Rect rect8 = new Rect(num, 0f, 30f, 30f);
                        TooltipHandler.TipRegion(rect8, "RenameColonist".Translate());
                        if (Widgets.ButtonImage(rect8, ContentFinder <Texture2D> .Get("UI/Buttons/Rename", true)))
                        {
                            Find.WindowStack.Add(new Dialog_ChangeNameTriple(pawn));
                        }
                        num -= 40f;
                    }
                }
                string label        = pawn.MainDesc(true);
                Rect   rectMainDesc = new Rect(0f, 45f, rect.width, 60f);

                Widgets.Label(rectMainDesc, label);
                Pawn p = pawn;

                TooltipHandler.TipRegion(rectMainDesc, () => p.ageTracker.AgeTooltipString, 6873641);
                Rect positionLeftHalf  = new Rect(0f, 100f, 250f, cardY);
                Rect positionRightHalf = new Rect(positionLeftHalf.xMax, 100f, 258f, cardY);

                GUI.BeginGroup(positionLeftHalf);
                float currentY = 0f;

                Text.Font = GameFont.Medium;
                Widgets.Label(new Rect(0f, 0f, 200f, 30f), "Backstory".Translate());
                currentY += 30f;
                Text.Font = GameFont.Small;
                foreach (BackstorySlot backstorySlot in Enum.GetValues(typeof(BackstorySlot)))
                {
                    Backstory backstory = pawn.story.GetBackstory(backstorySlot);
                    if (backstory != null)
                    {
                        Rect rect10 = new Rect(0f, currentY, positionLeftHalf.width, 24f);
                        if (Mouse.IsOver(rect10))
                        {
                            Widgets.DrawHighlight(rect10);
                        }
                        TooltipHandler.TipRegion(rect10, backstory.FullDescriptionFor(pawn));
                        Text.Anchor = TextAnchor.MiddleLeft;
                        string str = (backstorySlot != BackstorySlot.Adulthood) ? "Childhood".Translate() : "Adulthood".Translate();
                        Widgets.Label(rect10, str + ":");
                        Text.Anchor = TextAnchor.UpperLeft;
                        Rect rect11 = new Rect(rect10);
                        rect11.x     += 90f;
                        rect11.width -= 90f;
                        string title = backstory.Title;
                        Widgets.Label(rect11, title);
                        currentY += rect10.height + 2f;
                    }
                }
                currentY += 25f;
                Text.Font = GameFont.Small;
                Widgets.Label(new Rect(0f, currentY, 200f, 30f), "IncapableOf".Translate());
                currentY += 30f;
                Text.Font = GameFont.Small;
                StringBuilder stringBuilder            = new StringBuilder();
                WorkTags      combinedDisabledWorkTags = pawn.story.CombinedDisabledWorkTags;

                if (combinedDisabledWorkTags == WorkTags.None)
                {
                    stringBuilder.Append("(" + "NoneLower".Translate() + "), ");
                }
                else
                {
                    List <WorkTags> list  = WorkTagsFrom(combinedDisabledWorkTags).ToList <WorkTags>();
                    bool            flag2 = true;
                    foreach (WorkTags current in list)
                    {
                        if (flag2)
                        {
                            stringBuilder.Append(current.LabelTranslated().CapitalizeFirst());
                        }
                        else
                        {
                            stringBuilder.Append(current.LabelTranslated());
                        }
                        stringBuilder.Append(", ");
                        flag2 = false;
                    }
                }
                string text = stringBuilder.ToString();

                text = text.Substring(0, text.Length - 2);
                Rect rect12 = new Rect(0f, currentY, positionLeftHalf.width, 999f);

                Widgets.Label(rect12, text);
                currentY += 100f;
                Text.Font = GameFont.Medium;
                Widgets.Label(new Rect(0f, currentY, 200f, 30f), "Traits".Translate());
                currentY += 30f;
                Text.Font = GameFont.Small;
                for (int i = 0; i < pawn.story.traits.allTraits.Count; i++)
                {
                    Trait trait            = pawn.story.traits.allTraits[i];
                    Rect  rectCurrentTrait = new Rect(0f, currentY, positionLeftHalf.width, 24f);
                    if (Mouse.IsOver(rectCurrentTrait))
                    {
                        Widgets.DrawHighlight(rectCurrentTrait);
                    }
                    Widgets.Label(rectCurrentTrait, trait.LabelCap);
                    currentY += rectCurrentTrait.height + 2f;
                    Trait     trLocal = trait;
                    TipSignal tip     = new TipSignal(() => trLocal.TipString(p), (int)currentY * 37);
                    TooltipHandler.TipRegion(rectCurrentTrait, tip);
                }
                GUI.EndGroup();
                GUI.BeginGroup(positionRightHalf);
                Text.Font = GameFont.Medium;
                Widgets.Label(new Rect(0f, 0f, 200f, 30f), "Skills".Translate());
                SkillUI.SkillDrawMode mode;
                if (Current.ProgramState == ProgramState.Playing)
                {
                    mode = SkillUI.SkillDrawMode.Gameplay;
                }
                else
                {
                    mode = SkillUI.SkillDrawMode.Menu;
                }
                SkillUI.DrawSkillsOf(pawn, new Vector2(0f, 35f), mode);
                GUI.EndGroup();
                GUI.EndGroup();

                return(false);
            }
コード例 #17
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            foreach (Gizmo gizmo in base.CompGetGizmosExtra())
            {
                yield return(gizmo);
            }
            float offset2 = this.RoundedToCurrentTempModeOffset(-10f);

            yield return(new Command_Action
            {
                action = delegate()
                {
                    this.InterfaceChangeTargetTemperature(offset2);
                },
                defaultLabel = offset2.ToStringTemperatureOffset("F0"),
                defaultDesc = "CommandLowerTempDesc".Translate(),
                hotKey = KeyBindingDefOf.Misc5,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempLower", true)
            });

            float offset3 = this.RoundedToCurrentTempModeOffset(-1f);

            yield return(new Command_Action
            {
                action = delegate()
                {
                    this.InterfaceChangeTargetTemperature(offset3);
                },
                defaultLabel = offset3.ToStringTemperatureOffset("F0"),
                defaultDesc = "CommandLowerTempDesc".Translate(),
                hotKey = KeyBindingDefOf.Misc4,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempLower", true)
            });

            yield return(new Command_Action
            {
                action = delegate()
                {
                    this.targetTemperature = DefaultTargetTemperature;
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                    this.ThrowCurrentTemperatureText();
                },
                defaultLabel = "CommandResetTemp".Translate(),
                defaultDesc = "CommandResetTempDesc".Translate(),
                hotKey = KeyBindingDefOf.Misc1,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempReset", true)
            });

            float offset4 = this.RoundedToCurrentTempModeOffset(1f);

            yield return(new Command_Action
            {
                action = delegate()
                {
                    this.InterfaceChangeTargetTemperature(offset4);
                },
                defaultLabel = "+" + offset4.ToStringTemperatureOffset("F0"),
                defaultDesc = "CommandRaiseTempDesc".Translate(),
                hotKey = KeyBindingDefOf.Misc2,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempRaise", true)
            });

            float offset = this.RoundedToCurrentTempModeOffset(10f);

            yield return(new Command_Action
            {
                action = delegate()
                {
                    this.InterfaceChangeTargetTemperature(offset);
                },
                defaultLabel = "+" + offset.ToStringTemperatureOffset("F0"),
                defaultDesc = "CommandRaiseTempDesc".Translate(),
                hotKey = KeyBindingDefOf.Misc3,
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TempRaise", true)
            });

            yield break;
        }
コード例 #18
0
        public override void Init(GraphicRequest req)
        {
            this.data     = req.graphicData;
            this.path     = req.path;
            this.color    = req.color;
            this.colorTwo = req.colorTwo;
            this.drawSize = req.drawSize;
            Texture2D[] array = new Texture2D[4];

            string eyeType = null;
            string side    = null;
            string gender  = null;

            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(req.path);

            // ReSharper disable once PossibleNullReferenceException
            string[] arrayString = fileNameWithoutExtension.Split('_');
            try
            {
                eyeType = arrayString[1];
                gender  = arrayString[2];
                side    = arrayString[3];
            }
            catch (Exception ex)
            {
                Log.Error("Parse error with head graphic at " + req.path + ": " + ex.Message);
            }

            if (ContentFinder <Texture2D> .Get(req.path + "_front"))
            {
                array[2] = ContentFinder <Texture2D> .Get(req.path + "_front");
            }
            else
            {
                Log.Message(
                    "Facial Stuff: Failed to get front texture at " + req.path + "_front"
                    + " - Graphic_Multi_NaturalEyes");
                return;

                // array[2] = MaskTextures.BlankTexture();
            }

            string sidePath = Path.GetDirectoryName(req.path) + "/Eye_" + eyeType + "_" + gender + "_side";

            // 1 texture= 1 eye, blank for the opposite side
            if (ContentFinder <Texture2D> .Get(sidePath))
            {
                // ReSharper disable once PossibleNullReferenceException
                if (side.Equals("Right"))
                {
                    array[3] = FaceTextures.BlankTexture;
                }
                else
                {
                    array[3] = ContentFinder <Texture2D> .Get(sidePath);
                }

                if (side.Equals("Left"))
                {
                    array[1] = FaceTextures.BlankTexture;
                }
                else
                {
                    array[1] = ContentFinder <Texture2D> .Get(sidePath);
                }
            }
            else
            {
                Log.Message("Facial Stuff: No texture found at " + sidePath + " - Graphic_Multi_NaturalEyes");
                array[3] = FaceTextures.BlankTexture;
            }

            if (ContentFinder <Texture2D> .Get(req.path + "_back", false))
            {
                array[0] = ContentFinder <Texture2D> .Get(req.path + "_back");
            }
            else
            {
                array[0] = FaceTextures.BlankTexture;
            }

            Texture2D[] array2 = new Texture2D[4];
            if (req.shader.SupportsMaskTex())
            {
                array2[0] = FaceTextures.RedTexture;
                array2[2] = ContentFinder <Texture2D> .Get(req.path + "_frontm", false);

                if (array2[2] == null)
                {
                    array2[2] = FaceTextures.RedTexture;
                }

                string sidePath2 = Path.GetDirectoryName(req.path) + "/Eye_" + eyeType + "_" + gender + "_sidem";

                // 1 texture= 1 eye, blank for the opposite side

                if (side != null && side.Equals("Right"))
                {
                    array2[3] = FaceTextures.RedTexture;
                }
                else
                {
                    array2[3] = ContentFinder <Texture2D> .Get(sidePath2, false);
                }

                if (side != null && side.Equals("Left"))
                {
                    array2[1] = FaceTextures.RedTexture;
                }
                else
                {
                    array2[1] = ContentFinder <Texture2D> .Get(sidePath2, false);
                }
                if (array2[1] == null)
                {
                    array2[1] = FaceTextures.RedTexture;
                }
                if (array2[3] == null)
                {
                    array2[3] = FaceTextures.RedTexture;
                }
            }

            for (int i = 0; i < 4; i++)
            {
                MaterialRequest req2 = default;
                req2.mainTex  = array[i];
                req2.shader   = req.shader;
                req2.color    = this.color;
                req2.colorTwo = this.colorTwo;

                req2.maskTex = array2[i];

                // req2.mainTex.filterMode = FilterMode.Trilinear;
                this._mats[i] = MaterialPool.MatFrom(req2);
            }
        }
コード例 #19
0
 public static Material MatFrom(string texPath, Shader shader, PatternProperties properties)
 {
     return(MatFrom(new MaterialRequestRGB(ContentFinder <Texture2D> .Get(texPath, true), shader, properties)));
 }
コード例 #20
0
        // Note to whoever wants to add to this method (hi jptrrs!):
        // You can just do
        // foreach (Gizmo c in base.GetGizmos())
        // {
        //    yield return c;
        // }
        // yield return [whatever you want to add];
        //
        // No need to copy this method.
        public override IEnumerable <Gizmo> GetGizmos()
        {
            // Display the original gizmos (includes the swap guest bed button via patch)
            foreach (var gizmo in base.GetGizmos())
            {
                switch (gizmo)
                {
                case Command_Toggle toggle: {
                    // Disable prisoner and medical buttons
                    if (toggle.defaultLabel == "CommandBedSetForPrisonersLabel".Translate() || toggle.defaultLabel == "CommandBedSetAsMedicalLabel".Translate())
                    {
                        gizmo.Disable();
                    }
                    break;
                }

                case Command_Action action: {
                    // Disable set owner button
                    if (action.defaultLabel == "CommandThingSetOwnerLabel".Translate())
                    {
                        action.Disable();
                    }
                    break;
                }
                }
                yield return(gizmo);
            }

            // Gizmo for drawing guest room info
            if (Find.Selector.SingleSelectedObject == this)
            {
                if (Stats.lastCalculated == 0 || Stats.room == null)
                {
                    UpdateStats();
                }
                yield return(new Gizmo_GuestBedStats(this));
            }

            // Add buttons to decrease / increase the fee
            yield return(new Command_Action
            {
                defaultLabel = "CommandBedDecreaseFeeLabel".Translate(feeStep),
                defaultDesc = "CommandBedDecreaseFeeDesc".Translate(feeStep, MoodEffect),
                icon = ContentFinder <Texture2D> .Get("UI/Commands/ChangePriceDown"),
                action = () => AdjustFee(-feeStep),
                hotKey = KeyBindingDefOf.Misc5,
                disabled = rentalFee < feeStep
            });

            yield return(new Command_Action
            {
                defaultLabel = "CommandBedIncreaseFeeLabel".Translate(feeStep),
                defaultDesc = "CommandBedIncreaseFeeDesc".Translate(feeStep, MoodEffect),
                icon = ContentFinder <Texture2D> .Get("UI/Commands/ChangePriceUp"),
                action = () => AdjustFee(feeStep),
                hotKey = KeyBindingDefOf.Misc6
            });

            // Get base def
            var defName = def.defName.ReplaceFirst("Guest", string.Empty);
            var baseDef = DefDatabase <ThingDef> .GetNamed(defName);

            // Add build copy command
            Command buildCopy = BuildCopyCommandUtility.BuildCopyCommand(baseDef, Stuff);

            if (buildCopy != null)
            {
                yield return(buildCopy);
            }
        }
コード例 #21
0
ファイル: Resources.cs プロジェクト: fluffy-mods/BackupPower
        static Resources()
        {
            Battery = ContentFinder <Texture2D> .Get("UI/Battery");

            BackupPowerAttachment = ContentFinder <Texture2D> .Get("BackupPowerAttachment");
        }
コード例 #22
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            var gizmoList = base.GetGizmos().ToList();

            if (ResearchProjectDef.Named("TM_ForgeReplication").IsFinished)
            {
                bool canScan = true;
                for (int i = 0; i < this.BillStack.Count; i++)
                {
                    if (this.BillStack[i].recipe.defName == "ArcaneForge_Replication")
                    {
                        canScan = false;
                    }
                }
                if (canScan)
                {
                    TargetingParameters newParameters = new TargetingParameters();
                    newParameters.canTargetItems     = true;
                    newParameters.canTargetBuildings = true;
                    newParameters.canTargetLocations = true;


                    String label = "TM_Replicate".Translate();
                    String desc  = "TM_ReplicateDesc".Translate();

                    Command_LocalTargetInfo item = new Command_LocalTargetInfo
                    {
                        defaultLabel    = label,
                        defaultDesc     = desc,
                        order           = 67,
                        icon            = ContentFinder <Texture2D> .Get("UI/replicate", true),
                        targetingParams = newParameters
                    };
                    item.action = delegate(LocalTargetInfo thing)
                    {
                        this.infoTarget = thing;
                        IntVec3 localCell = thing.Cell;
                        this.targetThing = thing.Cell.GetFirstItem(this.Map);
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Scan"), localCell.ToVector3ShiftedWithAltitude(AltitudeLayer.Weather), this.Map, 1.2f, .8f, 0f, .5f, -400, 0, 0, Rand.Range(0, 360));
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Scan"), localCell.ToVector3ShiftedWithAltitude(AltitudeLayer.Weather), this.Map, 1.2f, .8f, 0f, .5f, 400, 0, 0, Rand.Range(0, 360));
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Scan"), this.DrawPos, this.Map, 1.2f, .8f, 0f, .5f, 400, 0, 0, Rand.Range(0, 360));
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Scan"), this.DrawPos, this.Map, 1.2f, .8f, 0f, .5f, -400, 0, 0, Rand.Range(0, 360));
                        SoundInfo info = SoundInfo.InMap(new TargetInfo(thing.Cell, this.Map, false), MaintenanceType.None);
                        info.pitchFactor  = 1.3f;
                        info.volumeFactor = 1.3f;
                        SoundDefOf.TurretAcquireTarget.PlayOneShot(info);
                        if (targetThing != null && targetThing.def.EverHaulable)
                        {
                            ClearReplication();
                            Replicate();
                        }
                        else
                        {
                            Messages.Message("TM_FoundNoReplicateTarget".Translate(), MessageTypeDefOf.CautionInput);
                        }
                    };
                    gizmoList.Add(item);
                }
                else
                {
                    String label = "TM_ReplicateDisabled".Translate();
                    String desc  = "TM_ReplicateDisabledDesc".Translate();

                    Command_Action item2 = new Command_Action
                    {
                        defaultLabel = label,
                        defaultDesc  = desc,
                        order        = 68,
                        icon         = ContentFinder <Texture2D> .Get("UI/replicateDisabled", true),
                        action       = delegate
                        {
                            ClearReplication();
                        }
                    };
                    gizmoList.Add(item2);
                }
            }

            return(gizmoList);
        }
コード例 #23
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo g in base.GetGizmos())
            {
                yield return(g);
            }
            yield return(new Command_Toggle()
            {
                defaultLabel = "PRFDroneStationLockdown".Translate(),
                defaultDesc = "PRFDroneStationLockdownDesc".Translate(),
                toggleAction = () =>
                {
                    lockdown = !lockdown;
                    if (lockdown)
                    {
                        foreach (Pawn_Drone drone in spawnedDrones.ToList())
                        {
                            drone.jobs.StartJob(new Job(PRFDefOf.PRFDrone_ReturnToStation, this), JobCondition.InterruptForced);
                        }
                    }
                },
                isActive = () => lockdown,
                icon = Cancel
            });

            yield return(new Command_Action()
            {
                defaultLabel = "PRFDroneStationLockdownAll".Translate(),
                defaultDesc = "PRFDroneStationLockdownAllDesc".Translate(),
                action = () =>
                {
                    List <Building_DroneStation> buildings = Map.listerThings.AllThings.OfType <Building_DroneStation>().ToList();
                    for (int i = 0; i < buildings.Count; i++)
                    {
                        buildings[i].lockdown = true;
                        foreach (Pawn_Drone drone in buildings[i].spawnedDrones.ToList())
                        {
                            drone.jobs.StartJob(new Job(PRFDefOf.PRFDrone_ReturnToStation, buildings[i]), JobCondition.InterruptForced);
                        }
                    }
                },
                icon = ContentFinder <Texture2D> .Get("PRFUi/deactivate", true)
            });

            yield return(new Command_Action()
            {
                defaultLabel = "PRFDroneStationLiftLockdownAll".Translate(),
                defaultDesc = "PRFDroneStationLiftLockdownAllDesc".Translate(),
                action = () =>
                {
                    List <Building_DroneStation> buildings = Map.listerThings.AllThings.OfType <Building_DroneStation>().ToList();
                    for (int i = 0; i < buildings.Count; i++)
                    {
                        buildings[i].lockdown = false;
                    }
                },
                icon = ContentFinder <Texture2D> .Get("PRFUi/activate", true)
            });

            if (DroneRange == 0)
            {
                /*
                 * "Verse.Designator"
                 * Holds example of how i want this Gizmo Implemented
                 */
                yield return(new DroneAreaSelector()
                {
                    icon = ContentFinder <Texture2D> .Get("UI/Designators/AreaAllowedExpand"),
                    defaultLabel = droneAreaSelectorLable,
                    selectAction = (a) =>
                    {
                        Update_droneAllowedArea_forDrones(a);
                        update_droneAreaSelectorLable(a);
                    }
                });
            }
            if (Prefs.DevMode)
            {
                yield return(new Command_Action()
                {
                    defaultLabel = "DEV: Respawn drones",
                    defaultDesc = "Respawns all Drones",
                    action = () =>
                    {
                        for (int i = spawnedDrones.Count - 1; i >= 0; i--)
                        {
                            spawnedDrones[i].Destroy();
                            Notify_DroneGained();
                        }
                    },
                });
            }
        }
コード例 #24
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())
            {
                yield return(c);
            }
            if (this.CanExtractShell)
            {
                CompChangeableProjectile changeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();
                yield return(new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = changeableProjectile.LoadedShell.uiIcon,
                    iconAngle = changeableProjectile.LoadedShell.uiIconAngle,
                    iconOffset = changeableProjectile.LoadedShell.uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(changeableProjectile.LoadedShell),
                    alsoClickIfOtherInGroupClicked = false,
                    action = delegate
                    {
                        GenPlace.TryPlaceThing(changeableProjectile.RemoveShell(), this.$this.Position, this.$this.Map, ThingPlaceMode.Near, null, null);
                    }
                });
            }
            if (this.CanSetForcedTarget)
            {
                Command_VerbTarget attack = new Command_VerbTarget();
                attack.defaultLabel = "CommandSetForceAttackTarget".Translate();
                attack.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                attack.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true);

                attack.verb   = this.AttackVerb;
                attack.hotKey = KeyBindingDefOf.Misc4;
                if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    attack.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return(attack);
            }
            if (this.forcedTarget.IsValid)
            {
                Command_Action stop = new Command_Action();
                stop.defaultLabel = "CommandStopForceAttack".Translate();
                stop.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                stop.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true);

                stop.action = delegate
                {
                    this.$this.ResetForcedTarget();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                };
                if (!this.forcedTarget.IsValid)
                {
                    stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                stop.hotKey = KeyBindingDefOf.Misc5;
                yield return(stop);
            }
            if (this.CanToggleHoldFire)
            {
                yield return(new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate
                    {
                        this.$this.holdFire = !this.$this.holdFire;
                        if (this.$this.holdFire)
                        {
                            this.$this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => this.$this.holdFire)
                });
            }
        }
コード例 #25
0
        private static Gizmo GetSquadTeleGizmo(Pawn pawn)
        {
            // Log.Warning("YES");
            var command_Target = new Command_TargetPlus {
                defaultLabel = "ChronoTeleport".Translate()
            };


            var tp = new TargetingParameters
            {
                canTargetBuildings = false,
                canTargetFires     = false,
                canTargetLocations = true,
                canTargetPawns     = false,
                canTargetSelf      = false
            };

            command_Target.disabled        = pawn.stances.stunner.Stunned || !pawn.drafter.Drafted;
            command_Target.targetingParams = tp;
            command_Target.hotKey          = KeyBindingDefOf.Misc4;
            command_Target.icon            = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport");

            command_Target.aimIcon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport");

            command_Target.action = delegate(LocalTargetInfo target)
            {
                var enumerable = Find.Selector.SelectedObjects.Where(x =>
                                                                     x is Pawn {
                    IsColonistPlayerControlled: true, Drafted: true
                }).Cast <Pawn>();

                var tmpPawns  = enumerable.ToList();
                var tmpPawns2 = new List <Pawn>();
                foreach (var pawn2 in tmpPawns)
                {
                    {
                        var casterPawn = pawn2;
                        var map        = pawn2.Map;

                        var thi = map.thingGrid.ThingsAt(target.Cell);
                        foreach (var th in thi)
                        {
                            if (th is not Building)
                            {
                                continue;
                            }

                            Messages.Message("ChronoNotToBuild".Translate(), MessageTypeDefOf.RejectInput);
                            return;
                        }

                        FleckMaker.ThrowExplosionCell(target.Cell, map, FleckDefOf.ExplosionFlash, new Color(1, 1, 1));
                        // MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1,1,1));
                        // for (int asd = 0; asd < 60; asd++)
                        FleckMaker.ThrowExplosionCell(casterPawn.Position, map, FleckDefOf.ExplosionFlash,
                                                      new Color(1f, 1, 1));
                        var dist = Math.Sqrt(Math.Pow(casterPawn.Position.x - target.Cell.x, 2) +
                                             Math.Pow(casterPawn.Position.z - target.Cell.z, 2));
                        if (dist < 20)
                        {
                            dist = 20;
                        }


                        pawn2.DeSpawn();
                        GenSpawn.Spawn(casterPawn, target.Cell, map);

                        casterPawn.drafter.Drafted = true;
                        tmpPawns2.Add(casterPawn);

                        DefDatabase <SoundDef> .GetNamed("ra2_Chrono_move").PlayOneShot(casterPawn);

                        DefDatabase <SoundDef> .GetNamed("ra2_Chrono_movesay").PlayOneShotOnCamera();

                        var dinfo = new DamageInfo(DamageDefOf.Stun, (int)(dist * 0.1), -1, 1, null, null,
                                                   casterPawn.equipment.Primary.def, DamageInfo.SourceCategory.ThingOrUnknown, casterPawn);
                        casterPawn.TakeDamage(dinfo);
                    }
                }

                foreach (var pps in tmpPawns2)
                {
                    Find.Selector.SelectedObjects.Add(pps);
                }
            };
コード例 #26
0
        public override void DoSettingsWindowContents(Rect inRect)
        {
            var leftRect  = new Rect(inRect.x, inRect.y, inRect.width * 0.65f, inRect.height);
            var rightRect = new Rect((int)(inRect.x + inRect.width * 0.65f + 30f), inRect.y, inRect.width * 0.35f - 30f,
                                     inRect.height);

            var listing_options = new Listing_Standard();

            listing_options.Begin(leftRect);

            listing_options.CheckboxLabeled("PrisonLabor_ShowNews".Translate(), ref showNews,
                                            "PrisonLabor_ShowNewsDesc".Translate());

            listing_options.GapLine();

            if (listing_options.ButtonTextLabeled("PrisonLabor_DefaultInterMode".Translate(), interactionModeList[defaultInteractionMode].LabelCap))
            {
                defaultInteractionMode = defaultInteractionMode < interactionModeList.Count - 1 ? defaultInteractionMode + 1 : 0;
            }

            listing_options.GapLine();

            listing_options.Label("PrisonLabor_AllowedWorkTypes".Translate(), -1f);
            listing_options.CheckboxLabeled("   " + "PrisonLabor_AllowAll".Translate(), ref allowAllWorktypes, "PrisonLabor_AllowAllWorkTypes".Translate());
            if (!allowAllWorktypes)
            {
                if (listing_options.ButtonTextLabeled("   " + "PrisonLabor_AllowedWorkTypesL".Translate(), "PrisonLabor_Browse".Translate()))
                {
                    Find.WindowStack.Add(new SelectWorkTypesDialog());
                }
            }
            else
            {
                listing_options.Gap();
            }

            listing_options.GapLine();

            listing_options.CheckboxLabeled("PrisonLabor_MotivationMechanics".Translate(), ref enableMotivationMechanics,
                                            "PrisonLabor_MotivationWarning".Translate());

            listing_options.GapLine();

            listing_options.CheckboxLabeled("PrisonLabor_MotivationIcons".Translate(), ref enableMotivationIcons,
                                            "PrisonLabor_MotivationIconsDesc".Translate());

            listing_options.GapLine();

            listing_options.CheckboxLabeled("PrisonLabor_CanGrowAdvanced".Translate(), ref advancedGrowing,
                                            "PrisonLabor_CanGrowAdvancedDesc".Translate());

            listing_options.GapLine();

            listing_options.CheckboxLabeled("PrisonLabor_EnableRevolts".Translate(), ref enableRevolts,
                                            "PrisonLabor_EnableRevoltsDesc".Translate());

            listing_options.GapLine();

            listing_options.CheckboxLabeled("PrisonLabor_EnableSuicide".Translate(), ref enableSuicide,
                                            "PrisonLabor_EnableSuicideDesc".Translate());

            listing_options.GapLine();

            listing_options.CheckboxLabeled("PrisonLabor_ShowTreatmentHappiness".Translate(), ref showTreatmentHappiness,
                                            "PrisonLabor_ShowTreatmentHappinessDesc".Translate());

            listing_options.Gap();
            listing_options.Gap();
            listing_options.Gap();

            if (listing_options.ButtonTextLabeled("PrisonLabor_ButtonRemoveModFromSaveDesc".Translate(), "PrisonLabor_ButtonRemoveModFromSave".Translate()))
            {
                Find.WindowStack.Add(new SelectSaveForCleaningDialog());
            }

            listing_options.End();

            var listing_panel = new Listing_Standard();

            listing_panel.Begin(rightRect);

            var heigh_temp = rightRect.width * 0.56f;

            GUI.DrawTexture(new Rect(0, 0, rightRect.width, heigh_temp), ContentFinder <Texture2D> .Get("Preview", true));
            listing_panel.Gap(heigh_temp);
            listing_panel.Label("Prison Labor", -1f);
            listing_panel.Label("PrisonLabor_Version".Translate() + VersionUtility.versionString, -1f);

            listing_panel.GapLine();

            listing_panel.Label("PrisonLabor_Difficulty".Translate() + difficulty, -1f);

            listing_panel.GapLine();

            if (listing_panel.ButtonText("PrisonLabor_Defaults".Translate()))
            {
                PrisonLaborPrefs.RestoreToDefault();
                Init();
            }

            if (listing_panel.ButtonText("PrisonLabor_ShowNews".Translate()))
            {
                NewsWindow.ShowAll = true;
                NewsWindow.ForceShow();
            }

            if (listing_panel.ButtonText("PrisonLabor_ReplayTurorialsButton".Translate()))
            {
                ReplayTutorialsWindow.Show();
            }

            listing_panel.End();

            Apply();
        }
コード例 #27
0
ファイル: JukeBox.cs プロジェクト: solaris0115/JukeBox
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            foreach (Gizmo c in base.CompGetGizmosExtra())
            {
                yield return(c);
            }
            if (compPowerTrader.PowerOn)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "nextSong".Translate(),
                    defaultDesc = "nextSongDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/Next", true),
                    action = delegate()
                    {
                        try
                        {
                            NextSong();
                        }
                        catch (Exception ee)
                        {
                            Log.Error("NextSong " + ee);
                        }
                    }
                });

                if (!currentState)
                {
                    yield return(new Command_Action
                    {
                        defaultLabel = "playSong".Translate(),
                        defaultDesc = "playSongDesc".Translate(),
                        icon = ContentFinder <Texture2D> .Get("UI/Commands/Play", true),
                        action = delegate()
                        {
                            try
                            {
                                PlaySong();
                            }
                            catch (Exception ee)
                            {
                                Log.Error("PlaySong " + ee);
                            }
                        }
                    });
                }
                else
                {
                    yield return(new Command_Action
                    {
                        defaultLabel = "stopSong".Translate(),
                        defaultDesc = "stopSongDesc".Translate(),
                        icon = ContentFinder <Texture2D> .Get("UI/Commands/Stop", true),
                        action = delegate()
                        {
                            try
                            {
                                StopSong();
                            }
                            catch (Exception ee)
                            {
                                Log.Error("StopSong " + ee);
                            }
                        }
                    });
                }

                /*yield return new Command_Action
                 * {
                 *  defaultLabel = "synchronize".Translate(),
                 *  defaultDesc = "synchronizeDesc".Translate(),
                 *  icon = ContentFinder<Texture2D>.Get("UI/Commands/Sync", true),
                 *  action = delegate ()
                 *  {
                 *      Synchronize();
                 *  }
                 * };*/
            }
            yield break;
        }
コード例 #28
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
            // Don't show gizmos on enemy turrets
            if (Faction == Faction.OfPlayer || MannedByColonist)
            {
                // Ammo gizmos
                if (CompAmmo != null)
                {
                    foreach (Command com in CompAmmo.CompGetGizmosExtra())
                    {
                        yield return(com);
                    }
                }
                // Fire mode gizmos
                if (CompFireModes != null)
                {
                    foreach (Command com in CompFireModes.GenerateGizmos())
                    {
                        yield return(com);
                    }
                }
                // Set forced target gizmo
                if (CanSetForcedTarget)
                {
                    yield return(new Command_VerbTarget
                    {
                        defaultLabel = "CommandSetForceAttackTarget".Translate(),
                        defaultDesc = "CommandSetForceAttackTargetDesc".Translate(),
                        icon = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true),
                        verb = GunCompEq.PrimaryVerb,
                        hotKey = KeyBindingDefOf.Misc4
                    });
                }
                // Stop forced attack gizmo
                if (forcedTarget.IsValid)
                {
                    Command_Action stop = new Command_Action();
                    stop.defaultLabel = "CommandStopForceAttack".Translate();
                    stop.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                    stop.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true);

                    stop.action = delegate
                    {
                        ResetForcedTarget();
                        SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                    };
                    if (!this.forcedTarget.IsValid)
                    {
                        stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                    }
                    stop.hotKey = KeyBindingDefOf.Misc5;
                    yield return(stop);
                }
                // Toggle fire gizmo
                if (CanToggleHoldFire)
                {
                    yield return(new Command_Toggle
                    {
                        defaultLabel = "CommandHoldFire".Translate(),
                        defaultDesc = "CommandHoldFireDesc".Translate(),
                        icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                        hotKey = KeyBindingDefOf.Misc6,
                        toggleAction = delegate
                        {
                            holdFire = !holdFire;
                            if (holdFire)
                            {
                                ResetForcedTarget();
                            }
                        },
                        isActive = (() => holdFire)
                    });
                }
            }
        }
コード例 #29
0
        public override void Init(GraphicRequest req)
        {
            this.data     = req.graphicData;
            this.path     = req.path;
            this.color    = req.color;
            this.colorTwo = req.colorTwo;
            this.drawSize = req.drawSize;
            Texture2D[] array = new Texture2D[4];

            string addedpartName = null;
            string side          = null;
            string crowntype     = null;

            string fileNameWithoutExtension = req.path;

            string[] array2 = fileNameWithoutExtension.Split('_');
            try
            {
                addedpartName = array2[0];
                side          = array2[1];
                crowntype     = array2[2];
            }
            catch (Exception ex)
            {
                Log.Error("Parse error with head graphic at " + req.path + ": " + ex.Message);
            }

            if (ContentFinder <Texture2D> .Get(req.path + "_front", false))
            {
                array[2] = ContentFinder <Texture2D> .Get(req.path + "_front");
            }
            else
            {
                Log.Message(
                    "Facial Stuff: Failed to get front texture at " + req.path + "_front"
                    + " - Graphic_Multi_AddedHeadParts");
                return;

                // array[2] = MaskTextures.BlankTexture();
            }

            Texture2D sideTex = ContentFinder <Texture2D> .Get(addedpartName + "_" + crowntype + "_side", false);

            Texture2D side2Tex = ContentFinder <Texture2D> .Get(addedpartName + "_" + crowntype + "_side2", false);

            Texture2D backTex = ContentFinder <Texture2D> .Get(req.path + "_back", false);

            if (sideTex.NullOrBad())
            {
                Log.Message(
                    "Facial Stuff: No texture found at " + addedpartName + "_" + crowntype + "_side"
                    + " - Graphic_Multi_AddedHeadParts. This message is just a note, no error.");
                array[3] = FaceTextures.BlankTexture;
            }
            else
            {
                // ReSharper disable once PossibleNullReferenceException
                if (side.Equals("Right"))
                {
                    if (!side2Tex.NullOrBad())
                    {
                        array[3] = side2Tex;
                    }
                    else
                    {
                        array[3] = FaceTextures.BlankTexture;
                    }
                }
                else
                {
                    array[3] = sideTex;
                }

                if (side.Equals("Left"))
                {
                    if (side2Tex.NullOrBad())
                    {
                        array[1] = FaceTextures.BlankTexture;
                    }
                    else
                    {
                        array[1] = side2Tex;
                    }
                }
                else
                {
                    array[1] = sideTex;
                }
            }

            if (backTex)
            {
                array[0] = backTex;
            }
            else
            {
                array[0] = FaceTextures.BlankTexture;
            }

            for (int i = 0; i < 4; i++)
            {
                if (array[i] == null)
                {
                    Log.Message("Array = null at: " + i);
                }

                MaterialRequest req2 = default;
                req2.mainTex  = array[i];
                req2.shader   = req.shader;
                req2.color    = this.color;
                req2.colorTwo = this.colorTwo;

                // ReSharper disable once PossibleNullReferenceException
                req2.mainTex.filterMode = FilterMode.Trilinear;

                // req2.maskTex = array2[i];
                this._mats[i] = MaterialPool.MatFrom(req2);
            }
        }
コード例 #30
0
 static Texture2D GetModTexture(string modName, string resourcePath)
 {
     return(ModLister.HasActiveModWithName(modName)
         ? ContentFinder <Texture2D> .Get(resourcePath, ShaderDatabase.Transparent)
         : null);
 }