Ejemplo n.º 1
0
        public bool CongruentTo(BehaviorCriteria otherCriteria)
        {
            if (otherCriteria.BehaviorAddress != BehaviorAddress)
            {
                return(false);
            }

            if (GfxId.HasValue && otherCriteria.GfxId.HasValue && GfxId.Value != otherCriteria.GfxId.Value)
            {
                return(false);
            }

            if (SubType.HasValue && otherCriteria.SubType.HasValue && SubType.Value != otherCriteria.SubType.Value)
            {
                return(false);
            }

            if (Appearance.HasValue && otherCriteria.Appearance.HasValue && Appearance.Value != otherCriteria.Appearance.Value)
            {
                return(false);
            }

            if (SpawnObj.HasValue && otherCriteria.SpawnObj.HasValue && SpawnObj.Value != otherCriteria.SpawnObj.Value)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public string GetObjectName(BehaviorCriteria behaviorCriteria)
        {
            var assoc = FindObjectAssociation(behaviorCriteria);

            if (assoc == null)
            {
                return("Unknown Object");
            }

            return(assoc.Name);
        }
Ejemplo n.º 3
0
        public bool GetObjectMapRotates(BehaviorCriteria behaviorCriteria)
        {
            var assoc = FindObjectAssociation(behaviorCriteria);

            if (assoc == null)
            {
                return(false);
            }

            return(assoc.RotatesOnMap);
        }
Ejemplo n.º 4
0
        public List <WatchVariableControl> GetWatchVarControls(BehaviorCriteria behaviorCriteria)
        {
            var assoc = FindObjectAssociation(behaviorCriteria);

            if (assoc == null)
            {
                return(new List <WatchVariableControl>());
            }

            else
            {
                return(assoc.WatchVariableControls);
            }
        }
Ejemplo n.º 5
0
        public Image GetObjectMapImage(BehaviorCriteria behaviorCriteria)
        {
            if (behaviorCriteria.BehaviorAddress == 0)
            {
                return(EmptyImage);
            }

            var assoc = FindObjectAssociation(behaviorCriteria);

            if (assoc == null)
            {
                return(_defaultImage);
            }

            return(assoc.MapImage);
        }
Ejemplo n.º 6
0
        public Image GetObjectImage(BehaviorCriteria behaviorCriteria, bool transparent)
        {
            if (behaviorCriteria.BehaviorAddress == 0)
            {
                return(EmptyImage);
            }

            var assoc = FindObjectAssociation(behaviorCriteria);

            if (assoc == null)
            {
                return(transparent ? _transparentDefaultImage : _defaultImage);
            }

            return(transparent ? assoc.TransparentImage : assoc.Image);
        }
Ejemplo n.º 7
0
        public BehaviorCriteria?Generalize(BehaviorCriteria otherCriteria)
        {
            if (otherCriteria.BehaviorAddress != BehaviorAddress)
            {
                return(null);
            }

            if (GfxId.HasValue && otherCriteria.GfxId.HasValue && GfxId.Value != otherCriteria.GfxId.Value)
            {
                return new BehaviorCriteria()
                       {
                           BehaviorAddress = BehaviorAddress
                       }
            }
            ;

            if (SubType.HasValue && otherCriteria.SubType.HasValue && SubType.Value != otherCriteria.SubType.Value)
            {
                return new BehaviorCriteria()
                       {
                           BehaviorAddress = BehaviorAddress, GfxId = GfxId
                       }
            }
            ;

            if (Appearance.HasValue && otherCriteria.Appearance.HasValue && Appearance.Value != otherCriteria.Appearance.Value)
            {
                return new BehaviorCriteria()
                       {
                           BehaviorAddress = BehaviorAddress, GfxId = GfxId, SubType = SubType
                       }
            }
            ;

            if (SpawnObj.HasValue && otherCriteria.SpawnObj.HasValue && SpawnObj.Value != otherCriteria.SpawnObj.Value)
            {
                return new BehaviorCriteria()
                       {
                           BehaviorAddress = BehaviorAddress, GfxId = GfxId, SubType = SubType, Appearance = Appearance
                       }
            }
            ;

            return(this);
        }
Ejemplo n.º 8
0
        public ObjectBehaviorAssociation FindObjectAssociation(BehaviorCriteria behaviorCriteria)
        {
            if (_cachedObjAssoc.ContainsKey(behaviorCriteria))
            {
                return(_cachedObjAssoc[behaviorCriteria]);
            }

            var possibleAssoc = _objAssoc.Where(objAssoc => objAssoc.MeetsCriteria(behaviorCriteria));

            if (possibleAssoc.Count() > 1 && possibleAssoc.Any(objAssoc => objAssoc.BehaviorCriteria.BehaviorOnly()))
            {
                possibleAssoc = possibleAssoc.Where(objAssoc => !objAssoc.BehaviorCriteria.BehaviorOnly());
            }

            var behaviorAssoc = possibleAssoc.FirstOrDefault();

            _cachedObjAssoc[behaviorCriteria] = behaviorAssoc;

            return(behaviorAssoc);
        }
Ejemplo n.º 9
0
        public bool RecognizedBehavior(BehaviorCriteria behaviorCriteria)
        {
            var assoc = FindObjectAssociation(behaviorCriteria);

            return(assoc != null);
        }
 public bool MeetsCriteria(BehaviorCriteria behaviorCriteria)
 {
     return(Criteria.CongruentTo(behaviorCriteria));
 }