Ejemplo n.º 1
0
        public void RemoveVerb(Verb verb)
        {
            var mv = verbs.Find(m => m.Verb == verb);

            verbs.Remove(mv);
            if (drawVerbs.Contains(mv))
            {
                drawVerbs.Remove(mv);
            }
            var idx = tickVerbs.FindIndex(tv => tv.Verb == verb);

            if (idx >= 0)
            {
                tickVerbs.RemoveAt(idx);
                if (tickVerbs.Count == 0)
                {
                    NeedsTicking = false;
                    WorldComponent_MVCF.GetComp().TickManagers.RemoveAll(wr =>
                    {
                        if (!wr.TryGetTarget(out var man))
                        {
                            return(true);
                        }
                        return(man == this);
                    });
                }
            }

            RecalcSearchVerb();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 4
0
        public static WorldComponent_MVCF GetComp()
        {
            var getKey = Find.World.ConstantRandSeed;

            if (getKey != localCache.key)
            {
                localCache = Find.World.GetComponent <WorldComponent_MVCF>();
            }

            return(localCache);
        }
        public void RemoveVerb(Verb verb)
        {
            if (debugOpts.VerbLogging)
            {
                Log.Message("Removing " + verb);
            }
            var mv = verbs.Find(m => m.Verb == verb);

            if (debugOpts.VerbLogging)
            {
                Log.Message("Found ManagedVerb: " + mv);
            }

            var success = verbs.Remove(mv);

            if (debugOpts.VerbLogging)
            {
                Log.Message("Succeeded at removing: " + success);
            }
            if (drawVerbs.Contains(mv))
            {
                drawVerbs.Remove(mv);
            }
            var idx = tickVerbs.FindIndex(tv => tv.Verb == verb);

            if (idx >= 0)
            {
                tickVerbs.RemoveAt(idx);
                if (tickVerbs.Count == 0)
                {
                    NeedsTicking = false;
                    WorldComponent_MVCF.GetComp().TickManagers.RemoveAll(wr =>
                    {
                        if (!wr.TryGetTarget(out var man))
                        {
                            return(true);
                        }
                        return(man == this);
                    });
                }
            }

            RecalcSearchVerb();
        }
Ejemplo n.º 6
0
 public WorldComponent_MVCF(World world) : base(world)
 {
     key        = world.ConstantRandSeed;
     localCache = this;
 }