public BooleanDsdlType(CastMode castMode) : base(1, castMode) { if (castMode != CastMode.Saturated) { throw new ArgumentException("Invalid cast mode for boolean.", nameof(CastMode)); } }
void CastW(Obj_AI_Base target, CastMode mode) { if (target.IsDead || mode != CastMode.Killsteal && !Orbwalking.CanMove(0.5f)) { return; } switch (mode) { case CastMode.Combo: W.CastIfHigherThen(target, Menu.GetList("HitChance.Combo.W").ToHitChance()); break; case CastMode.Harass: W.CastIfHigherThen(target, Menu.GetList("HitChance.Harass.W").ToHitChance()); break; case CastMode.Farm: PredictionOutput value = W.GetPrediction(target); if (value.Hitchance != HitChance.Collision && value.Hitchance != HitChance.OutOfRange && value.CastPosition != Vector3.Zero) { W.Cast(value.CastPosition); } break; } }
public UIntDsdlType(int bitlen, CastMode castMode) : base(bitlen, castMode) { if (!ValidateBitlen(bitlen)) { throw new ArgumentException($"Invalid bit length: {bitlen}.", nameof(bitlen)); } }
public bool Use(OldContext context) { if (!Usable(context)) { return(false); } this.context = context; context.ability = this; SetComponentContext(context); OnUse(); if (castState == CastState.Invalid) { if (castMode == CastMode.Channel) { float actualChannelTime = channelTime.Value; castTimer.Reset(actualChannelTime); channelTimer.Reset(actualChannelTime / channelTicks.Value); } else { float actualCastTime = castTime.Value; castTimer.Reset(actualCastTime); actualCastMode = (actualCastTime <= 0f) ? CastMode.Instant : castMode; } castState = CastState.Casting; OnCastStarted(); } return(true); }
public IntDsdlType(int bitlen, CastMode castMode) : base(bitlen, castMode) { if (!ValidateBitlen(bitlen)) { throw new ArgumentException($"Invalid bit length: {bitlen}.", nameof(bitlen)); } if (castMode != CastMode.Saturated) { throw new ArgumentException("Invalid cast mode for signed integer.", nameof(CastMode)); } }
public Ability(string id) { Id = id; nextCharge = 0; charges = new Charge[1] { new Charge() }; tags = new TagCollection(); components = new List <AbilityComponent>(); requirements = new List <AbilityRequirement>(); castTime = new FloatRange(1f); castMode = CastMode.Cast; channelTicks = new IntRange(3); channelTime = new FloatRange(3f); castTimer = new Timer(); channelTimer = new Timer(); contextType = contextType ?? typeof(Context); }
public Ability(string id) { Id = id; nextCharge = 0; charges = new Charge[1] { new Charge() }; tags = new TagCollection(); // attributes = new Dictionary<string, object>(); components = new List <AbilityComponent>(); requirements = new List <AbilityRequirement>(); castTime = new FloatRange(1f); castMode = CastMode.Cast; channelTicks = new IntRange(3); channelTime = new FloatRange(3f); castTimer = new Timer(); channelTimer = new Timer(); }
void CastE(Obj_AI_Base target, CastMode mode) { if (E.IsReady() && E.IsInRange(target)) { switch (mode) { case CastMode.Combo: E.CastIfHigherThen(target, Config.GetList("HitChance.Combo.E").ToHitChance()); break; case CastMode.Harass: E.CastIfHigherThen(target, Config.GetList("HitChance.Harass.E").ToHitChance()); break; default: E.CastIfHigherThen(target, HitChance.Low); break; } } }
public SumPipe(Node[] children, Dictionary <string, object> options) : base(children.First().XType, children.First().YType, children) { if (children.Select(c => c.XType).Distinct().Count() > 1) { throw new ArgumentException("All children must have the same X type."); } if (!typeof(IComparable).IsAssignableFrom(children.First().XType)) { throw new ArgumentException($"The X type must implement {nameof(IComparable)}"); } if (children.Select(c => c.YType).Except(new [] { typeof(int), typeof(float), typeof(double) }).Count() > 0) { throw new ArgumentException("All children must have a numerical Y type."); } if (children.Any(c => c.YType == typeof(double))) { Mode = CastMode.Double; } else if (children.Any(c => c.YType == typeof(float))) { Mode = CastMode.Float; } else { Mode = CastMode.Int; } YType = Mode switch { CastMode.Double => typeof(double), CastMode.Float => typeof(float), CastMode.Int or _ => typeof(int), }; }
public bool Use(Context context) { if (!contextType.IsAssignableFrom(context.GetType())) { Debug.LogError("Ability `" + Id + "` expects a context type assignable to " + contextType.Name + ", but was used with: " + context.GetType().Name); } if (!Usable(context)) { return(false); } this.context = context; SetComponentContext(context); OnUse(); if (castState == CastState.Invalid) { if (castMode == CastMode.Channel) { float actualChannelTime = channelTime.Value; castTimer.Reset(actualChannelTime); channelTimer.Reset(actualChannelTime / channelTicks.Value); } else { float actualCastTime = castTime.Value; castTimer.Reset(actualCastTime); actualCastMode = (actualCastTime <= 0f) ? CastMode.Instant : castMode; } castState = CastState.Casting; OnCastStarted(); } return(true); }
private IEnumerator AutoTest() { CastMode[] castModes = new CastMode[]{ CastMode.Line, CastMode.Sphere }; ColliderMode[] colModes = new ColliderMode[] { ColliderMode.Box, ColliderMode.Sphere }; int[] colNums = new int[]{ 0, 1, 10, 50, 100, 500, 1000 }; string markdownTable = "|Cast mode|Col mode|Box nums|Sphere nums|IsHit|Total col|Total mesh|Hit mesh|Time|\n" + "|:-:|:-:|--:|--:|:-:|--:|--:|--:|--:|\n"; foreach (CastMode castMode in castModes) { foreach (ColliderMode colMode in colModes) { foreach (int boxNums in colNums) { foreach (int sphereNums in colNums) { cur.colMode = ColliderMode.Box; ClearCols (); yield return null; Enumerable.Range (0, boxNums).ToList ().ForEach (i => AddCol ()); cur.colMode = ColliderMode.Sphere; ClearCols (); yield return null; Enumerable.Range (0, sphereNums).ToList ().ForEach (i => AddCol ()); cur.colMode = colMode; cur.castMode = castMode; yield return null; TestCast (); Debug.Log (castMode + "," + colMode + "," + boxNums + "," + sphereNums); markdownTable += cur.toMarkdown() + "\n"; yield return null; } } } } Debug.Log (markdownTable); }
public static extern bool HP_UdpNode_StartWithCast(IntPtr pNode, string lpszBindAddress, ushort usPort, CastMode castMode, string lpszCastAddress);
public static extern void HP_UdpCast_SetCastMode(IntPtr pCast, CastMode enCastMode);
static DsdlType ParseType(string ns, string attrTypeName, CastMode castMode) { Match match; if ((match = _typeVoidRegex.Match(attrTypeName)).Success) { var size = int.Parse(match.Groups["SIZE"].Value); if (size < 1 || size > 64) { throw new Exception($"Invalid void bit length: {size}."); } return(new VoidDsdlType(size)); } else if ((match = _typeArrayRegex.Match(attrTypeName)).Success) { var size = match.Groups["SIZE"].Value; var name = match.Groups["NAME"].Value; var valueType = ParseType(ns, name, castMode); if (valueType is ArrayDsdlType) { throw new Exception("Multidimensional arrays are not allowed (protip: use nested types)."); } try { if (size.StartsWith("<=")) { return(new ArrayDsdlType(valueType, ArrayDsdlTypeMode.Dynamic, int.Parse(size.Substring(2)))); } else if (size.StartsWith("<")) { return(new ArrayDsdlType(valueType, ArrayDsdlTypeMode.Dynamic, int.Parse(size.Substring(1)) - 1)); } else { return(new ArrayDsdlType(valueType, ArrayDsdlTypeMode.Static, int.Parse(size))); } } catch (Exception ex) { throw new Exception($"Invalid array size specifier [{size}] (valid patterns: [<=X], [<X], [X]).", ex); } } else if (attrTypeName == "bool") { return(new BooleanDsdlType(castMode)); } else if ((match = _typePrimitiveRegex.Match(attrTypeName)).Success) { var size = int.Parse(match.Groups["SIZE"].Value); var name = match.Groups["NAME"].Value; switch (name) { case "uint": return(new UIntDsdlType(size, castMode)); case "int": return(new IntDsdlType(size, castMode)); case "float": return(new FloatDsdlType(size, castMode)); } } if (castMode != CastMode.Saturated) { throw new Exception("Cast mode specifier is not applicable for compound types."); } return(new DsdlTypeReference(ns, attrTypeName)); }
protected PrimitiveDsdlType(int bitlen, CastMode castMode) { _bitlen = bitlen; _castMode = castMode; }
/// <summary> /// 设置传播模式(组播或广播) /// </summary> /// <param name="mode"></param> public void SetCastMode(CastMode mode) { Sdk.HP_UdpCast_SetCastMode(pCast, mode); }
public CastModeAttribute(CastMode mode) { Mode = mode; }