コード例 #1
0
        protected override Gui.Mesh Redraw()
        {
            // Set values from CreatureAI
            if (Employee != null && !Employee.IsDead)
            {
                if (Employee.GetRoot().GetComponent <Inventory>().HasValue(out var inventory))
                {
                    ContentsPanel.Hidden    = false;
                    ContentsPanel.Resources = inventory.ContentsAsResourceSet();
                    ContentsPanel.Invalidate();
                    Text = "";
                }
                else
                {
                    ContentsPanel.Hidden    = true;
                    ContentsPanel.Resources = null;
                    Text = "This creature has no inventory.";
                }
            }
            else
            {
                ContentsPanel.Hidden    = true;
                ContentsPanel.Resources = null;
                Text = "No employee selected.";
            }

            return(base.Redraw());
        }
コード例 #2
0
        protected override Gui.Mesh Redraw()
        {
            if (Employee != null && !Employee.IsDead)
            {
                Employee.World.Tutorial("equipment");

                Hidden = false;
                Text   = "";

                if (Employee.Creature.Equipment.HasValue(out var equipment))
                {
                    if (SelectedSlot != null && equipment.GetItemInSlot(SelectedSlot.Name).HasValue(out var selectedTool))
                    {
                        SelectedSlotIcon.Resource = selectedTool;
                        RemoveButton.Hidden       = false;
                    }
                    else
                    {
                        SelectedSlotIcon.Resource = null;
                        RemoveButton.Hidden       = true;
                    }

                    foreach (var slot in ResourceIcons)
                    {
                        var tool     = equipment.GetItemInSlot(slot.Key);
                        var slotType = Library.FindEquipmentSlotType(slot.Key);

                        // Set the icon background
                        if (tool.HasValue(out var t))
                        {
                            slot.Value.Resource = t;

                            if (SelectedSlot != null && SelectedSlot.Name == slot.Key)
                            {
                                slot.Value.Hilite = new TileReference("equipment_sheet", 2);
                            }
                            else
                            {
                                slot.Value.Hilite = new TileReference("equipment_sheet", 1);
                            }
                        }
                        else if (slotType.HasValue(out var st))
                        {
                            slot.Value.Resource = null;

                            if (SelectedSlot != null && SelectedSlot.Name == slot.Key)
                            {
                                slot.Value.Hilite = st.SelectedBackground;
                            }
                            else
                            {
                                slot.Value.Hilite = st.UnselectedBackground;
                            }
                        }
                        else
                        {
                            slot.Value.Resource = null;

                            if (SelectedSlot != null && SelectedSlot.Name == slot.Key)
                            {
                                slot.Value.Hilite = new TileReference("equipment_sheet", 2);
                            }
                            else
                            {
                                slot.Value.Hilite = new TileReference("equipment_sheet", 1);
                            }
                        }

                        slot.Value.Invalidate();
                    }

                    ContentsPanel.Resources.Clear();

                    if (Employee.GetRoot().GetComponent <Inventory>().HasValue(out var inventory))
                    {
                        ContentsPanel.Hidden = false;

                        if (SelectedSlot != null)
                        {
                            foreach (var res in Employee.World.EnumerateResourcesInStockpiles().Where(r => r.Equipment_Slot == SelectedSlot.Name))
                            {
                                ContentsPanel.Resources.Add(res);
                            }
                            foreach (var res in inventory.Resources.Where(r => r.Resource.Equipment_Slot == SelectedSlot.Name))
                            {
                                ContentsPanel.Resources.Add(res.Resource);
                            }
                        }

                        ContentsPanel.Invalidate();
                    }
                    else
                    {
                        ContentsPanel.Hidden = true;
                    }
                }
                else
                {
                    Text = "This employee cannot use equipment.";
                }
            }
            else
            {
                Hidden = true;
            }

            return(base.Redraw());
        }
コード例 #3
0
        protected override Gui.Mesh Redraw()
        {
            if (Employee != null && !Employee.IsDead)
            {
                Employee.World.Tutorial("equipment");

                Hidden = false;
                Text   = "";

                foreach (var icon in ResourceIcons)
                {
                    icon.Value.Hilite   = null;
                    icon.Value.Resource = null;
                }

                if (Employee.Creature.Equipment.HasValue(out var equipment))
                {
                    SelectedSlotIcon.Resource = null;
                    RemoveButton.Hidden       = true;

                    foreach (var slot in ResourceIcons)
                    {
                        if (equipment.GetItemInSlot(slot.Key).HasValue(out var tool))
                        {
                            slot.Value.Resource = tool;
                            if (SelectedSlot != null && SelectedSlot.Name == slot.Key)
                            {
                                slot.Value.Hilite         = "selected-slot";
                                SelectedSlotIcon.Resource = tool;
                                RemoveButton.Hidden       = false;
                                RemoveButton.Invalidate();
                            }
                        }
                    }

                    ContentsPanel.Resources.Clear();

                    if (Employee.GetRoot().GetComponent <Inventory>().HasValue(out var inventory))
                    {
                        ContentsPanel.Hidden = false;

                        if (SelectedSlot != null)
                        {
                            foreach (var res in Employee.World.EnumerateResourcesInStockpiles().Where(r => r.Equipment_Slot == SelectedSlot.Name))
                            {
                                ContentsPanel.Resources.Add(res);
                            }
                            foreach (var res in inventory.Resources.Where(r => r.Resource.Equipment_Slot == SelectedSlot.Name))
                            {
                                ContentsPanel.Resources.Add(res.Resource);
                            }
                        }

                        ContentsPanel.Invalidate();
                    }
                    else
                    {
                        ContentsPanel.Hidden = true;
                    }
                }
                else
                {
                    Text = "This employee cannot use equipment.";
                }
            }
            else
            {
                Hidden = true;
            }

            return(base.Redraw());
        }