public List <int> FindContextTarget(ContextTargetType target, ContextAbilityData context) { var list = new List <int>(); switch (target) { case ContextTargetType.Target: list.Add(ContextTurn.InterfaceTargetId ?? context.OwnerId); break; case ContextTargetType.Owner: list.Add(context.OwnerId); break; case ContextTargetType.AllAllies: list = (context.IsEnemy ? _battleAccessor.LiveEnemies : _battleAccessor.LiveAllies).ToList(); break; case ContextTargetType.AllEnemies: list = (context.IsEnemy ? _battleAccessor.LiveAllies : _battleAccessor.LiveEnemies).ToList(); break; case ContextTargetType.AllUnits: list = _unitAccessor.State.Units.Where(x => x.Stars > 0).Select(x => x.Id).ToList(); break; default: throw new ArgumentOutOfRangeException(nameof(target), target, null); } return(list); }
private Type _FindContextWithFeatures(ContextTargetType contextTargetType, ContextFeatures contextFeatures) { IEnumerable <Type> contextTypes = Assembly.GetExecutingAssembly().GetAttributedTypes(typeof(ContextAttribute)); return (contextTypes.FirstOrDefault( x => x.GetCustomAttributes(typeof(ContextAttribute), false).Cast <ContextAttribute>().Any( y => y.TargetType == contextTargetType && y.Caching == contextFeatures.Caching))); }
public List <int> FindExplorerTarget(ContextTargetType target) { if (target == ContextTargetType.AllUnits) { return(_unitAccessor.State.Units.Where(x => x.Stars > 0).Select(x => x.Id).ToList()); } var list = _unitAccessor.ExplorerUnits.ToList(); if (_unitAccessor.State.Assist != null) { list.Add(_unitAccessor.State.Assist.Id); } return(list); }
private IContext _CreateContext(ContextTargetType contextTargetType, ContextFeatures contextFeatures) { if (contextFeatures == null) { throw new ArgumentNullException("contextFeatures"); } Type contextType = _FindContextWithFeatures(contextTargetType, contextFeatures); if (contextType == null) { Logging.Error(string.Format("Could not find a context for target type {0} with features {1}", contextTargetType, contextFeatures)); return(null); } return((ContextBase)Activator.CreateInstance(contextType)); }
private IContext _CreateContext(ContextTargetType contextTargetType, ContextFeatures contextFeatures) { if (contextFeatures == null) { throw new ArgumentNullException("contextFeatures"); } Type contextType = _FindContextWithFeatures(contextTargetType, contextFeatures); if (contextType == null) { VixenSystem.Logging.Error("Could not find a context for target type " + contextTargetType + " with features " + contextFeatures); return(null); } return((ContextBase)Activator.CreateInstance(contextType)); }
public ContextAttribute(ContextTargetType targetType, ContextCaching caching) { TargetType = targetType; Caching = caching; }