コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Dialog_Costume"/> class.
        /// </summary>
        /// <param name="loadout"> loadout that getups are dervied from. </param>
        /// <param name="pawn"> The pawn who <paramref name="loadout"/> is assigned to. </param>
        public Dialog_Costume(AwesomeInventoryLoadout loadout, Pawn pawn)
        {
            ValidateArg.NotNull(loadout, nameof(loadout));
            ValidateArg.NotNull(pawn, nameof(pawn));

            if (loadout is AwesomeInventoryCostume costume)
            {
                _loadout = costume.Base;
                _costume = costume;
            }
            else
            {
                _loadout = loadout;
            }

            _apparelInLoadout = _loadout.ThingGroupSelectors
                                .Where(t => t.AllowedThing.IsApparel)
                                .OrderBy(t => t.LabelCapNoCount)
                                .ToList();

            _pawn = pawn;

            doCloseX = true;
            absorbInputAroundWindow = true;
            closeOnClickedOutside   = true;
            resizeable = true;
            draggable  = true;
        }
コード例 #2
0
        /// <inheritdoc/>
        public override void PreOpen()
        {
            base.PreOpen();
            _costumes = LoadoutManager.Loadouts.OfType <AwesomeInventoryCostume>().ToList();
            List <ChecklistItem <AwesomeInventoryCostume> > items = new List <ChecklistItem <AwesomeInventoryCostume> >();

            foreach (AwesomeInventoryCostume costume in _costumes)
            {
                ChecklistItem <AwesomeInventoryCostume> item =
                    new ChecklistItem <AwesomeInventoryCostume>(
                        costume.label
                        , costume
                        , GenUI.ListSpacing
                        , _columnWidth
                        , false)
                {
                    Draw = (pos, cos) =>
                    {
                        Rect labelRect = new Rect(pos, new Vector2(_columnWidth - GenUI.ListSpacing * 2, GenUI.ListSpacing));
                        Rect checkRect = new Rect(labelRect.xMax, pos.y, GenUI.ListSpacing * 2, GenUI.ListSpacing);

                        Widgets.Label(labelRect, costume.label);
                        if (Widgets.ButtonImageWithBG(checkRect, TexResource.TriangleRight, new Vector2(GenUI.SmallIconSize, GenUI.SmallIconSize)))
                        {
                            _selectedCostume = costume;
                            _costumeItemList = new Checklist <ThingGroupSelector>(
                                costume.Select(
                                    g => new ChecklistItem <ThingGroupSelector>(g.LabelCapNoCount, g, GenUI.ListSpacing, _columnWidth, false))
                                .ToList()
                                , false
                                , true
                                , true);
                        }

                        return(labelRect);
                    },
                };
                items.Add(item);
            }

            _costumeList = new Checklist <AwesomeInventoryCostume>(items, true, true);
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Dialog_Costume"/> class.
        /// </summary>
        /// <param name="loadout"> loadout that getups are dervied from. </param>
        /// <param name="pawn"> The pawn who <paramref name="loadout"/> is assigned to. </param>
        public Dialog_Costume(AwesomeInventoryLoadout loadout, Pawn pawn)
        {
            ValidateArg.NotNull(loadout, nameof(loadout));
            ValidateArg.NotNull(pawn, nameof(pawn));

            if (loadout is AwesomeInventoryCostume costume)
            {
                _loadout = costume.Base;
                _costume = costume;
            }
            else
            {
                _loadout = loadout;
            }

            _pawn = pawn;

            doCloseX = true;
            absorbInputAroundWindow = true;
            closeOnClickedOutside   = true;
            resizeable = true;
            draggable  = true;
        }
コード例 #4
0
        private void DrawHeader(Rect canvas)
        {
            WidgetRow widgetRow = new WidgetRow(canvas.x, canvas.y, UIDirection.RightThenDown);

            if (widgetRow.ButtonText(UIText.CreateCostume.TranslateSimple()))
            {
                AwesomeInventoryCostume costume = new AwesomeInventoryCostume(_loadout);

                _costume = costume;
                _loadout.Costumes.Add(costume);
                LoadoutManager.AddLoadout(costume);
            }

            if (widgetRow.ButtonText(UIText.CopyCostume.TranslateSimple()))
            {
                if (_costume != null)
                {
                    AwesomeInventoryCostume costume = new AwesomeInventoryCostume(_costume);

                    _costume = costume;
                    _loadout.Costumes.Add(costume);
                    LoadoutManager.AddLoadout(costume);
                }
                else
                {
                    DrawNoCostumeWindow();
                }
            }

            if (widgetRow.ButtonText(UIText.DeleteCostume.TranslateSimple()))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (AwesomeInventoryCostume costume in _loadout.Costumes)
                {
                    options.Add(
                        new FloatMenuOption(
                            costume.label
                            , () =>
                    {
                        _loadout.Costumes.Remove(costume);
                        _costume = null;
                        _pawn.outfits.CurrentOutfit = _loadout;
                        LoadoutManager.TryRemoveLoadout(costume);
                    }));
                }

                if (!options.Any())
                {
                    options.Add(new FloatMenuOption(UIText.NoCostumeAvailable.TranslateSimple(), null));
                }

                Find.WindowStack.Add(new FloatMenu(options));
            }

            if (widgetRow.ButtonText(UIText.SelectCostume.TranslateSimple()))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (AwesomeInventoryCostume costume in _loadout.Costumes)
                {
                    options.Add(
                        new FloatMenuOption(
                            costume.label
                            , () =>
                    {
                        _costume = costume;
                    }));
                }

                if (!options.Any())
                {
                    options.Add(new FloatMenuOption(UIText.NoCostumeAvailable.TranslateSimple(), null));
                }

                Find.WindowStack.Add(new FloatMenu(options));
            }

            Rect   nameRect = new Rect(widgetRow.FinalX, widgetRow.FinalY, canvas.width - widgetRow.FinalX, GenUI.ListSpacing);
            string name;

            if (_costume == null)
            {
                name      = UIText.NoCostumeAvailable.TranslateSimple();
                GUI.color = Color.grey;
            }
            else
            {
                name = _costume.label;
            }

            name = Widgets.TextField(nameRect, name);
            if (_costume != null)
            {
                _costume.label = name;
            }

            GUI.color = Color.white;
        }
