public StructureDiscoveryCommand Instantiate(Target target, TargetType type, IEnumerable<CaptionFilter> filters) { if (!(connection is AdomdConnection)) throw new ArgumentException(); var builder = InstantiateBuilder(target, type); builder.Build(filters); var cmd = connection.CreateCommand(); cmd.CommandText = builder.GetCommandText(); var postFilters = builder.GetPostFilters(); var description = new CommandDescription(target, filters); OlapCommand command = null; if ((target == Target.MeasureGroups && type == TargetType.Object) || target == Target.Perspectives) command = new DistinctOlapCommand(cmd, postFilters, description); else if (target == Target.Dimensions && type == TargetType.Object) command = new DimensionCommand(cmd, postFilters, description); else if (target == Target.Dimensions && type == TargetType.Relation) command = new DimensionRelationCommand(cmd, postFilters, description); else command = new OlapCommand(cmd, postFilters, description); return command; }
public async void Run() { var instance = new Target(); await instance.MethodWithThrow(); //run and have a look at your Raygun dashboard Thread.Sleep(10); }
public BattleCommand GetNextAction(Player[] party, Enemy[] allies, ElementType[] fieldEffect) { if (pressTheAdvantage.CanUse(fieldEffect)) { var target = new Target { TheTarget = BehaviorHelpers.GetStrongestTarget(party), TargetType = TargetTypes.Single }; return CreateBattleCommand(target, pressTheAdvantage, CommandType.Ability); } if ((me.CurrentHP / (decimal)me.MaxHP) <= .5m && solarBeam.CanUse(fieldEffect)) { var target = new Target { TheTarget = BehaviorHelpers.GetWeakestTarget(party), TargetType = TargetTypes.Single }; return CreateBattleCommand(target, solarBeam, CommandType.Ability); } if (party.All(p => !p.IsDead) && cleave.CanUse(fieldEffect)) { var target = new Target { TargetType = TargetTypes.All }; return CreateBattleCommand(target, cleave, CommandType.Ability); } if (sliceAndDice.CanUse(fieldEffect)) { var target = new Target { TheTarget = BehaviorHelpers.GetRandomTarget(party), TargetType = TargetTypes.Single }; return CreateBattleCommand(target, sliceAndDice, CommandType.Ability); } return CreateBattleCommand(new Target { TheTarget = BehaviorHelpers.GetRandomTarget(party), TargetType = TargetTypes.Single }, Ability.ATTACK, CommandType.Attack); }
/// <summary>Assigns all needed attributes to the tag</summary> /// <returns>This instance downcasted to base class</returns> public virtual IndexedTag attr( Shape? shape = null, Length[] coords = null, string href = null, NoHref? nohref = null, Target target = null, string alt = null, string id = null, string @class = null, string style = null, string title = null, LangCode lang = null, string xmllang = null, Dir? dir = null, string onclick = null, string ondblclick = null, string onmousedown = null, string onmouseup = null, string onmouseover = null, string onmousemove = null, string onmouseout = null, string onkeypress = null, string onkeydown = null, string onkeyup = null, char? accesskey = null, int? tabindex = null, string onfocus = null, string onblur = null ) { Shape = shape; Coords = coords; Href = href; NoHref = nohref; Target = target; Alt = alt; Id = id; Class = @class; Style = style; Title = title; Lang = lang; XmlLang = xmllang; Dir = dir; OnClick = onclick; OnDblClick = ondblclick; OnMouseDown = onmousedown; OnMouseUp = onmouseup; OnMouseOver = onmouseover; OnMouseMove = onmousemove; OnMouseOut = onmouseout; OnKeyPress = onkeypress; OnKeyDown = onkeydown; OnKeyUp = onkeyup; AccessKey = accesskey; TabIndex = tabindex; OnFocus = onfocus; OnBlur = onblur; return this; }
/// <summary> /// Initializes a new instance of the <see cref="BufferingTargetWrapper" /> class. /// </summary> /// <param name="wrappedTarget">The wrapped target.</param> /// <param name="bufferSize">Size of the buffer.</param> /// <param name="flushTimeout">The flush timeout.</param> public BufferingTargetWrapper(Target wrappedTarget, int bufferSize, int flushTimeout) { this.WrappedTarget = wrappedTarget; this.BufferSize = bufferSize; this.FlushTimeout = flushTimeout; this.SlidingTimeout = true; }
/// <summary> Logs specified log level and above to custom target (requires knowledge of NLog target usage) </summary> public LoggerConfiguration AddTarget(LogLevel minLogLevel, Target target) { var loggingRule = new LoggingRule("*", minLogLevel.NLogLevel, target); LogManager.Configuration.LoggingRules.Add(loggingRule); LogManager.ReconfigExistingLoggers(); return this; }
/// <summary> /// 获取显示确认对话框的客户端脚本 /// </summary> /// <param name="message">对话框消息</param> /// <param name="title">对话框标题</param> /// <param name="icon">对话框图标</param> /// <param name="okScriptstring">点击确定按钮执行的客户端脚本</param> /// <param name="cancelScript">点击取消按钮执行的客户端脚本</param> /// <param name="target">弹出对话框的目标页面</param> /// <returns>客户端脚本</returns> public static string GetShowReference(string message, string title, MessageBoxIcon icon, string okScriptstring, string cancelScript, Target target) { //string msgBoxScript = "var msgBox=Ext.MessageBox;"; //msgBoxScript += "if(parent!=window){msgBox=parent.window.Ext.MessageBox;}"; if (String.IsNullOrEmpty(title)) { title = "X.util.confirmTitle"; } else { title = JsHelper.GetJsString(title.Replace("\r\n", "\n").Replace("\n", "<br/>")); } message = message.Replace("\r\n", "\n").Replace("\n", "<br/>"); JsObjectBuilder ob = new JsObjectBuilder(); ob.AddProperty("title", title, true); ob.AddProperty("msg", JsHelper.GetJsStringWithScriptTag(message), true); ob.AddProperty("buttons", "Ext.MessageBox.OKCANCEL", true); ob.AddProperty("icon", String.Format("{0}", MessageBoxIconHelper.GetName(icon)), true); ob.AddProperty("fn", String.Format("function(btn){{if(btn=='cancel'){{{0}}}else{{{1}}}}}", cancelScript, okScriptstring), true); string targetName = "window"; if (target != Target.Self) { targetName = TargetHelper.GetScriptName(target); } return String.Format("{0}.Ext.MessageBox.show({1});", targetName, ob.ToString()); }
public static void Handle(string timestamp, string data, ParserState state) { data = data.Trim(); var match = Regexes.OptionsEntityRegex.Match(data); if(match.Success) { var id = match.Groups[1].Value; state.Options = new Options {Id = int.Parse(id), OptionList = new List<Option>(), TimeStamp = timestamp}; state.UpdateCurrentNode(typeof(Game)); if(state.Node.Type == typeof(Game)) ((Game)state.Node.Object).Data.Add(state.Options); else throw new Exception("Invalid node " + state.Node.Type + " -- " + data); return; } match = Regexes.OptionsOptionRegex.Match(data); if(match.Success) { var index = match.Groups[1].Value; var rawType = match.Groups[2].Value; var rawEntity = match.Groups[3].Value; var entity = Helper.ParseEntity(rawEntity, state); var type = Helper.ParseEnum<OptionType>(rawType); var option = new Option {Entity = entity, Index = int.Parse(index), Type = type, OptionItems = new List<OptionItem>()}; state.Options.OptionList.Add(option); state.CurrentOption = option; state.LastOption = option; return; } match = Regexes.OptionsSuboptionRegex.Match(data); if(match.Success) { var subOptionType = match.Groups[1].Value; var index = match.Groups[2].Value; var rawEntity = match.Groups[3].Value; var entity = Helper.ParseEntity(rawEntity, state); if(subOptionType == "subOption") { var subOption = new SubOption {Entity = entity, Index = int.Parse(index), Targets = new List<Target>()}; state.CurrentOption.OptionItems.Add(subOption); state.LastOption = subOption; } else if(subOptionType == "target") { var target = new Target {Entity = entity, Index = int.Parse(index)}; var lastOption = state.LastOption as Option; if(lastOption != null) { lastOption.OptionItems.Add(target); return; } var lastSubOption = state.LastOption as SubOption; if(lastSubOption != null) lastSubOption.Targets.Add(target); } else throw new Exception("Unexpected suboption type: " + subOptionType); } }
/// <summary> /// Initializes a new instance of the <see cref="BufferingTargetWrapper" /> class. /// </summary> /// <param name="wrappedTarget">The wrapped target.</param> /// <param name="bufferSize">Size of the buffer.</param> /// <param name="flushTimeout">The flush timeout.</param> public BufferingTargetWrapper(Target wrappedTarget, int bufferSize, int flushTimeout) { WrappedTarget = wrappedTarget; BufferSize = bufferSize; FlushTimeout = flushTimeout; SlidingTimeout = true; }
/// <summary> /// Configures NLog for to log to the specified target so that all messages /// above and including the specified level are output. /// </summary> /// <param name="target">The target to log all messages to.</param> /// <param name="minLevel">The minimal logging level.</param> public static void ConfigureForTargetLogging(Target target, LogLevel minLevel) { LoggingConfiguration config = new LoggingConfiguration(); LoggingRule rule = new LoggingRule("*", minLevel, target); config.LoggingRules.Add(rule); LogManager.Configuration = config; }
private void OnHit(HitEffectList effects, Target target, Collider other) { if (this.isDead) return; if (other != null) Debug.Log(this.name + " was hit by collider on " + other.name); foreach (HitEffect effect in effects) { if (effect.name == "Damage") { this.life -= (int)effect.value; } } if (this.life <= 0) { this.isDead = true; Instantiate ( this.explosion.gameObject, this.transform.position, this.transform.rotation ); this.gameObject.SetActive(false); } }
public void Clearing_Items_Should_Clear_Selection() { var items = new PerspexList<Item> { new Item(), new Item(), }; var target = new Target { Items = items, Template = this.Template(), }; target.ApplyTemplate(); target.SelectedIndex = 1; Assert.Equal(items[1], target.SelectedItem); Assert.Equal(1, target.SelectedIndex); target.Items = null; Assert.Equal(null, target.SelectedItem); Assert.Equal(-1, target.SelectedIndex); }
public string GetNextTargetPluralExpression(Target target) { var text = string.Empty; switch (target) { case Target.MeasureGroups: text = "measures"; break; case Target.Dimensions: text = "hierarchies"; break; case Target.Hierarchies: text = "levels"; break; case Target.Levels: text = "properties"; break; case Target.Tables: text = "columns"; break; default: break; } return text; }
/// <summary> /// Registers the specified target object under a given name. /// </summary> /// <param name="name">Name of the target.</param> /// <param name="target">The target object.</param> public void AddTarget(string name, Target target) { if (name == null) throw new ArgumentException("name", "Target name cannot be null"); InternalLogger.Debug("Registering target {0}: {1}", name, target.GetType().FullName); _targets[name.ToLower(CultureInfo.InvariantCulture)] = target; }
protected bool PlayerValid(Player localPlayer, Player enemy, Target target) { if (enemy == null) return false; if (enemy.Address == localPlayer.Address) return false; if (enemy.Index == localPlayer.Index) return false; if (!enemy.IsValid()) return false; if (target == Target.Allies && enemy.InTeam != localPlayer.InTeam) return false; if (target == Target.Enemies && enemy.InTeam == localPlayer.InTeam) return false; //if (!Geometry.PointSeesPoint(localPlayer.Vector2, enemy.Vector2, Player.FOV_DEGREE, localPlayer.Yaw)) // return false; //if (!enemy.IsVisible()) // return false; CSGOImplementation csgo = (CSGOImplementation)Program.GameImplementation; //if (!csgo.CurrentMap.IsVisible(localPlayer.Vector3 + Vector3.UnitZ * (enemy.Skeleton.Head.Z - enemy.Skeleton.LeftFoot.Z), enemy.Skeleton.Head)) // return false; //if(!enemy.IsSpotted) // return false; return true; }
public Target GetNewRandomTargetExcluding(Target excluded) { targets.Remove (excluded); Target t = GetNewRandomTarget (); targets.Add (excluded); return t; }
public static void SetUp(TestContext context) { _unitOfWork = new UnitOfWork(); _memberFactory = new MemberFactory(); _gomeeFactory = new GomeeFactory(); _targetFactory = new TargetFactory(); _targetDecorator = new TargetDecorator(_targetFactory, _unitOfWork.TargetRepository); _member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _gomee = _gomeeFactory.CreateGomee(_member); _target = _targetFactory.CreateGomeeTarget(_member, _gomee); using (var uow = new UnitOfWork()) { uow.MemberRepository.Add(_member); uow.GomeeRepository.Add(_gomee); uow.TargetRepository.Add(_target); uow.PersistAll(); _oldCount = uow.TargetRepository.Count(); } _targetDecorator.Remove(_unitOfWork.TargetRepository.Get(_target.Id)); _unitOfWork.PersistAll(); _newCount = _unitOfWork.TargetRepository.Count(); try { _loadedTarget = _unitOfWork.TargetRepository.Get(_target.Id); } catch (ArgumentException) { _loadedTarget = null; } }
protected override AimMethodResult OnGetAimPoint(CSGOImplementation csgo, Target target, AimBone bone, Vector2 screenM, float radius) { Vector2 least = Vector2.Zero; Player playerTmp = null; float leastDist = float.MaxValue; try { foreach (Player player in csgo.Players) { if (!PlayerValid(csgo.LocalPlayer, player, target)) continue; if (csgo.GetValue<YesNo>("aimSpottedOnly") == YesNo.Yes && !player.SeenBy(csgo.LocalPlayer)) continue; float multiplicator = this.GetFloatMultiplicator(); Vector2 head = AimAt(csgo, bone, player); if (!Geometry.PointInCircle(head, screenM, radius)) continue; float playerDist = Geometry.GetDistanceToPoint(player.Vector3, csgo.LocalPlayer.Vector3); if (playerDist < leastDist) { least = head; leastDist = playerDist; playerTmp = player; } } } catch { } return new AimMethodResult(playerTmp != null ? playerTmp.Index : 0, least); }
protected override AimMethodResult OnGetAimPoint(CSGOImplementation csgo, Target target, AimBone bone, Vector2 screenMid, float radius) { Vector2 least = Vector2.Zero; int index = -1; float leastDist = float.MaxValue, dist = 0f; Vector3 currentAngles = csgo.ViewAngles; Vector3 aimAngles = Vector3.Zero; for (int i = 0; i < csgo.Players.Length; i++) { if (csgo.Players[i] == null) continue; if (!csgo.LocalPlayer.SeenBy(csgo.Players[i]) && !csgo.Players[i].SeenBy(csgo.LocalPlayer)) continue; aimAngles = Geometry.CalcAngle(csgo.LocalPlayer.Vector3 + csgo.ViewOffset, csgo.Players[i].Skeleton.GetBone(bone)); aimAngles -= currentAngles; dist = aimAngles.Length(); if(dist < leastDist) { leastDist = dist; index = csgo.Players[i].Index; } } return new AimMethodResult(index, least); }
/// <summary> /// Fires the delegate without any need to call EndInvoke. /// </summary> /// <param name="d">Target Delegate - must contain only one Target method</param> /// <param name="args">Users arguments.</param> public static void FireAndForget(Delegate d, params object[] args) { Target target = new Target(d, args); ThreadPool.QueueUserWorkItem(new WaitCallback(target.ExecuteDelegate)); }
public static void Write(Target target, string message, params object[] args) { if (!DebugVerbose) return; WriteInternal(message, args, target, null); }
protected override IDiscoveryCommandBuilder InstantiateBuilder(Target target, TargetType type) { if (type != TargetType.Object) throw new ArgumentOutOfRangeException(); switch (target) { case Target.Perspectives: return new PerspectiveDiscoveryCommandBuilder(); case Target.MeasureGroups: return new MeasureGroupDiscoveryCommandBuilder(); case Target.Measures: return new MeasureDiscoveryCommandBuilder(); case Target.Dimensions: return new DimensionDiscoveryCommandBuilder(); case Target.Hierarchies: return new HierarchyDiscoveryCommandBuilder(); case Target.Levels: return new LevelDiscoveryCommandBuilder(); case Target.Properties: return new PropertyDiscoveryCommandBuilder(); case Target.Tables: return new TableDiscoveryCommandBuilder(); case Target.Columns: return new ColumnDiscoveryCommandBuilder(); case Target.Sets: return new SetDiscoveryCommandBuilder(); default: throw new ArgumentOutOfRangeException(); } }
public JoinVoiceMessage(Target target) { if (target == null) throw new ArgumentNullException ("target"); Target = target; }
private static void TestCompletionCore( bool expectedIsCompletedSynchronously, Action<AsyncResult> test, Action<AsyncResult> assertion ) { using ( var waitHandle = new ManualResetEventSlim() ) { object owner = new object(); var target = new Target( owner, null, null ); using ( var task = Task.Factory.StartNew( () => { test( target ); } ) ) { target.WaitForCompletion(); Assert.That( target.IsCompleted, Is.True ); Assert.That( target.IsFinished, Is.False ); Assert.That( ( target as IAsyncResult ).CompletedSynchronously, Is.EqualTo( expectedIsCompletedSynchronously ) ); // NOTE: Invocation of AsyncCallback is derived class responsibility. if ( assertion != null ) { assertion( target ); } task.Wait( 10 ); } } }
protected override void OnUnitDestroyedHandler(Target obj) { PlayerHealth.Instance.RemoveOneHealth(); (SoldierGeneral as PlayerGeneral).ResurrectPlayer(); base.OnUnitDestroyedHandler(obj); }
public void ManualMapGeneralTest() { ManualMap<Source, Target> map = ManualMap<Source, Target>.New .AddMap(a => a.Source1, b => b.Target1) .AddMap(a => a.Source2, b => b.Target2) .AddMap(a => a.Source3, b => b.Target3) .AddMap(a => a.Source4, b => b.Target4) .AddMap(a => a.Source5, b => b.Target5); Guid guid = Guid.NewGuid(); Source source = new Source(1, "as", null, guid, 2); Target target = new Target(); Assert.That(target.Target1, Is.EqualTo(default(int))); Assert.That(target.Target2, Is.EqualTo(default(string))); Assert.That(target.Target3, Is.EqualTo(default(object))); Assert.That(target.Target4, Is.EqualTo(default(Guid))); Assert.That(target.Target5, Is.EqualTo(default(int))); target = source.Map(map); Assert.That(target.Target1, Is.EqualTo(source.Source1)); Assert.That(target.Target2, Is.EqualTo(source.Source2)); Assert.That(target.Target3, Is.EqualTo(source.Source3)); Assert.That(target.Target4, Is.EqualTo(source.Source4)); Assert.That(target.Target5, Is.EqualTo(source.Source5)); }
protected void OnHit(EventInfoList infoList, Target target) { if (this.isDead) return; foreach (EventInfo info in infoList) { switch (info.name) { case "Damage": this.life -= (int)info.value; break; } } if (this.life <= 0) { this.isDead = true; Instantiate ( this.explosion.gameObject, this.transform.position, this.transform.rotation ); this.gameObject.SetActive(false); } }
public static void SetNLogTarget(Target target, LogLevel minLevel = null) { if (target != null) { SimpleConfigurator.ConfigureForTargetLogging(target, minLevel ?? LogLevel.Info); } }
public void use_is_empty() { var doc1 = Target.Random(false); var doc2 = Target.Random(true); var doc3 = Target.Random(false); var doc4 = Target.Random(true); var empties = new Target[] {doc1, doc3}.OrderBy(x => x.Id).Select(x => x.Id).ToArray(); using (var session = theStore.OpenSession()) { session.Store(doc1, doc2, doc3, doc4); session.SaveChanges(); } using (var query = theStore.QuerySession()) { query.Query<Target>().Where(x => x.Children.IsEmpty()) .OrderBy(x => x.Id).Select(x => x.Id) .ToList() .ShouldHaveTheSameElementsAs(empties); } }
public WrapperTarget(Target wrappedTarget) { WrappedTarget = wrappedTarget; if (HostingEnvironment.IsHosted) HostingEnvironment.RegisterObject(this); }
/// <summary> /// Gets the image alignment for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image alignment style.</returns> public override PaletteRectangleAlign GetContentLongTextImageAlign(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentLongTextImageAlign(state) ?? Target.GetContentLongTextImageAlign(style, state)); }
/// <summary>Creates setup benchmark action.</summary> /// <param name="target">Target info.</param> /// <param name="instance">Instance of target.</param> /// <returns>Setup benchmark action.</returns> public static BenchmarkAction CreateSetup(Target target, object instance) => CreateCore(instance, target.SetupMethod, FallbackSignature, BenchmarkActionCodegen.DelegateCombine, 1);
/// <summary>Creates idle benchmark action.</summary> /// <param name="target">Target info.</param> /// <param name="instance">Instance of target.</param> /// <param name="codegenMode">Describes how benchmark action code is generated.</param> /// <param name="unrollFactor">Unroll factor.</param> /// <returns>Idle benchmark action.</returns> public static BenchmarkAction CreateIdle(Target target, object instance, BenchmarkActionCodegen codegenMode, int unrollFactor) => CreateCore(instance, null, target.Method, codegenMode, unrollFactor);
public ScheduledRenewal Find(Target target) { return(Renewals.Where(r => string.Equals(r.Binding.Host, target.Host)).FirstOrDefault()); }
protected override IEnumerable <Block> GetNeighborsOrdered(Block block) { return(GetNeighbors(block).OrderBy(n => Target.MinDistance(block))); }
/// <summary> /// Gets the padding between adjacent content items. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Integer value.</returns> public override int GetContentAdjacentGap(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentAdjacentGap(state) ?? Target.GetContentAdjacentGap(style, state)); }
/// <summary> /// Gets the padding between the border and content drawing. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Padding value.</returns> public override Padding GetContentPadding(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentPadding(state) ?? Target.GetContentPadding(style, state)); }
/// <summary> /// Gets the horizontal relative alignment of multiline long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentLongTextMultiLineH(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentLongTextMultiLineH(state) ?? Target.GetContentLongTextMultiLineH(style, state)); }
/// <summary> /// Gets the flag indicating if multiline text is allowed for long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetContentLongTextMultiLine(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentLongTextMultiLine(state) ?? Target.GetContentLongTextMultiLine(style, state)); }
/// <summary> /// Gets the background image style for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image style value.</returns> public override PaletteImageStyle GetContentLongTextImageStyle(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentLongTextImageStyle(state) ?? Target.GetContentLongTextImageStyle(style, state)); }
/// <summary> /// Gets the vertical relative alignment of the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentShortTextV(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentShortTextV(state) ?? Target.GetContentShortTextV(style, state)); }
/// <summary> /// Gets the prefix drawing setting for long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteTextPrefix value.</returns> public override PaletteTextHotkeyPrefix GetContentLongTextPrefix(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentLongTextPrefix(state) ?? Target.GetContentLongTextPrefix(style, state)); }
/// <summary> /// Gets a value indicating if content should be drawn with focus indication. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetContentDrawFocus(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentDrawFocus(state) ?? Target.GetContentDrawFocus(style, state)); }
/// <summary> /// Gets the color background angle for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Angle used for color drawing.</returns> public override float GetContentShortTextColorAngle(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentShortTextColorAngle(state) ?? Target.GetContentShortTextColorAngle(style, state)); }
public void Tick(Squad owner) { if (!owner.IsValid) { return; } if (!owner.IsTargetValid) { var closestEnemy = FindClosestEnemy(owner); if (closestEnemy != null) { owner.TargetActor = closestEnemy; } else { owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsFleeState(), true); return; } } var leader = owner.Units.ClosestTo(owner.TargetActor.CenterPosition); if (leader == null) { return; } var ownUnits = owner.World.FindActorsInCircle(leader.CenterPosition, WDist.FromCells(owner.Units.Count) / 3) .Where(a => a.Owner == owner.Units.First().Owner&& owner.Units.Contains(a)).ToHashSet(); if (ownUnits.Count < owner.Units.Count) { // Since units have different movement speeds, they get separated while approaching the target. // Let them regroup into tighter formation. owner.Bot.QueueOrder(new Order("Stop", leader, false)); foreach (var unit in owner.Units.Where(a => !ownUnits.Contains(a))) { owner.Bot.QueueOrder(new Order("AttackMove", unit, Target.FromCell(owner.World, leader.Location), false)); } } else { var enemies = owner.World.FindActorsInCircle(leader.CenterPosition, WDist.FromCells(12)) .Where(a => !a.IsDead && leader.Owner.Stances[a.Owner] == Stance.Enemy && a.Info.HasTraitInfo <ITargetableInfo>()); var target = enemies.ClosestTo(leader.CenterPosition); if (target != null) { owner.TargetActor = target; owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsAttackState(), true); } else { foreach (var a in owner.Units) { owner.Bot.QueueOrder(new Order("AttackMove", a, Target.FromCell(owner.World, owner.TargetActor.Location), false)); } } } if (ShouldFlee(owner)) { owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsFleeState(), true); } }
/// <summary> /// Gets the text trimming to use for short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteTextTrim value.</returns> public override PaletteTextTrim GetContentShortTextTrim(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentShortTextTrim(state) ?? Target.GetContentShortTextTrim(style, state)); }
internal VersionToken(VersionProvider provider, Target target, long number) { _provider = provider; _target = target; _number = number; }
private void OnUpdate() { var Impale = Main.Impale; if (Menu.ImpaleRadiusItem && Impale.Ability.Level > 0) { Context.Particle.DrawRange( Owner, "Impale", Impale.CastRange, Impale.IsReady ? Color.Aqua : Color.Gray); } else { Context.Particle.Remove("Impale"); } var ManaBurn = Main.ManaBurn; if (Menu.ManaBurnRadiusItem && ManaBurn.Ability.Level > 0) { Context.Particle.DrawRange( Owner, "ManaBurn", ManaBurn.CastRange, ManaBurn.IsReady ? Color.Aqua : Color.Gray); } else { Context.Particle.Remove("ManaBurn"); } var Blink = Main.Blink; if (Menu.BlinkRadiusItem && Blink != null) { var color = Color.Red; if (!Blink.IsReady) { color = Color.Gray; } else if (Impale.CanBeCasted) { color = Color.Aqua; } Context.Particle.DrawRange( Owner, "Blink", Blink.CastRange, color); } else { Context.Particle.Remove("Blink"); } if (Menu.TargetItem.Value.SelectedValue.Contains("Lock") && Context.TargetSelector.IsActive && ((!Menu.ComboKeyItem && !Menu.MaxStunKeyItem) || Target == null || !Target.IsValid || !Target.IsAlive)) { Target = Context.TargetSelector.Active.GetTargets().FirstOrDefault() as Hero; } else if (Menu.TargetItem.Value.SelectedValue.Contains("Default") && Context.TargetSelector.IsActive) { Target = Context.TargetSelector.Active.GetTargets().FirstOrDefault() as Hero; } if (Target != null) { var otherTarget = EntityManager <Hero> .Entities.Where(x => x.IsValid && x.IsVisible && x.IsAlive && !x.IsIllusion && x != Target && x.Distance2D(Target) < Impale.Range - 100 && x.IsEnemy(Owner)).OrderBy(x => Target.Distance2D(x)).FirstOrDefault(); BlinkPos = Vector3.Zero; ImpalePos = Vector3.Zero; if (otherTarget != null) { var input = new PredictionInput { Owner = Owner, AreaOfEffect = false, CollisionTypes = CollisionTypes.None, Delay = Impale.CastPoint + Impale.ActivationDelay, Speed = float.MaxValue, Range = 0, Radius = 0, PredictionSkillshotType = PredictionSkillshotType.SkillshotCircle }; var predictionInput = input.WithTarget(Target); var OutputPrediction = Prediction.GetPrediction(predictionInput); var blinkTargetPos = OutputPrediction.CastPosition.Extend(OutputPrediction.CastPosition, Owner.Distance2D(OutputPrediction.CastPosition)); var Output = Impale.GetPredictionOutput(Impale.GetPredictionInput(otherTarget)); BlinkPos = Output.CastPosition.Extend(blinkTargetPos, Output.CastPosition.Distance2D(Target.Position) + 100); var impaleTargetPos = Output.CastPosition.Extend(Output.CastPosition, Owner.Distance2D(Output.CastPosition)); ImpalePos = Target.Position.Extend(impaleTargetPos, Math.Min(Target.Distance2D(Output.CastPosition), Impale.Range - 100)); if (Menu.ImpaleLineItem) { Context.Particle.AddOrUpdate( Owner, "Line", "materials/ensage_ui/particles/line.vpcf", ParticleAttachment.AbsOrigin, RestartType.None, 1, BlinkPos, 2, ImpalePos, 3, new Vector3(255, 30, 0), 4, Color.Red); CircleParticle("BlinkCast", BlinkPos, true); CircleParticle("ImpaleCast", ImpalePos, true); } else { Remover(); } } else { Remover(); } } else { Remover(); } var comboKey = Menu.ComboKeyItem || Menu.MaxStunKeyItem; if (Target != null && (Menu.DrawOffTargetItem && !comboKey || Menu.DrawTargetItem && comboKey)) { switch (Menu.TargetEffectTypeItem.Value.SelectedIndex) { case 0: Context.Particle.DrawTargetLine( Owner, "NyxAssassinPlusTarget", Target.Position, comboKey ? new Color(Menu.TargetRedItem, Menu.TargetGreenItem, Menu.TargetBlueItem) : new Color(Menu.OffTargetRedItem, Menu.OffTargetGreenItem, Menu.OffTargetBlueItem)); break; case 1: Context.Particle.DrawDangerLine( Owner, "NyxAssassinPlusTarget", Target.Position, comboKey ? new Color(Menu.TargetRedItem, Menu.TargetGreenItem, Menu.TargetBlueItem) : new Color(Menu.OffTargetRedItem, Menu.OffTargetGreenItem, Menu.OffTargetBlueItem)); break; default: Context.Particle.AddOrUpdate( Target, "NyxAssassinPlusTarget", Menu.Effects[Menu.TargetEffectTypeItem.Value.SelectedIndex], ParticleAttachment.AbsOriginFollow, RestartType.NormalRestart, 1, comboKey ? new Color(Menu.TargetRedItem, Menu.TargetGreenItem, Menu.TargetBlueItem) : new Color(Menu.OffTargetRedItem, Menu.OffTargetGreenItem, Menu.OffTargetBlueItem), 2, new Vector3(255)); break; } } else { Context.Particle.Remove("NyxAssassinPlusTarget"); } if (Owner.HasAghanimsScepter()) { Menu.MaxStunKeyItem.Item.SetFontColor(new Color(163, 185, 176, 255)); } else { Menu.MaxStunKeyItem.Item.SetFontColor(Color.Black); } }
protected override void OnRuntimeEnable() { base.OnRuntimeEnable(); _referencePoolHelper = Target.GetType().GetField("_helper", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Target) as IReferencePoolHelper; }
/// <summary> /// Marks the current VersionToken as outdated /// </summary> public void Reset() { _target = null; _number = 0; }
private void ModifyTable(ICollection <Candidate> candidatesToAssign, Candidate candidate, Target target, DateTime requestTime, DateTime assignedTime, TimeSpan algoExecution, int algo, int maxLoad) { Data.Candidate modCandidate = _dataBusiness.GetCandidate(candidate.Id); modCandidate.TotalTravel += (int)candidate.DistanceToTarget; modCandidate.IsAssigned = true; modCandidate.Load++; Data.Target modTarget = _dataBusiness.GetTarget(target.Id); modTarget.LastRequest = requestTime; string transactionId = Guid.NewGuid().ToString(); Data.Transaction modTransaction = new Data.Transaction { TransactionId = transactionId, From = modTarget, To = modCandidate, RequestAt = requestTime, AssigneeAt = assignedTime, Distance = candidate.DistanceToTarget, AlgorithmExecutionTime = algoExecution, Algorithm = algo == 1 ? "Nearest Neighbor" : "Round Robin", Candidates = Newtonsoft.Json.JsonConvert.SerializeObject(candidatesToAssign), MaxLoad = maxLoad, }; _ = _dataBusiness.ModifyCandidate(modCandidate); _ = _dataBusiness.ModifyTarget(modTarget); _ = _dataBusiness.ModifyTransaction(modTransaction); // _ = _dataBusiness.CreateJsonFile($"Transaction_{transactionId}", candidatesToAssign); }
internal VersionToken(VersionProvider provider) { _number = 0; _target = null; _provider = provider; }
/// <summary> /// Gets the image alignment. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image alignment style.</returns> public override PaletteRectangleAlign GetBackImageAlign(PaletteBackStyle style, PaletteState state) { IPaletteBack inherit = GetInherit(state); return(inherit?.GetBackImageAlign(state) ?? Target.GetBackImageAlign(style, state)); }
/// <summary> /// Gets texture information from a texture descriptor. /// </summary> /// <param name="descriptor">The texture descriptor</param> /// <returns>The texture information</returns> private TextureInfo GetInfo(TextureDescriptor descriptor) { ulong address = Context.MemoryManager.Translate(descriptor.UnpackAddress()); int width = descriptor.UnpackWidth(); int height = descriptor.UnpackHeight(); int depthOrLayers = descriptor.UnpackDepth(); int levels = descriptor.UnpackLevels(); TextureMsaaMode msaaMode = descriptor.UnpackTextureMsaaMode(); int samplesInX = msaaMode.SamplesInX(); int samplesInY = msaaMode.SamplesInY(); int stride = descriptor.UnpackStride(); TextureDescriptorType descriptorType = descriptor.UnpackTextureDescriptorType(); bool isLinear = descriptorType == TextureDescriptorType.Linear; Target target = descriptor.UnpackTextureTarget().Convert((samplesInX | samplesInY) != 1); // We use 2D targets for 1D textures as that makes texture cache // management easier. We don't know the target for render target // and copies, so those would normally use 2D targets, which are // not compatible with 1D targets. By doing that we also allow those // to match when looking for compatible textures on the cache. if (target == Target.Texture1D) { target = Target.Texture2D; height = 1; } else if (target == Target.Texture1DArray) { target = Target.Texture2DArray; height = 1; } uint format = descriptor.UnpackFormat(); bool srgb = descriptor.UnpackSrgb(); if (!FormatTable.TryGetTextureFormat(format, srgb, out FormatInfo formatInfo)) { if ((long)address > 0L && (int)format > 0) { Logger.Error?.Print(LogClass.Gpu, $"Invalid texture format 0x{format:X} (sRGB: {srgb})."); } formatInfo = FormatInfo.Default; } int gobBlocksInY = descriptor.UnpackGobBlocksInY(); int gobBlocksInZ = descriptor.UnpackGobBlocksInZ(); int gobBlocksInTileX = descriptor.UnpackGobBlocksInTileX(); SwizzleComponent swizzleR = descriptor.UnpackSwizzleR().Convert(); SwizzleComponent swizzleG = descriptor.UnpackSwizzleG().Convert(); SwizzleComponent swizzleB = descriptor.UnpackSwizzleB().Convert(); SwizzleComponent swizzleA = descriptor.UnpackSwizzleA().Convert(); DepthStencilMode depthStencilMode = GetDepthStencilMode( formatInfo.Format, swizzleR, swizzleG, swizzleB, swizzleA); if (formatInfo.Format.IsDepthOrStencil()) { swizzleR = SwizzleComponent.Red; swizzleG = SwizzleComponent.Red; swizzleB = SwizzleComponent.Red; if (depthStencilMode == DepthStencilMode.Depth) { swizzleA = SwizzleComponent.One; } else { swizzleA = SwizzleComponent.Red; } } return(new TextureInfo( address, width, height, depthOrLayers, levels, samplesInX, samplesInY, stride, isLinear, gobBlocksInY, gobBlocksInZ, gobBlocksInTileX, target, formatInfo, depthStencilMode, swizzleR, swizzleG, swizzleB, swizzleA)); }
/// <summary> /// Gets the color background angle. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Angle used for color drawing.</returns> public override float GetBackColorAngle(PaletteBackStyle style, PaletteState state) { IPaletteBack inherit = GetInherit(state); return(inherit?.GetBackColorAngle(state) ?? Target.GetBackColorAngle(style, state)); }
public void SendAirstrike(Actor self, WPos target, bool randomize = true, int attackFacing = 0) { var info = Info as AirstrikePowerInfo; if (randomize) { attackFacing = 256 * self.World.SharedRandom.Next(info.QuantizedFacings) / info.QuantizedFacings; } var altitude = self.World.Map.Rules.Actors[info.UnitType].TraitInfo <AircraftInfo>().CruiseAltitude.Length; var attackRotation = WRot.FromFacing(attackFacing); var delta = new WVec(0, -1024, 0).Rotate(attackRotation); target = target + new WVec(0, 0, altitude); var startEdge = target - (self.World.Map.DistanceToEdge(target, -delta) + info.Cordon).Length * delta / 1024; var finishEdge = target + (self.World.Map.DistanceToEdge(target, delta) + info.Cordon).Length * delta / 1024; Actor camera = null; Beacon beacon = null; var aircraftInRange = new Dictionary <Actor, bool>(); Action <Actor> onEnterRange = a => { // Spawn a camera and remove the beacon when the first plane enters the target area if (info.CameraActor != null && !aircraftInRange.Any(kv => kv.Value)) { self.World.AddFrameEndTask(w => { camera = w.CreateActor(info.CameraActor, new TypeDictionary { new LocationInit(self.World.Map.CellContaining(target)), new OwnerInit(self.Owner), }); }); } if (beacon != null) { self.World.AddFrameEndTask(w => { w.Remove(beacon); beacon = null; }); } aircraftInRange[a] = true; }; Action <Actor> onExitRange = a => { aircraftInRange[a] = false; // Remove the camera when the final plane leaves the target area if (!aircraftInRange.Any(kv => kv.Value)) { if (camera != null) { camera.QueueActivity(new Wait(info.CameraRemoveDelay)); camera.QueueActivity(new RemoveSelf()); } camera = null; if (beacon != null) { self.World.AddFrameEndTask(w => { w.Remove(beacon); beacon = null; }); } } }; self.World.AddFrameEndTask(w => { var notification = self.Owner.IsAlliedWith(self.World.RenderPlayer) ? Info.LaunchSound : Info.IncomingSound; Game.Sound.Play(notification); Actor distanceTestActor = null; for (var i = -info.SquadSize / 2; i <= info.SquadSize / 2; i++) { // Even-sized squads skip the lead plane if (i == 0 && (info.SquadSize & 1) == 0) { continue; } // Includes the 90 degree rotation between body and world coordinates var so = info.SquadOffset; var spawnOffset = new WVec(i * so.Y, -Math.Abs(i) * so.X, 0).Rotate(attackRotation); var targetOffset = new WVec(i * so.Y, 0, 0).Rotate(attackRotation); var a = w.CreateActor(info.UnitType, new TypeDictionary { new CenterPositionInit(startEdge + spawnOffset), new OwnerInit(self.Owner), new FacingInit(attackFacing), }); var attack = a.Trait <AttackBomber>(); attack.SetTarget(w, target + targetOffset); attack.OnEnteredAttackRange += onEnterRange; attack.OnExitedAttackRange += onExitRange; attack.OnRemovedFromWorld += onExitRange; a.QueueActivity(new Fly(a, Target.FromPos(target + spawnOffset))); a.QueueActivity(new Fly(a, Target.FromPos(finishEdge + spawnOffset))); a.QueueActivity(new RemoveSelf()); aircraftInRange.Add(a, false); distanceTestActor = a; } if (Info.DisplayBeacon) { var distance = (target - startEdge).HorizontalLength; beacon = new Beacon( self.Owner, target - new WVec(0, 0, altitude), Info.BeaconPaletteIsPlayerPalette, Info.BeaconPalette, Info.BeaconImage, Info.BeaconPoster, Info.BeaconPosterPalette, Info.ArrowSequence, Info.CircleSequence, Info.ClockSequence, () => 1 - ((distanceTestActor.CenterPosition - target).HorizontalLength - info.BeaconDistanceOffset.Length) * 1f / distance); w.Add(beacon); } }); }
/// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteBackStyle style, PaletteState state) { IPaletteBack inherit = GetInherit(state); return(inherit?.GetBackDraw(state) ?? Target.GetBackDraw(style, state)); }
/// <summary> /// Gets the background image style. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image style value.</returns> public override PaletteImageStyle GetBackImageStyle(PaletteBackStyle style, PaletteState state) { IPaletteBack inherit = GetInherit(state); return(inherit?.GetBackImageStyle(state) ?? Target.GetBackImageStyle(style, state)); }
//Allow possible customization. public TyphoonKick(string name, byte level, byte gauge, float potency, Target target) : base(name, level, gauge, potency, target) { }
/// <summary> /// Gets the graphics drawing hint for the background. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteGraphicsHint value.</returns> public override PaletteGraphicsHint GetBackGraphicsHint(PaletteBackStyle style, PaletteState state) { IPaletteBack inherit = GetInherit(state); return(inherit?.GetBackGraphicsHint(state) ?? Target.GetBackGraphicsHint(style, state)); }