Ludeon Forums

RimWorld => Bugs => Topic started by: 1000101 on July 04, 2015, 08:38:10 PM

Title: [A11] Command class "Desc" is never used, always references "defaultDesc"
Post by: 1000101 on July 04, 2015, 08:38:10 PM
I'm not sure if I should have posted it here, it is a "real bug" but not one that effects actual game play.  If this is the wrong place for it, I apologise now.

This bug only really shows up when modding as it only becomes apparent when extending the Command class in conjunction with Gizmos.

In the Command class, there is a virtual property Desc which (in theory) allows commands description to be handled by inheritors.  Unfortunately, it doesn't seem this is ever invoked and the defaultDesc is always used.

This leads to unexpected behaviour when modding, namely, no description callback.  If your description is static no problem, use defaultDesc.

Unless I am totally missing the purpose of the Desc property...?

Sample code to reproduce:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using RimWorld;
using UnityEngine;
using Verse;
using Verse.AI;

namespace foo
{
    public class TestCommand : Command
    {
        public TestCommand() {
            // Give it the grow zone icon for testing
            icon = ContentFinder<Texture2D>.Get( "UI/Designators/ZoneCreate_Growing", true );
        }

        // THIS IS NEVER INVOKED!
        // Shows "No description."
        public override string Desc {
            get { return "Yes description."; }
        }

    }

    public class Building_Bar : Building
    {
       
        public override IEnumerable<Command> GetGizmos()
        {
            yield return base.GetGizmos();

            // Get the offending gizmo
            var bar = new foo.TestCommand();
            yield return bar;

            // No more gizmos
            yield break;
        }

    }

}
Title: Re: [A11] Command class "Desc" is never used, always references "defaultDesc"
Post by: Tynan on July 15, 2015, 10:04:42 PM
You're right, for the tooltip it was ignoring Desc. Fixed now, thanks.