コード例 #5
0
        /// <inheritdoc/>
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            ValidateArg.NotNull(pawn, nameof(pawn));

            if (Find.TickManager.TicksGame < _optimizedTick)
            {
                return(ThinkResult.NoJob);
            }

            CompAwesomeInventoryLoadout comp = pawn.TryGetComp <CompAwesomeInventoryLoadout>();

            if (comp?.Loadout == null || comp.Loadout.GetType() == typeof(AwesomeInventoryCostume))
            {
                return(ThinkResult.NoJob);
            }

            List <Thing> list = pawn.inventory?.innerContainer?.ToList();

            if (list == null)
            {
                return(ThinkResult.NoJob);
            }

            if (!list.Any())
            {
                _optimizedTick = _optmizedInterval + Find.TickManager.TicksGame;
                return(ThinkResult.NoJob);
            }

            List <Apparel> wornApparels = pawn.apparel?.WornApparel;

            if (wornApparels == null)
            {
                return(ThinkResult.NoJob);
            }

            AwesomeInventoryCostume costume = comp.Loadout as AwesomeInventoryCostume;

            var thingList = list
                            .Where(t => t is Apparel apparel && ApparelOptionUtility.CanWear(pawn, apparel))
                            .Select(t => new { thing = t, score = JobGiver_OptimizeApparel.ApparelScoreGain(pawn, (Apparel)t) })
                            .Where(thingScore => thingScore.score > 0.05f)
                            .OrderByDescending(s => s.score)
                            .ToList();

            if (!thingList.Any())
            {
                _optimizedTick = _optmizedInterval + Find.TickManager.TicksGame;
                return(ThinkResult.NoJob);
            }

            List <Apparel> wornCostume = null;

            if (costume != null)
            {
                wornCostume = pawn.apparel.WornApparel
                              .AsParallel()
                              .Where(a => costume.CostumeItems.Any(c => c.Allows(a, out _)))
                              .ToList();
            }

            foreach (var t in thingList)
            {
                Thing thing = null;

                if (costume == null)
                {
                    thing = t.thing;
                }
                else
                {
                    foreach (ThingGroupSelector selector in costume.CostumeItems)
                    {
                        if (selector.Allows(t.thing, out _))
                        {
                            thing = t.thing;
                            break;
                        }
                    }

                    if (thing == null)
                    {
                        if (wornCostume.NullOrEmpty() || wornCostume.All(c => ApparelUtility.CanWearTogether(c.def, t.thing.def, BodyDefOf.Human)))
                        {
                            thing = t.thing;
                        }
                    }
                }

                if (thing != null)
                {
                    return(new ThinkResult(
                               new DressJob(AwesomeInventory_JobDefOf.AwesomeInventory_Dress, thing, false)
                               , this
                               , JobTag.ChangingApparel));
                }
            }

            _optimizedTick = _optmizedInterval + Find.TickManager.TicksGame;
            return(ThinkResult.NoJob);
        }