コード例 #1
0
 public void ScatterItemsAround()
 {
     foreach (Thing thing in itemsList)
     {
         IntVec3 bestSpot = IntVec3.Invalid;
         if (JobDriver_HaulToCell.TryFindPlaceSpotNear(parent.Position, thing, out bestSpot))
         {
             thing.Position = bestSpot;
         }
         else
         {
             Log.Error("No free spot for " + thing);
         }
     }
 }
コード例 #2
0
        protected override void FillTab()
        {
            Building_Storage storage = this.SelThing as Building_Storage;

            this.container = storage.TryGetComp <CompContainer>();
            if (container == null)
            {
                Log.Error("No CompContainer included for this Building_Storage");
                return;
            }
            List <Thing> list        = container.itemsList;
            float        fieldHeight = 30.0f;

            this.size = new Vector2(300f, 55f + container.compProps.itemsCap * fieldHeight);

            ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame);
            Text.Font = GameFont.Small;

            Rect  innerRect  = GenUI.ContractedBy(new Rect(0.0f, 0.0f, this.size.x, this.size.y), 10f);
            float innerRectX = innerRect.x;

            GUI.BeginGroup(innerRect);
            {
                Widgets.TextField(new Rect(0.0f, 0.0f, this.size.x - 40f, fieldHeight), GetTitle());

                Rect thingIconRect   = new Rect(10f, fieldHeight + 5f, 30f, fieldHeight);
                Rect thingLabelRect  = new Rect(thingIconRect.x + 35f, thingIconRect.y + 5.0f, innerRect.width - 35f, fieldHeight);
                Rect thingButtonRect = new Rect(thingIconRect.x, thingIconRect.y, innerRect.width, fieldHeight);

                //float startY = 0.0f;
                //Widgets.ListSeparator(ref startY, innerRect.width, GetTitle());

                foreach (var thing in list)
                {
                    Widgets.ThingIcon(thingIconRect, thing);
                    Widgets.Label(thingLabelRect, thing.Label);

                    if (Widgets.InvisibleButton(thingButtonRect))
                    {
                        List <FloatMenuOption> options = new List <FloatMenuOption>();
                        options.Add(new FloatMenuOption("Container_Info".Translate(), () =>
                        {
                            // NOTE ?
                            Find.WindowStack.Add(new Dialog_InfoCard(thing));
                        }));
                        options.Add(new FloatMenuOption("Container_Drop".Translate(), () =>
                        {
                            IntVec3 bestSpot = IntVec3.Invalid;
                            if (JobDriver_HaulToCell.TryFindPlaceSpotNear(storage.Position, thing, out bestSpot))
                            {
                                thing.Position = bestSpot;
                            }
                            else
                            {
                                Log.Error("No free spot for " + thing);
                            }
                        }));

                        Find.WindowStack.Add(new FloatMenu(options, "", false, false));
                    }

                    thingIconRect.y   += fieldHeight;
                    thingLabelRect.y  += fieldHeight;
                    thingButtonRect.y += fieldHeight;
                }
            }
            GUI.EndGroup();
        }