public static void RegisterVisualizer(Type forType, ICustomVisualizer visualizer, bool registerDerivedTypes = false)
 {
     Ensure.ArgumentNotNull(visualizer, "visualizer");
     if (VisualizationManager._visualizerLookup == null)
     {
         VisualizationManager._visualizerLookup = new Dictionary <Type, ICustomVisualizer>();
     }
     if (!(forType.IsAbstract | registerDerivedTypes))
     {
         if (VisualizationManager._visualizerLookup.ContainsKey(forType))
         {
             Debug.LogWarning(string.Format("A visualizer for type {0} has already been registered, skipping {1}.", forType.Name, visualizer.GetType().Name));
             return;
         }
         VisualizationManager._visualizerLookup.Add(forType, visualizer);
     }
     else
     {
         foreach (Type derived in VisualizationManager.GetDerived(forType))
         {
             if (!VisualizationManager._visualizerLookup.ContainsKey(derived))
             {
                 VisualizationManager._visualizerLookup.Add(derived, visualizer);
             }
             else
             {
                 Debug.LogWarning(string.Format("A visualizer for type {0} has already been registered, skipping {1}.", derived.Name, visualizer.GetType().Name));
             }
         }
     }
 }
Example #2
0
        public float Score(IAIContext context)
        {
            ICustomVisualizer customVisualizer;
            float             single = this._scorer.Score(context);

            this.lastScore = single.ToString("f0");
            if (VisualizationManager.TryGetVisualizerFor(this._scorer.GetType(), out customVisualizer))
            {
                customVisualizer.EntityUpdate(this._scorer, context, this._parent.parent.parent.id);
            }
            return(single);
        }
        public virtual float Score(IAIContext context)
        {
            ICustomVisualizer customVisualizer;
            float             single = this._qualifier.Score(context);

            this.lastScore = new float?(single);
            if (VisualizationManager.TryGetVisualizerFor(this._qualifier.GetType(), out customVisualizer))
            {
                customVisualizer.EntityUpdate(this._qualifier, context, this._parent.parent.id);
            }
            return(single);
        }
Example #4
0
        public override float Score(IAIContext context)
        {
            ICustomVisualizer customVisualizer;
            float             single = ((ICompositeScorer)base.qualifier).Score(context, this._scorers);

            base.lastScore = new float?(single);
            if (VisualizationManager.TryGetVisualizerFor(base.qualifier.GetType(), out customVisualizer))
            {
                customVisualizer.EntityUpdate(base.qualifier, context, base.parent.parent.id);
            }
            return(single);
        }
        internal virtual void Execute(IAIContext context, bool doCallback)
        {
            ICustomVisualizer customVisualizer;

            this._action.Execute(context);
            if (doCallback)
            {
                this._parent.parent.parent.PostExecute();
            }
            if (VisualizationManager.TryGetVisualizerFor(this._action.GetType(), out customVisualizer))
            {
                customVisualizer.EntityUpdate(this._action, context, this._parent.parent.parent.id);
            }
        }
        /// <summary>
        /// Calculates a score using the supplied scorers given the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// The score.
        /// </returns>
        public override float Score(IAIContext context)
        {
            var score = ((ICompositeScorer)this.qualifier).Score(context, _scorers);

            this.lastScore = score;

            ICustomVisualizer customVisualizer;

            if (VisualizationManager.TryGetVisualizerFor(this.qualifier.GetType(), out customVisualizer))
            {
                customVisualizer.EntityUpdate(this.qualifier, context, this.parent.parent.id);
            }

            return(score);
        }
Example #7
0
        /// <summary>
        /// Calculates the score for this qualifier given the provided context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// The score.
        /// </returns>
        public virtual float Score(IAIContext context)
        {
            var score = _qualifier.Score(context);

            this.lastScore = score;

            ICustomVisualizer customVisualizer;

            if (VisualizationManager.TryGetVisualizerFor(_qualifier.GetType(), out customVisualizer))
            {
                customVisualizer.EntityUpdate(_qualifier, context, _parent.parent.id);
            }

            return(score);
        }
 public static void UnregisterVisualizer(Type forType, bool registeredDerivedTypes = false)
 {
     if (VisualizationManager._visualizerLookup == null)
     {
         return;
     }
     if (!(forType.IsAbstract | registeredDerivedTypes))
     {
         VisualizationManager._visualizerLookup.Remove(forType);
     }
     else
     {
         foreach (Type derived in VisualizationManager.GetDerived(forType))
         {
             VisualizationManager._visualizerLookup.Remove(derived);
         }
     }
 }
Example #9
0
 protected virtual void OnEnable()
 {
     VisualizationManager.RegisterVisualizer <T>(this, this.registerForDerivedTypes);
 }
 public static void RegisterVisualizer <TFor>(ICustomVisualizer visualizer, bool registerDerivedTypes = false)
 {
     VisualizationManager.RegisterVisualizer(typeof(TFor), visualizer, registerDerivedTypes);
 }
 public static void UnregisterVisualizer <TFor>(bool registeredDerivedTypes = false)
 {
     VisualizationManager.UnregisterVisualizer(typeof(TFor), registeredDerivedTypes);
 }