How to you add an option to a building?

Started by VapidLinus, December 25, 2014, 12:46:33 PM

Previous topic - Next topic

VapidLinus

One of these:


I've been looking at the source of Building_Door.cs and a bunch of other buildings but I haven't been able to figure it out.

mrofa

Hmm wierd couldnt find them to :D
It might be that they are still hard coded.

Anyways to add butons to buildings you need to use GetCommand

        //Buttons
        public override IEnumerable<Command> GetCommands()
        {
            IList<Command> list = new List<Command>();
            Command_Action ca0 = new Command_Action();
            ca0.icon = Uisave;
            ca0.defaultDesc = "Switch Image";
            ca0.activateSound = SoundDef.Named("Click");
            ca0.action = new Action(TexSwitch);
            ca0.hotKey = KeyBindingDefOf.Misc9;
            ca0.groupKey = 887761181;
            list.Add(ca0);

            Command_Action ca1 = new Command_Action();
            if (!Rswitch)
            {
                ca1.icon = UI_Rot1;
            }
            else
            {
                ca1.icon = UI_Rot2;
            }
            ca1.defaultDesc = "Toggle rotation";
            ca1.activateSound = SoundDef.Named("Click");
            ca1.action = new Action(RotSwitch);
            ca1.hotKey = KeyBindingDefOf.Misc10;
            ca1.groupKey = 887761189;
            list.Add(ca1);

            IEnumerable<Command> commands = base.GetCommands();
            IEnumerable<Command> result;
            if (commands != null)
                result = list.AsEnumerable<Command>().Concat(commands);
            else
                result = list.AsEnumerable<Command>();
            return result;
        }


So it looks generally like this :)
All i do is clutter all around.