Example #1
0
        public void AddVerb(Verb verb, VerbSource source, AdditionalVerbProps props)
        {
            ManagedVerb mv;

            if (props != null && props.canFireIndependently)
            {
                var tv = new TurretVerb(verb, source, props, this);
                if (tickVerbs.Count == 0)
                {
                    NeedsTicking = true;
                    WorldComponent_MVCF.GetComp().TickManagers.Add(new System.WeakReference <VerbManager>(this));
                }

                tickVerbs.Add(tv);
                mv = tv;
            }
            else
            {
                mv = new ManagedVerb(verb, source, props, this);
            }

            if (props != null && props.draw)
            {
                drawVerbs.Add(mv);
            }

            verbs.Add(mv);
            RecalcSearchVerb();
        }
        public void AddVerb(Verb verb, VerbSource source, AdditionalVerbProps props)
        {
            if (debugOpts.VerbLogging)
            {
                Log.Message("Adding " + verb + " from " + source + " with props " + props);
            }
            if (AllVerbs.Contains(verb))
            {
                if (debugOpts.VerbLogging)
                {
                    Log.Warning("Added duplicate verb " + verb);
                }
                return;
            }

            ManagedVerb mv;

            if (props != null && props.canFireIndependently)
            {
                TurretVerb tv;
                if (props.managedClass != null)
                {
                    tv = (TurretVerb)Activator.CreateInstance(props.managedClass, verb, source, props, this);
                }
                else
                {
                    tv = new TurretVerb(verb, source, props, this);
                }
                if (tickVerbs.Count == 0)
                {
                    NeedsTicking = true;
                    WorldComponent_MVCF.GetComp().TickManagers.Add(new System.WeakReference <VerbManager>(this));
                }

                tickVerbs.Add(tv);
                mv = tv;
            }
            else
            {
                if (props?.managedClass != null)
                {
                    mv = (ManagedVerb)Activator.CreateInstance(props.managedClass, verb, source, props, this);
                }
                else
                {
                    mv = new ManagedVerb(verb, source, props, this);
                }
            }

            if (props != null && props.draw)
            {
                drawVerbs.Add(mv);
            }

            verbs.Add(mv);
            RecalcSearchVerb();
        }
Example #3
0
 public Command_ToggleVerbUsage(ManagedVerb verb)
 {
     icon         = verb.Verb.Icon(verb.Props, verb.Verb.EquipmentSource, true);
     isActive     = () => verb.Enabled;
     toggleAction = verb.Toggle;
     defaultLabel = PawnVerbGizmoUtility.FirstNonEmptyString(verb.Props?.toggleLabel,
                                                             "MVCF.Toggle".Translate(verb.Verb.Label(verb.Props)));
     defaultDesc = PawnVerbGizmoUtility.FirstNonEmptyString(verb.Props?.toggleDescription,
                                                            "MVCF.ToggleUsing".Translate(verb.Verb.Label(verb.Props)));
 }