public NativeFieldInfo(TargetType type, string name, int index, bool has_const_value, int const_value) : base(type, name, index, false, TargetMemberAccessibility.Public, 0, 0, has_const_value) { this.const_value = const_value; }
public Network WithDest(string dest) { _destType = GetTargetType(dest); _dest = dest; return this; }
public Item(string name, string desc, ItemType type, TargetType targetType) { _name = name; _desc = desc; _type = type; _targetType = targetType; }
public static Obj_AI_Hero GetBestTarget(TargetType type, float range) { var List = HeroManager.Enemies.Where(x => !x.IsDead && x.Distance(Player.Position) <= range); if (type == TargetType.LowestHealth) { return List.OrderBy(x => x.Health).FirstOrDefault(); } if (type == TargetType.MaxHealth) { return List.OrderBy(x => x.MaxHealth).FirstOrDefault(); } if (type == TargetType.BestDamage) { return List.OrderBy(x => x.TotalMagicalDamage + x.TotalAttackDamage ).LastOrDefault(); } if (type == TargetType.Closest) { return List.OrderBy(x => x.Distance(Player.Position)).FirstOrDefault(); } if (type == TargetType.Tankiest) { return List.OrderBy(x => x.Armor + x.FlatMagicReduction).FirstOrDefault(); } if (type == TargetType.MostHealth) { return List.OrderBy(x => x.Health).LastOrDefault(); } else return TargetSelector.GetTarget(range, TargetSelector.DamageType.Physical); }
public void Initialize (Transform targ, TargetType targType, float maxTTL, float expRadius, float dmg ) { target = targ; targetType = targType; maxTimeToLive = maxTTL; explosionRadius = expRadius; damage = dmg; }
public TargetAuraMaxTimeLeftCondition(TargetType target, int auraId, WoWGuid creatorGuid, TimeSpan maxTimeLeft) { Target = target; AuraId = auraId; CreatorGuid = creatorGuid; MaxTimeLeft = maxTimeLeft; }
public TargetAuraMinTimeLeftCondition(TargetType target, int auraId, TimeSpan minTimeLeft) { Target = target; AuraId = auraId; CreatorGuid = StyxWoW.Me.Guid; MinTimeLeft = minTimeLeft; }
public Target(String name, TargetType type, DynamicState dynamicState, int value) { Name = name; Type = type; DynamicState = dynamicState; Value = value; }
public static bool IsValidTarget(TargetType targetType, GameObject target, GameObject me) { Team targetTeam = target.GetComponent<Team>(); Team myTeam = me.GetComponent<Team>(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ switch (targetType) { case TargetType.Self: if(target == me) { return true; } break; case TargetType.Ally: if(myTeam.m_teamNumber == targetTeam.m_teamNumber) { return true; } break; case TargetType.Enemy: if(myTeam.m_teamNumber != targetTeam.m_teamNumber) { return true; } break; case TargetType.All: return true; default: return false; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return false; }
public void PropertySetPreservedAndSourceNotModified() { const string ValueFoo = "hello"; var valueBar = new DateTime(2013, 12, 1, 23, 0, 0); var valueBaz = new object(); var valueFuu = new TargetType(); dynamic source = new ExpandoObject(); source.Foo = ValueFoo; source.Bar = valueBar; source.Baz = valueBaz; source.Fuu = valueFuu; dynamic result = ((object)source).ToExpando(); Assert.AreNotSame(source, result); Assert.AreEqual(source.Foo, result.Foo); Assert.AreEqual(source.Bar, result.Bar); Assert.AreEqual(source.Baz, result.Baz); Assert.AreEqual(source.Fuu, result.Fuu); Assert.AreEqual(ValueFoo, source.Foo); Assert.AreEqual(valueBar, source.Bar); Assert.AreEqual(valueBaz, source.Baz); Assert.AreEqual(valueFuu, source.Fuu); }
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 TargetHasAuraMinStacksCondition(TargetType target, int auraId, int minStackCount, WoWGuid creatorGuid) { Target = target; AuraId = auraId; MinStackCount = minStackCount; CreatorGuid = creatorGuid; }
public TargetHasAuraMinStacksCondition(TargetType target, int auraId, int minStackCount) { Target = target; AuraId = auraId; MinStackCount = minStackCount; CreatorGuid = StyxWoW.Me.Guid; }
/// <summary> /// 将分类类别转换为TreeNodes /// </summary> /// <param name="categoryService">扩展类:CategoryService</param> /// <param name="categories">要转换成节点分类集合</param> /// <param name="targetType">点击分类时打开新页还是在本页打开</param> /// <param name="idPrefix">节点ID前缀</param> /// <param name="checkedCategoryId">当前选中的CategoryId</param> /// <param name="openLevel">默认打开的层级</param> /// <returns>TreeNodes列表</returns> public static IList<TreeNode> CategoriesToTreeNodes(this CategoryService<Category> categoryService, IList<Category> categories, TargetType targetType, string idPrefix, long? checkedCategoryId, int? openLevel) { //本方法将分类转换成TreeNodes,其中,哪些节点展开还是闭合的逻辑较为复杂,如下: //关于哪些节点展开哪些节点闭合,逻辑实现如下: //1 首先,若checkedCategoryId有值,则这个分类的所有父级分类展开,其他分类全部折叠; //2 其次,若checkedCategoryId无值,openLevel有着,则深度小于等于openLevel的分类展开,其他分类折叠; //3 若若checkedCategoryId和openLevel都没有值,则所有分类折叠。 IList<TreeNode> nodes = new List<TreeNode>(); if (categories != null && categories.Count > 0) { //若当前有选中的分类,则获取其所有的父级分类Id集合 List<long> checkedCategoryIds = new List<long>(); if (checkedCategoryId.HasValue && checkedCategoryId.Value > 0) GetParentCategoryIDs(categoryService, checkedCategoryId.Value, checkedCategoryIds); //通过Category组装TreeNode foreach (Category category in categories) { TreeNode node = new TreeNode(); node.Id = idPrefix + category.CategoryId.ToString(); node.IsChecked = (checkedCategoryId == category.CategoryId); node.IsOpened = IsOpenedNode(category, checkedCategoryIds, openLevel); node.IsParent = category.ChildCount > 0; node.Name = category.CategoryName; node.ParentId = idPrefix + category.ParentId.ToString(); node.Target = targetType; node.Url = string.Empty; nodes.Add(node); } } return nodes; }
private static IList<WarMagicData> CreateAbnormalConditionMagic(MagicData magic, bool isChipEffect, IAbnormalCondition cond, TargetType targetType) { var name = magic.Name; var description = magic.Description; var cores = magic.Cores; var magicDatas = new List<WarMagicData>(cores.Length); foreach (var core in cores) { // 行為の範囲や対象を設定する IScope scope; if (core.Area != 0) scope = new DefaultScope(core.Range, core.Area, targetType); else scope = new WholeScope(targetType); // 画面効果を設定する var screenEffect = CreateScreenEffect(magic, isChipEffect); // 消費MPの設定 var consumption = new MPCost(core.MPCost); // 行為の設定 var action = new GiveAbnormalConditionAction(scope, consumption, screenEffect, cond); // 魔法データを作成する var magicData = new WarMagicData(name, description, action, core.MPCost, core.Area, core.Range); magicDatas.Add(magicData); } return magicDatas; }
public CMakeTarget(TargetType type, bool isImported) { Type = type; IMPORTED = isImported; sources = new HashSet<FileInfo>(); properties = new CMakeTargetPropertyCollection(); }
public TargetInfo(string name, string target, TargetType type, bool safe) { this.name = name; this.target = target; this.type = type; this.safe = safe; }
public MonoGenericInstanceType(MonoClassType container, TargetType[] type_args, TargetAddress class_ptr) : base(container.File.MonoLanguage) { this.Container = container; this.type_args = type_args; this.class_ptr = class_ptr; struct_type = new MonoStructType (container.File, this, container.Type); StringBuilder sb = new StringBuilder (container.BaseName); sb.Append ('<'); for (int i = 0; i < type_args.Length; i++) { if (i > 0) sb.Append (','); sb.Append (type_args [i].Name); } sb.Append ('>'); full_name = sb.ToString (); bool is_compiler_generated; DebuggerBrowsableState? browsable_state; MonoSymbolFile.CheckCustomAttributes (container.Type, out browsable_state, out debugger_display, out type_proxy, out is_compiler_generated); }
public MonoVariable(string name, TargetType type, bool is_local, bool is_byref, Method method, VariableInfo info, int start_scope_offset, int end_scope_offset) : this(name, type, is_local, is_byref, method, info) { if (is_local) { start_scope = method.StartAddress + start_scope_offset; end_scope = method.StartAddress + end_scope_offset; } else if (method.HasMethodBounds) { start_scope = method.MethodStartAddress; end_scope = method.MethodEndAddress; } else { start_scope = method.StartAddress; end_scope = method.EndAddress; } if (has_liveness_info) { if (start_liveness < start_scope) start_liveness = start_scope; if (end_liveness > end_scope) end_liveness = end_scope; } else { start_liveness = start_scope; end_liveness = end_scope; has_liveness_info = true; } }
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(); } }
private void clear() { targetType = TargetType.Type_Null; targetArrived = null; goTarget = null; }
public DtsTask(SourceType sourceType, string sourceName, TargetType targetType, ITarget target) { SourceType = sourceType; SourceName = sourceName; TargetType = targetType; Target = target; }
public ChainedAbility(IAbility ability, TargetType targetType, bool mustBeReady) { Instance = ability; TargetType = targetType; MustBeReady = mustBeReady; ClassType = Instance.GetType(); }
public MonoEnumInfo(MonoEnumType type, TargetType field_type, int index, int pos, Cecil.FieldDefinition finfo) : base(field_type, finfo.Name, index, finfo.IsStatic, MonoFieldInfo.GetAccessibility (finfo), pos, 0, finfo.HasConstant) { FieldInfo = finfo; }
public void Target(Vector3 pos, TargetArrived _delegate = null) { clear(); targetType = TargetType.Type_Position; posTarget = pos; radius = 0.1f; targetArrived = _delegate; }
public NativeFunctionType(Language language, string name, TargetType return_type, TargetType[] parameter_types) : base(language) { this.name = name; this.return_type = return_type; this.parameter_types = parameter_types; }
public NativeFieldInfo(TargetType type, string name, int index, int offset, int bit_offset, int bit_size) : this(type, name, index, offset) { this.bit_offset = bit_offset; this.bit_size = bit_size; this.is_bitfield = true; }
public ValueSpecification(int index, string metaName, bool required, Maybe<int> min, Maybe<int> max, Maybe<object> defaultValue, string helpText, string metaValue, IEnumerable<string> enumValues, Type conversionType, TargetType targetType) : base(SpecificationType.Value, required, min, max, defaultValue, helpText, metaValue, enumValues, conversionType, targetType) { this.index = index; this.metaName = metaName; }
public NativeArrayType(Language language, string name, TargetType element_type, TargetArrayBounds bounds, int size) : base(element_type, bounds.Rank) { this.name = name; this.size = size; this.bounds = bounds; }
public OptionSpecification(string shortName, string longName, bool required, string setName, Maybe<int> min, Maybe<int> max, char separator, Maybe<object> defaultValue, string helpText, string metaValue, IEnumerable<string> enumValues, Type conversionType, TargetType targetType) : base(SpecificationType.Option, required, min, max, defaultValue, helpText, metaValue, enumValues, conversionType, targetType) { this.shortName = shortName; this.longName = longName; this.separator = separator; this.setName = setName; }
// Used also by DOTweenAnimationInspector when applying runtime changes and restarting public void CreateTween() { if (target == null) { Debug.LogWarning(string.Format("{0} :: This tween's target is NULL, because the animation was created with a DOTween Pro version older than 0.9.255. To fix this, exit Play mode then simply select this object, and it will update automatically", this.gameObject.name), this.gameObject); return; } if (forcedTargetType != TargetType.Unset) { targetType = forcedTargetType; } if (targetType == TargetType.Unset) { // Legacy DOTweenAnimation (made with a version older than 0.9.450) without stored targetType > assign it now targetType = TypeToDOTargetType(target.GetType()); } switch (animationType) { case DOTweenAnimationType.None: break; case DOTweenAnimationType.Move: if (useTargetAsV3) { isRelative = false; if (endValueTransform == null) { Debug.LogWarning(string.Format("{0} :: This tween's TO target is NULL, a Vector3 of (0,0,0) will be used instead", this.gameObject.name), this.gameObject); endValueV3 = Vector3.zero; } else { if (targetType == TargetType.RectTransform) { RectTransform endValueT = endValueTransform as RectTransform; if (endValueT == null) { Debug.LogWarning(string.Format("{0} :: This tween's TO target should be a RectTransform, a Vector3 of (0,0,0) will be used instead", this.gameObject.name), this.gameObject); endValueV3 = Vector3.zero; } else { RectTransform rTarget = target as RectTransform; if (rTarget == null) { Debug.LogWarning(string.Format("{0} :: This tween's target and TO target are not of the same type. Please reassign the values", this.gameObject.name), this.gameObject); } else { // Problem: doesn't work inside Awake (ararargh!) endValueV3 = DOTweenUtils46.SwitchToRectTransform(endValueT, rTarget); } } } else { endValueV3 = endValueTransform.position; } } } switch (targetType) { case TargetType.RectTransform: tween = ((RectTransform)target).DOAnchorPos3D(endValueV3, duration, optionalBool0); break; case TargetType.Transform: tween = ((Transform)target).DOMove(endValueV3, duration, optionalBool0); break; case TargetType.Rigidbody2D: tween = ((Rigidbody2D)target).DOMove(endValueV3, duration, optionalBool0); break; case TargetType.Rigidbody: tween = ((Rigidbody)target).DOMove(endValueV3, duration, optionalBool0); break; } break; case DOTweenAnimationType.LocalMove: tween = transform.DOLocalMove(endValueV3, duration, optionalBool0); break; case DOTweenAnimationType.Rotate: switch (targetType) { case TargetType.Transform: tween = ((Transform)target).DORotate(endValueV3, duration, optionalRotationMode); break; case TargetType.Rigidbody2D: tween = ((Rigidbody2D)target).DORotate(endValueFloat, duration); break; case TargetType.Rigidbody: tween = ((Rigidbody)target).DORotate(endValueV3, duration, optionalRotationMode); break; } break; case DOTweenAnimationType.LocalRotate: tween = transform.DOLocalRotate(endValueV3, duration, optionalRotationMode); break; case DOTweenAnimationType.Scale: switch (targetType) { #if DOTWEEN_TK2D case TargetType.tk2dTextMesh: tween = ((tk2dTextMesh)target).DOScale(optionalBool0 ? new Vector3(endValueFloat, endValueFloat, endValueFloat) : endValueV3, duration); break; case TargetType.tk2dBaseSprite: tween = ((tk2dBaseSprite)target).DOScale(optionalBool0 ? new Vector3(endValueFloat, endValueFloat, endValueFloat) : endValueV3, duration); break; #endif default: tween = transform.DOScale(optionalBool0 ? new Vector3(endValueFloat, endValueFloat, endValueFloat) : endValueV3, duration); break; } break; case DOTweenAnimationType.UIWidthHeight: tween = ((RectTransform)target).DOSizeDelta(optionalBool0 ? new Vector2(endValueFloat, endValueFloat) : endValueV2, duration); break; case DOTweenAnimationType.Color: isRelative = false; switch (targetType) { case TargetType.SpriteRenderer: tween = ((SpriteRenderer)target).DOColor(endValueColor, duration); break; case TargetType.Renderer: tween = ((Renderer)target).material.DOColor(endValueColor, duration); break; case TargetType.Image: tween = ((Image)target).DOColor(endValueColor, duration); break; case TargetType.Text: tween = ((Text)target).DOColor(endValueColor, duration); break; case TargetType.Light: tween = ((Light)target).DOColor(endValueColor, duration); break; #if DOTWEEN_TK2D case TargetType.tk2dTextMesh: tween = ((tk2dTextMesh)target).DOColor(endValueColor, duration); break; case TargetType.tk2dBaseSprite: tween = ((tk2dBaseSprite)target).DOColor(endValueColor, duration); break; #endif #if DOTWEEN_TMP case TargetType.TextMeshProUGUI: tween = ((TextMeshProUGUI)target).DOColor(endValueColor, duration); break; case TargetType.TextMeshPro: tween = ((TextMeshPro)target).DOColor(endValueColor, duration); break; #endif } break; case DOTweenAnimationType.Fade: isRelative = false; switch (targetType) { case TargetType.SpriteRenderer: tween = ((SpriteRenderer)target).DOFade(endValueFloat, duration); break; case TargetType.Renderer: tween = ((Renderer)target).material.DOFade(endValueFloat, duration); break; case TargetType.Image: tween = ((Image)target).DOFade(endValueFloat, duration); break; case TargetType.Text: tween = ((Text)target).DOFade(endValueFloat, duration); break; case TargetType.Light: tween = ((Light)target).DOIntensity(endValueFloat, duration); break; case TargetType.CanvasGroup: tween = ((CanvasGroup)target).DOFade(endValueFloat, duration); break; #if DOTWEEN_TK2D case TargetType.tk2dTextMesh: tween = ((tk2dTextMesh)target).DOFade(endValueFloat, duration); break; case TargetType.tk2dBaseSprite: tween = ((tk2dBaseSprite)target).DOFade(endValueFloat, duration); break; #endif #if DOTWEEN_TMP case TargetType.TextMeshProUGUI: tween = ((TextMeshProUGUI)target).DOFade(endValueFloat, duration); break; case TargetType.TextMeshPro: tween = ((TextMeshPro)target).DOFade(endValueFloat, duration); break; #endif } break; case DOTweenAnimationType.Text: switch (targetType) { case TargetType.Text: tween = ((Text)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString); break; #if DOTWEEN_TK2D case TargetType.tk2dTextMesh: tween = ((tk2dTextMesh)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString); break; #endif #if DOTWEEN_TMP case TargetType.TextMeshProUGUI: tween = ((TextMeshProUGUI)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString); break; case TargetType.TextMeshPro: tween = ((TextMeshPro)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString); break; #endif } break; case DOTweenAnimationType.PunchPosition: switch (targetType) { case TargetType.RectTransform: tween = ((RectTransform)target).DOPunchAnchorPos(endValueV3, duration, optionalInt0, optionalFloat0, optionalBool0); break; case TargetType.Transform: tween = ((Transform)target).DOPunchPosition(endValueV3, duration, optionalInt0, optionalFloat0, optionalBool0); break; } break; case DOTweenAnimationType.PunchScale: tween = transform.DOPunchScale(endValueV3, duration, optionalInt0, optionalFloat0); break; case DOTweenAnimationType.PunchRotation: tween = transform.DOPunchRotation(endValueV3, duration, optionalInt0, optionalFloat0); break; case DOTweenAnimationType.ShakePosition: switch (targetType) { case TargetType.RectTransform: tween = ((RectTransform)target).DOShakeAnchorPos(duration, endValueV3, optionalInt0, optionalFloat0, optionalBool0); break; case TargetType.Transform: tween = ((Transform)target).DOShakePosition(duration, endValueV3, optionalInt0, optionalFloat0, optionalBool0); break; } break; case DOTweenAnimationType.ShakeScale: tween = transform.DOShakeScale(duration, endValueV3, optionalInt0, optionalFloat0); break; case DOTweenAnimationType.ShakeRotation: tween = transform.DOShakeRotation(duration, endValueV3, optionalInt0, optionalFloat0); break; case DOTweenAnimationType.CameraAspect: tween = ((Camera)target).DOAspect(endValueFloat, duration); break; case DOTweenAnimationType.CameraBackgroundColor: tween = ((Camera)target).DOColor(endValueColor, duration); break; case DOTweenAnimationType.CameraFieldOfView: tween = ((Camera)target).DOFieldOfView(endValueFloat, duration); break; case DOTweenAnimationType.CameraOrthoSize: tween = ((Camera)target).DOOrthoSize(endValueFloat, duration); break; case DOTweenAnimationType.CameraPixelRect: tween = ((Camera)target).DOPixelRect(endValueRect, duration); break; case DOTweenAnimationType.CameraRect: tween = ((Camera)target).DORect(endValueRect, duration); break; } if (tween == null) { return; } if (isFrom) { ((Tweener)tween).From(isRelative); } else { tween.SetRelative(isRelative); } tween.SetTarget(this.gameObject).SetDelay(delay).SetLoops(loops, loopType).SetAutoKill(autoKill) .OnKill(() => tween = null); if (isSpeedBased) { tween.SetSpeedBased(); } if (easeType == Ease.INTERNAL_Custom) { tween.SetEase(easeCurve); } else { tween.SetEase(easeType); } if (!string.IsNullOrEmpty(id)) { tween.SetId(id); } tween.SetUpdate(isIndependentUpdate); if (hasOnStart) { if (onStart != null) { tween.OnStart(onStart.Invoke); } } else { onStart = null; } if (hasOnPlay) { if (onPlay != null) { tween.OnPlay(onPlay.Invoke); } } else { onPlay = null; } if (hasOnUpdate) { if (onUpdate != null) { tween.OnUpdate(onUpdate.Invoke); } } else { onUpdate = null; } if (hasOnStepComplete) { if (onStepComplete != null) { tween.OnStepComplete(onStepComplete.Invoke); } } else { onStepComplete = null; } if (hasOnComplete) { if (onComplete != null) { tween.OnComplete(onComplete.Invoke); } } else { onComplete = null; } if (autoPlay) { tween.Play(); } else { tween.Pause(); } if (hasOnTweenCreated && onTweenCreated != null) { onTweenCreated.Invoke(); } }
private void GeneratePropertySetter ( [NotNull] IntrospectivePropertyInfo property, [NotNull] FieldInfo propertyFieldBuilder, [NotNull] PropertyBuilder propertyBuilder ) { var wrappedProperty = property.GetWrappedMember(); var actualSetMethod = wrappedProperty.GetSetMethod(); var setterMethod = TargetType.DefineMethod ( actualSetMethod.Name, PropertyMethodAttributes, actualSetMethod.CallingConvention, typeof(void), actualSetMethod.GetParameters().Select(p => p.ParameterType).ToArray() ); MethodInfo underlyingMethod; if (property.PropertyType.IsPointer) { underlyingMethod = typeof(Marshal).GetMethods().First ( m => m.Name == nameof(Marshal.WriteIntPtr) && m.GetParameters().Length == 3 ); } else if (property.PropertyType.IsValueType) { underlyingMethod = typeof(Marshal).GetMethods().First ( m => m.Name == nameof(Marshal.StructureToPtr) && m.GetParameters().Length == 3 && m.IsGenericMethod ) .MakeGenericMethod(property.PropertyType); } else { throw new NotSupportedException ( $"The type \"{property.PropertyType.FullName}\" is not supported. Only value types or pointers are supported." ); } var setterIL = setterMethod.GetILGenerator(); if (Options.HasFlagFast(GenerateDisposalChecks)) { EmitDisposalCheck(setterIL); } if (property.PropertyType.IsPointer) { var explicitConvertToIntPtrFunc = typeof(IntPtr).GetMethods().First ( m => m.Name == "op_Explicit" ); GenerateSymbolPush(setterIL, propertyFieldBuilder); // Push Symbol address to stack setterIL.Emit(OpCodes.Ldc_I4, 0); // Push 0 offset to stack setterIL.Emit(OpCodes.Ldarg_1); // Push value to stack setterIL.EmitCall(OpCodes.Call, explicitConvertToIntPtrFunc, null); // Explicit Convert Pointer to IntPtr object } else { setterIL.Emit(OpCodes.Ldarg_1); GenerateSymbolPush(setterIL, propertyFieldBuilder); setterIL.Emit(OpCodes.Ldc_I4, 0); // false for deleting structure that is already stored in pointer } setterIL.EmitCall ( OpCodes.Call, underlyingMethod, null ); setterIL.Emit(OpCodes.Ret); propertyBuilder.SetSetMethod(setterMethod); TargetType.DefineMethodOverride(setterMethod, actualSetMethod); }
public void SetAsDraggableTarget() { type = TargetType.DraggableTarget; UpdateTargetMaterial(); }
public AttackOption(string name, IAttack item, TargetType targetType) : this(new DefaultActionMenuStore(), name, item, targetType) { }
public IntSpellComponent(TargetType targetType, double baseValue) : base(targetType) { attribute = new Attribute().SetBaseValue(baseValue); }
public static void FullIndexSetModifySpell ( int fullidx, int id, int iconid, int smalliconid, int minskill, int manacost, int tithing, string name, string words, TargetType target, params Reagents[] regs ) { if (fullidx < 1 || fullidx > 799) { return; } SpellDefinition sd = FullIndexGetSpell(fullidx); if (sd.ID == fullidx) //we are not using an emptyspell spelldefinition { if (iconid == 0) { iconid = sd.GumpIconID; } if (smalliconid == 0) { smalliconid = sd.GumpIconSmallID; } if (tithing == 0) { tithing = sd.TithingCost; } if (manacost == 0) { manacost = sd.ManaCost; } if (minskill == 0) { minskill = sd.MinSkill; } if (!string.IsNullOrEmpty(sd.PowerWords) && sd.PowerWords != words) { WordToTargettype.Remove(sd.PowerWords); } if (!string.IsNullOrEmpty(sd.Name) && sd.Name != name) { WordToTargettype.Remove(sd.Name); } } sd = new SpellDefinition (name, fullidx, iconid, smalliconid, words, manacost, minskill, tithing, target, regs); if (fullidx < 100) { SpellsMagery.SetSpell(id, in sd); } else if (fullidx < 200) { SpellsNecromancy.SetSpell(id, in sd); } else if (fullidx < 300) { SpellsChivalry.SetSpell(id, in sd); } else if (fullidx < 500) { SpellsBushido.SetSpell(id, in sd); } else if (fullidx < 600) { SpellsNinjitsu.SetSpell(id, in sd); } else if (fullidx < 678) { SpellsSpellweaving.SetSpell(id, in sd); } else if (fullidx < 700) { SpellsMysticism.SetSpell(id - 77, in sd); } else { SpellsMastery.SetSpell(id, in sd); } }
/// <summary> /// Gets the project's root binaries folder. /// </summary> /// <param name="RawProjectPath">Full project path.</param> /// <param name="TargetType">Target type.</param> /// <param name="bIsUProjectFile">True if uproject file.</param> /// <returns>Binaries path.</returns> public static DirectoryReference GetClientProjectBinariesRootPath(FileReference RawProjectPath, TargetType TargetType, bool bIsCodeBasedProject) { DirectoryReference BinPath = null; switch (TargetType) { case TargetType.Program: BinPath = DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine", "Binaries"); break; case TargetType.Client: case TargetType.Game: if (!bIsCodeBasedProject) { BinPath = DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine", "Binaries"); } else { BinPath = DirectoryReference.Combine(RawProjectPath.Directory, "Binaries"); } break; } return(BinPath); }
public Target(TargetType type) { mType = type; mPosition = new Vector3(); mObjects = new ObjectList(); }
private TypeDescriptor(TargetType targetType, Maybe <int> maxItems, Maybe <TypeDescriptor> nextValue = null) { this.targetType = targetType; this.maxItems = maxItems; this.nextValue = nextValue; }
private void GeneratePropertyGetter ( [NotNull] IntrospectivePropertyInfo property, [NotNull] FieldInfo propertyFieldBuilder, [NotNull] PropertyBuilder propertyBuilder ) { var wrappedProperty = property.GetWrappedMember(); var actualGetMethod = wrappedProperty.GetGetMethod(); var getterMethod = TargetType.DefineMethod ( actualGetMethod.Name, PropertyMethodAttributes, actualGetMethod.CallingConvention, actualGetMethod.ReturnType, Type.EmptyTypes ); MethodInfo underlyingMethod; if (property.PropertyType.IsPointer) { underlyingMethod = typeof(Marshal).GetMethods().First ( m => m.Name == nameof(Marshal.ReadIntPtr) && m.GetParameters().Length == 1 ); } else if (property.PropertyType.IsValueType) { underlyingMethod = typeof(Marshal).GetMethods().First ( m => m.Name == nameof(Marshal.PtrToStructure) && m.GetParameters().Length == 1 && m.IsGenericMethod ) .MakeGenericMethod(property.PropertyType); } else { throw new NotSupportedException ( $"The type \"{property.PropertyType.FullName}\" is not supported. Only value types or pointers are supported." ); } var getterIL = getterMethod.GetILGenerator(); if (Options.HasFlagFast(GenerateDisposalChecks)) { EmitDisposalCheck(getterIL); } GenerateSymbolPush(getterIL, propertyFieldBuilder); getterIL.EmitCall ( OpCodes.Call, underlyingMethod, null ); getterIL.Emit(OpCodes.Ret); propertyBuilder.SetGetMethod(getterMethod); TargetType.DefineMethodOverride(getterMethod, actualGetMethod); }
public TrackTargetEvent(Transform target, TargetType idleMoving, string context) { this.target = target; this.idleMoving = idleMoving; this.context = context; }
public static long GetTargetGMO() // 0 if not a GMO or not set. { TargetType tt = (TargetType)EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("TargetPositionType", (int)TargetType.None); return((tt == TargetType.GMO) ? EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("TargetPositionID", 0) : 0); }
static ProjectedGameState GetNextStateFromAction_Attack(ScenarioState newState, EntityData entity, Action action) { GameBoard testBoard = BoardController.CurrentBoard; AttackCardData card = action.card as AttackCardData; TargetType attackTargetType = card.targetType; Tile attackOriginTile = BoardController.CurrentBoard.GetTileAtPosition(entity.Position); List <Tile> targetTiles = new List <Tile>(); switch (attackTargetType) { case TargetType.Single: targetTiles.Add(newState.FindFirstOccupiedTileInDirection(attackOriginTile, action.direction, action.distance)); break; case TargetType.AreaOfEffect: Tile impactTile = newState.FindFirstOccupiedTileInDirection(attackOriginTile, action.direction, action.distance); targetTiles.Add(impactTile); targetTiles.AddRange(impactTile.Neighbors); break; case TargetType.Line: targetTiles.AddRange(attackOriginTile.GetAllTilesInDirection(action.direction, action.card.range)); break; default: break; } ProjectedGameState newProjectedState = new ProjectedGameState(entity, newState, action); newProjectedState.AddAttackedPositions(targetTiles.Select(t => t.Position)); List <EntityData> affectedEntities = targetTiles .Select(t => newState.GetTileOccupant(t)) .Where(o => o != null) .ToList(); if (affectedEntities.Count == 0) { List <ModifierData> modifiersToResolve = action.card.modifiers .Where(m => m.modifierCategory == ModifierCategory.Blowback || m.modifierCategory == ModifierCategory.FollowUp) .ToList(); for (int i = 0; i < modifiersToResolve.Count; i++) { ModifierData modifier = modifiersToResolve[i]; ApplyModifierToAttack_BlowbackFollowUp(modifier, entity, newState, action.direction, modifier.modifierCategory); } return(newProjectedState); } for (int i = 0; i < affectedEntities.Count; i++) { EntityData affectedEntity = affectedEntities[i]; int cardDamage = card.damage + entity.GetAttackModifierValue(); affectedEntity.DealDamage(cardDamage, newState); List <ModifierData> attackModifiers = action.card.modifiers; if (attackModifiers != null && attackModifiers.Count > 0) { for (int j = 0; i < attackModifiers.Count; i++) { ApplyModifierToAttack(affectedEntity, attackModifiers[j], entity, newState, action.direction); } } } return(newProjectedState); }
public static TargetType GetTargetType() { TargetType tt = (TargetType)EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("TargetPositionType", (int)TargetType.None); return(tt); }
/**** ** Targets ****/ /// <summary>Get all potential lookup targets in the current location.</summary> /// <param name="location">The current location.</param> /// <param name="originTile">The tile from which to search for targets.</param> /// <param name="includeMapTile">Whether to allow matching the map tile itself.</param> public IEnumerable <ITarget> GetNearbyTargets(GameLocation location, Vector2 originTile, bool includeMapTile) { // NPCs foreach (NPC npc in location.characters) { if (!GameHelper.CouldSpriteOccludeTile(npc.getTileLocation(), originTile)) { continue; } TargetType type = TargetType.Unknown; if (npc is Child || npc.isVillager()) { type = TargetType.Villager; } else if (npc is Horse) { type = TargetType.Horse; } else if (npc is Junimo) { type = TargetType.Junimo; } else if (npc is Pet) { type = TargetType.Pet; } else if (npc is Monster) { type = TargetType.Monster; } yield return(new CharacterTarget(type, npc, npc.getTileLocation(), this.Reflection)); } // animals foreach (FarmAnimal animal in (location as Farm)?.animals.Values ?? (location as AnimalHouse)?.animals.Values ?? Enumerable.Empty <FarmAnimal>()) { if (!GameHelper.CouldSpriteOccludeTile(animal.getTileLocation(), originTile)) { continue; } yield return(new FarmAnimalTarget(animal, animal.getTileLocation())); } // map objects foreach (var pair in location.objects) { Vector2 spriteTile = pair.Key; SObject obj = pair.Value; if (!GameHelper.CouldSpriteOccludeTile(spriteTile, originTile)) { continue; } yield return(this.CustomFarming.IsLoaded && this.CustomFarming.IsCustomObject(obj) ? new CustomFarmingObjectTarget(obj, spriteTile, this.Reflection, this.CustomFarming) : new ObjectTarget(obj, spriteTile, this.Reflection)); } // furniture if (location is DecoratableLocation decoratableLocation) { foreach (var furniture in decoratableLocation.furniture) { yield return(new ObjectTarget(furniture, furniture.TileLocation, this.Reflection)); } } // terrain features foreach (var pair in location.terrainFeatures) { Vector2 spriteTile = pair.Key; TerrainFeature feature = pair.Value; if (!GameHelper.CouldSpriteOccludeTile(spriteTile, originTile)) { continue; } if ((feature as HoeDirt)?.crop != null) { yield return(new CropTarget(feature, spriteTile, this.Reflection)); } else if (feature is FruitTree fruitTree) { if (this.Reflection.GetField <float>(feature, "alpha").GetValue() < 0.8f) { continue; // ignore when tree is faded out (so player can lookup things behind it) } yield return(new FruitTreeTarget(fruitTree, spriteTile)); } else if (feature is Tree wildTree) { if (this.Reflection.GetField <float>(feature, "alpha").GetValue() < 0.8f) { continue; // ignore when tree is faded out (so player can lookup things behind it) } yield return(new TreeTarget(wildTree, spriteTile, this.Reflection)); } else { yield return(new UnknownTarget(feature, spriteTile)); } } // players foreach (var farmer in new[] { Game1.player }.Union(location.farmers)) { if (!GameHelper.CouldSpriteOccludeTile(farmer.getTileLocation(), originTile)) { continue; } yield return(new FarmerTarget(farmer)); } // tile if (includeMapTile) { yield return(new TileTarget(originTile)); } }
/// <summary> /// Determines whether the given plugin module is part of the current build. /// </summary> /// <param name="Platform">The platform being compiled for</param> /// <param name="TargetConfiguration">The target configuration being compiled for</param> /// <param name="TargetName">Name of the target being built</param> /// <param name="TargetType">The type of the target being compiled</param> /// <param name="bBuildDeveloperTools">Whether the configuration includes developer tools (typically UEBuildConfiguration.bBuildDeveloperTools for UBT callers)</param> /// <param name="bBuildEditor">Whether the configuration includes the editor (typically UEBuildConfiguration.bBuildEditor for UBT callers)</param> /// <param name="bBuildRequiresCookedData">Whether the configuration requires cooked content (typically UEBuildConfiguration.bBuildRequiresCookedData for UBT callers)</param> public bool IsCompiledInConfiguration(UnrealTargetPlatform Platform, UnrealTargetConfiguration TargetConfiguration, string TargetName, TargetType TargetType, bool bBuildDeveloperTools, bool bBuildEditor, bool bBuildRequiresCookedData) { // Check the platform is whitelisted if (WhitelistPlatforms != null && WhitelistPlatforms.Length > 0 && !WhitelistPlatforms.Contains(Platform)) { return(false); } // Check the platform is not blacklisted if (BlacklistPlatforms != null && BlacklistPlatforms.Contains(Platform)) { return(false); } // Check the target is whitelisted if (WhitelistTargets != null && WhitelistTargets.Length > 0 && !WhitelistTargets.Contains(TargetType)) { return(false); } // Check the target is not blacklisted if (BlacklistTargets != null && BlacklistTargets.Contains(TargetType)) { return(false); } // Check the target configuration is whitelisted if (WhitelistTargetConfigurations != null && WhitelistTargetConfigurations.Length > 0 && !WhitelistTargetConfigurations.Contains(TargetConfiguration)) { return(false); } // Check the target configuration is not blacklisted if (BlacklistTargetConfigurations != null && BlacklistTargetConfigurations.Contains(TargetConfiguration)) { return(false); } // Special checks just for programs if (TargetType == TargetType.Program) { // Check the program name is whitelisted. Note that this behavior is slightly different to other whitelist/blacklist checks; we will whitelist a module of any type if it's explicitly allowed for this program. if (WhitelistPrograms != null && WhitelistPrograms.Length > 0) { return(WhitelistPrograms.Contains(TargetName)); } // Check the program name is not blacklisted if (BlacklistPrograms != null && BlacklistPrograms.Contains(TargetName)) { return(false); } } // Check the module is compatible with this target. switch (Type) { case ModuleHostType.Runtime: case ModuleHostType.RuntimeNoCommandlet: return(TargetType != TargetType.Program); case ModuleHostType.CookedOnly: return(bBuildRequiresCookedData); case ModuleHostType.RuntimeAndProgram: return(true); case ModuleHostType.Developer: return(bBuildDeveloperTools); case ModuleHostType.Editor: case ModuleHostType.EditorNoCommandlet: return(TargetType == TargetType.Editor || bBuildEditor); case ModuleHostType.Program: return(TargetType == TargetType.Program); case ModuleHostType.ServerOnly: return(TargetType != TargetType.Program && TargetType != TargetType.Client); case ModuleHostType.ClientOnly: return(TargetType != TargetType.Program && TargetType != TargetType.Server); } return(false); }
/**** ** Targets ****/ /// <summary>Get all potential lookup targets in the current location.</summary> /// <param name="location">The current location.</param> /// <param name="originTile">The tile from which to search for targets.</param> /// <param name="includeMapTile">Whether to allow matching the map tile itself.</param> public IEnumerable <ITarget> GetNearbyTargets(GameLocation location, Vector2 originTile, bool includeMapTile) { // NPCs foreach (NPC npc in location.characters) { if (!this.GameHelper.CouldSpriteOccludeTile(npc.getTileLocation(), originTile)) { continue; } TargetType type = TargetType.Unknown; if (npc is Child || npc.isVillager()) { type = TargetType.Villager; } else if (npc is Horse) { type = TargetType.Horse; } else if (npc is Junimo) { type = TargetType.Junimo; } else if (npc is Pet) { type = TargetType.Pet; } else if (npc is Monster) { type = TargetType.Monster; } yield return(new CharacterTarget(this.GameHelper, type, npc, npc.getTileLocation(), this.Reflection)); } // animals foreach (FarmAnimal animal in (location as Farm)?.animals.Values ?? (location as AnimalHouse)?.animals.Values ?? Enumerable.Empty <FarmAnimal>()) { if (!this.GameHelper.CouldSpriteOccludeTile(animal.getTileLocation(), originTile)) { continue; } yield return(new FarmAnimalTarget(this.GameHelper, animal, animal.getTileLocation())); } // map objects foreach (KeyValuePair <Vector2, SObject> pair in location.objects.Pairs) { Vector2 spriteTile = pair.Key; SObject obj = pair.Value; if (!this.GameHelper.CouldSpriteOccludeTile(spriteTile, originTile)) { continue; } yield return(new ObjectTarget(this.GameHelper, obj, spriteTile, this.Reflection)); } // furniture if (location is DecoratableLocation decoratableLocation) { foreach (var furniture in decoratableLocation.furniture) { yield return(new ObjectTarget(this.GameHelper, furniture, furniture.TileLocation, this.Reflection)); } } // terrain features foreach (KeyValuePair <Vector2, TerrainFeature> pair in location.terrainFeatures.Pairs) { Vector2 spriteTile = pair.Key; TerrainFeature feature = pair.Value; if (!this.GameHelper.CouldSpriteOccludeTile(spriteTile, originTile)) { continue; } if (feature is HoeDirt dirt && dirt.crop != null) { yield return(new CropTarget(this.GameHelper, dirt, spriteTile, this.Reflection)); }
public void SetAsNormalTarget() { type = TargetType.NormalTarget; UpdateTargetMaterial(); }
/// <summary> /// Initializes a new instance of the <see cref="T:SleepTracker.CustomViews.SleepInstanceView"/> class. /// </summary> /// <param name="targetType">Target type.</param> public SleepInstanceView(TargetType targetType, Action reddrawCanvasView) { ReddrawCanvasView = reddrawCanvasView; SetBinding(ContentView.BackgroundColorProperty, new Binding("BackgroundColor")); BindingContext = new { BackgroundColor = StyledBackground }; Grid coreGrid = new Grid { Padding = new Thickness(0, 1, 1, 1), RowSpacing = 1, ColumnSpacing = 1, BackgroundColor = Color.FromHex("E3E3E3"), VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = new GridLength(100, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(30, GridUnitType.Absolute) } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(4, GridUnitType.Absolute) }, new ColumnDefinition { Width = new GridLength(100, GridUnitType.Absolute) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(100, GridUnitType.Absolute) }, new ColumnDefinition { Width = new GridLength(50, GridUnitType.Absolute) } } }; RangeTargetView = new SleepTargetView(targetType); coreGrid.Children.Add(RangeTargetView, 0, 1, 0, 2); RangeSliderView = new SleepSliderView(targetType); coreGrid.Children.Add(RangeSliderView, 1, 5, 0, 1); coreGrid.Children.Add(new SleepDescriptionView(targetType), 1, 5, 1, 2); Content = coreGrid; var tgr = CreateRateTapGestureRecognizer(); GestureRecognizers.Add(tgr); RangeTargetView.GestureRecognizers.Add(tgr); RangeSliderView.RangeSlider.DragCompleted += RangeSlider_DragCompleted; }
public CommandTargeting(TargetType criteria, float range, bool requireLoS) { Criteria = criteria; Range = range; RequireLoS = requireLoS; }
public void SetAsNextTarget() { type = TargetType.NextTarget; UpdateTargetMaterial(); }
/// <summary> /// 发送消息。 /// </summary> /// <param name="type">目标类型。</param> /// <param name="id">用于发送的ID。</param> /// <param name="content">消息内容。</param> public void Message(TargetType type, long id, string content) { try { lock (syncPost) { if (Status != ClientStatus.Active) { throw new InvalidOperationException("尚未登录,无法进行该操作"); } Logger.Debug("开始发送消息,对象类型:" + type); string paramName; ApiUrl url; switch (type) { case TargetType.Friend: paramName = "to"; url = ApiUrl.SendMessageToFriend; break; case TargetType.Group: paramName = "group_uin"; url = ApiUrl.SendMessageToGroup; break; case TargetType.Discussion: paramName = "did"; url = ApiUrl.SendMessageToDiscussion; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } var response = Client.PostWithRetry(url, new JObject { { paramName, id }, { "content", new JArray { StringHelper.TranslateEmoticons(content), new JArray { "font", JObject.FromObject(Font.DefaultFont) } } .ToString(Formatting.None) }, { "face", 573 }, { "clientid", ClientId }, { "msg_id", _messageId++ }, { "psessionid", Psessionid } }, RetryTimes); if (response.StatusCode != HttpStatusCode.OK) { Logger.Error("消息发送失败,HTTP返回码" + (int)response.StatusCode); } int?status = null; status = response.RawText.Contains("errCode") ? JObject.Parse(response.RawText)["errCode"].ToObject <int?>() : JObject.Parse(response.RawText)["retcode"].ToObject <int?>(); if (status != null && (status == 0 || status == 100100)) { Logger.Debug("消息发送成功"); if (MessageEcho == null) { return; } MessageEchoEventArgs args; switch (type) { case TargetType.Friend: { args = new MessageEchoEventArgs(Friends.Find(_ => _.Id == id), content); break; } case TargetType.Group: { args = new MessageEchoEventArgs(Groups.Find(_ => _.Id == id), content); break; } case TargetType.Discussion: { args = new MessageEchoEventArgs(Discussions.Find(_ => _.Id == id), content); break; } default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } MessageEcho(this, args); } else { Logger.Error("消息发送失败,API返回码" + status); } } } catch (Exception e) { Console.WriteLine(e); throw; } }
public void SetAsStartingTestTarget() { type = TargetType.StartingTestTarget; UpdateTargetMaterial(); }
public static void TargetCancel(TargetType type, Serial cursorID, byte cursorType) { Socket.Send(new PTargetCancel(type, cursorID, cursorType)); }
void FixedUpdate() { if (state != State.Dead) // Unit alive { if (building) { if (currentConstruction) { Vector3 dist = this.transform.position - currentConstruction.transform.position; //print (dist.magnitude); if (dist.magnitude < 2) { currentConstruction.GetComponent <build> ().percentage += 1; currentConstruction.GetComponent <build> ().t = team; } else { //print ("GO"); MoveUnit(transform.position, currentConstruction.transform.position); } } } if (Input.GetKeyDown(KeyCode.P) && !patrolPointSelection) { patrolPointSelection = true; print("Set patrol points"); patroling = false; patrolPointCount = 0; } if (TargetReached && !attacking && state != State.Idle) { changeState(State.Idle); } if (state != State.Idle && attacking && target != null) { transform.LookAt(target.transform); //Makes unit look at current attack target } if (health <= 0) //Checks to see if target is dead { changeState(State.Dead); audio.PlayOneShot(death); } CheckState(); //Checks the state of the target if (state != State.Attacking) { CheckForEnemies(); } int targetHealth = 0; //Gets the health of the target if (target != null) { if (targetType == TargetType.Unit) { targetHealth = target.gameObject.GetComponent <Unit> ().health; } else if (targetType == TargetType.Building) { targetHealth = target.gameObject.GetComponent <DestructableBuilding> ().health; } } //If target is out of range or dead remove it as target if (state != State.Idle && target != null && !instructedAttack && Vector3.Distance(target.transform.position, transform.position) >= ((float)attackRange) || targetHealth <= 0) { target = null; attacking = false; if (state != State.Moving) { changeState(State.Idle); } } //Gathering if ((MAX_LOAD == currentLoad) || (collectGoods && gathering && currentResource == null)) // If the unit has reached its max load return to base or If the resource is destroyed and the grunt has not filled its capacity { collectGoods = false; collectedAmount = currentLoad; currentLoad = 0; StartCoroutine("FollowPath"); } if (unitClass == Type.Grunt && collectGoods && MAX_LOAD > currentLoad && currentResource != null) // While gathering goods increase current load { currentLoad += gatherSpeed; Debug.Log(currentLoad); currentResource.GetComponent <Resource> ().ReduceAmountOfMaterial(gatherSpeed); collectedAmount = currentLoad; } if (Input.GetMouseButton(0) && !EventSystem.current.IsPointerOverGameObject()) { // Helps the selection of troops either multiple or single troop selection if (!clicked) { Vector3 cameraPosition = Camera.main.WorldToScreenPoint(transform.position); cameraPosition.y = Screen.height - cameraPosition.y; selected = AICamera.selectedArea.Contains(cameraPosition); GameObject aiCamera = GameObject.FindGameObjectWithTag("MainCamera"); if (renderer.isVisible && selected && !UnitMonitor.selectedUnits.Contains(this.gameObject) && UnitMonitor.LimitNotReached() && this.team == VarMan.Instance.pNum) { UnitMonitor.AddUnit(this.gameObject); wasSelected = true; audio.PlayOneShot(selectionConfirmation); } else if (!selected && wasSelected && !UnitMonitor.isShiftPressed()) { //If either of the shift buttons are pushed then dont deselct it just add it UnitMonitor.RemoveUnit(this.gameObject); wasSelected = false; TargetReached = false; } else if (this.team != VarMan.Instance.pNum) { Debug.Log("Not me!"); } } //Create the particle effect object that shows which object is selected if (wasSelected && glow == null) { glow = (GameObject)GameObject.Instantiate(glowSelection); glow.transform.parent = transform; glow.transform.localPosition = new Vector3(0, 0, 0); if (transform.FindChild("Health Bar")) { transform.FindChild("Health Bar").gameObject.renderer.enabled = true; transform.FindChild("Health Bar").transform.FindChild("Bar").gameObject.renderer.enabled = true; } } //If unselected remove it else if (renderer.isVisible && !wasSelected && glow != null) { GameObject.Destroy(glow); glow = null; if (transform.FindChild("Health Bar")) { transform.FindChild("Health Bar").gameObject.renderer.enabled = false; transform.FindChild("Health Bar").transform.FindChild("Bar").gameObject.renderer.enabled = false; } } } //Makes the units setup a patrol point and patrol between two points if (Input.GetMouseButtonDown(1) && patrolPointSelection && wasSelected) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { mouseClick = hit.point; if (patrolPointCount == 0) { patrolPointCount = 0; patrolPoint1 = mouseClick; audio.PlayOneShot(moveConfirmation); MoveUnit(transform.position, patrolPoint1); patrolPointCount++; } else if (patrolPointCount == 1) { patrolPoint2 = mouseClick; patrolPointSelection = false; patroling = true; patrolPointCount = 0; audio.PlayOneShot(moveConfirmation); } if (patroling && !patrolPointSelection) { Patrol(patrolPoint1, patrolPoint2); } } } else if (Input.GetMouseButtonDown(1) && wasSelected && !patrolPointSelection) { // Detects a players right click and moves the selected troops top that position path = null; //Stops the players movement StopCoroutine("FollowPath"); RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Debug.Log("click"); if (Physics.Raycast(ray, out hit)) { TargetReached = false; mouseClick = hit.point; notOverrideable = true; instructedAttack = false; Transform attackPoint = null; patroling = false; //If enemy unit attack if ((hit.collider.gameObject.tag == "Unit" || hit.collider.gameObject.tag == "Grunt") && hit.collider.gameObject.GetComponent <Unit> ().team != this.team) { audio.PlayOneShot(attackConfirmation); this.target = hit.collider.gameObject; targetType = TargetType.Unit; attacking = true; instructedAttack = true; notOverrideable = false; print("Attack unit"); } //If enemy building attack if ((hit.collider.gameObject.tag == "Building" || hit.collider.gameObject.tag == "Home Base" || hit.collider.gameObject.tag == "School") && hit.collider.gameObject.GetComponent <DestructableBuilding> ().team != this.team) { audio.PlayOneShot(attackConfirmation); this.target = hit.collider.gameObject; targetType = TargetType.Building; attacking = true; instructedAttack = true; notOverrideable = false; attackPoint = hit.transform.Find("AttackPoint"); print("Attack Building"); } //If resource and grunt start gathering if (hit.collider.gameObject.tag == "Scafold" && unitClass.Equals(Type.Grunt)) { //print ("GO BUILD"); var buildPoint = hit.transform.FindChild("BuildPoint"); if (buildPoint) { //print ("SCAFFOLD SET"); building = true; print(buildPoint.localPosition); MoveUnit(transform.position, buildPoint.position); currentConstruction = buildPoint.gameObject; } } else if (hit.collider.gameObject.tag == "Resource" && unitClass.Equals(Type.Grunt)) { audio.PlayOneShot(gatherConfirmation); currentResource = hit.transform.gameObject; if (resourceType != Resource.ResourceType.Nothing) { collectedAmount = 0; currentLoad = 0; } resourceType = currentResource.GetComponent <Resource> ().type; var gatherPoint = hit.transform.Find("GatherPoint"); gathering = true; attacking = false; if (gatherPoint) { collectGoods = false; returning = false; resourcePoint = gatherPoint.position; MoveUnit(transform.position, gatherPoint.position); } } else if (hit.collider.gameObject.tag == "Resource" || (hit.collider.gameObject.tag == "Home Base" && !unitClass.Equals(Type.Grunt) && hit.collider.gameObject.GetComponent <DestructableBuilding> ().team == this.team)) { //If not grunt just stop moving changeState(State.Idle); } else if (hit.collider.gameObject.tag == "Home Base" && unitClass.Equals(Type.Grunt) && hit.collider.gameObject.GetComponent <DestructableBuilding> ().team == this.team) { //Return to homebase and deposit goods var returnPoint = hit.transform.Find("ReturnPoint"); attacking = false; if (unitClass.Equals(Type.Grunt)) { depositing = true; MoveUnit(transform.position, returnPoint.position); } } else { //Just move the unit if (!attacking) { audio.PlayOneShot(moveConfirmation); } building = false; gathering = false; returning = false; collectGoods = false; currentLoad = 0; if (targetType == TargetType.Building && attackPoint != null) { MoveUnit(transform.position, attackPoint.position); } else { MoveUnit(transform.position, mouseClick); } } } } } else { CheckState(); } }
/// <summary> /// Sets the endpoint type /// </summary> /// <param name="target"></param> public void SetEndpoint(TargetType target) { this.Endpoint = target; }
public override bool WriteProjectFile(List <UnrealTargetPlatform> InPlatforms, List <UnrealTargetConfiguration> InConfigurations, PlatformProjectGeneratorCollection PlatformProjectGenerators) { bool bSuccess = false; string ProjectNameRaw = ProjectFilePath.GetFileNameWithoutExtension(); //string ProjectPath = ProjectFilePath.FullName; string ProjectExtension = ProjectFilePath.GetExtension(); string ProjectPlatformName = BuildHostPlatform.Current.Platform.ToString(); // Get the output directory string EngineRootDirectory = UnrealBuildTool.EngineDirectory.FullName; // // Build the working directory of the Game executable. // string GameWorkingDirectory = ""; if (OnlyGameProject != null) { GameWorkingDirectory = Path.Combine(Path.GetDirectoryName(OnlyGameProject.FullName), "Binaries", ProjectPlatformName); } // // Build the working directory of the UE4Editor executable. // string UE4EditorWorkingDirectory = Path.Combine(EngineRootDirectory, "Binaries", ProjectPlatformName); // // Create the folder where the project files goes if it does not exist // String FilePath = Path.GetDirectoryName(ProjectFilePath.FullName); if ((FilePath.Length > 0) && !Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } string GameProjectFile = ""; if (OnlyGameProject != null) { GameProjectFile = OnlyGameProject.FullName; } // // Write all targets which will be separate projects. // foreach (ProjectTarget target in ProjectTargets) { string[] tmp = target.ToString().Split('.'); string ProjectTargetFileName = Path.GetDirectoryName(ProjectFilePath.FullName) + "/" + tmp [0] + ProjectExtension; String TargetName = tmp [0]; TargetType ProjectTargetType = target.TargetRules.Type; // // Create the CodeLites root element. // XElement CodeLiteProject = new XElement("CodeLite_Project"); XAttribute CodeLiteProjectAttributeName = new XAttribute("Name", TargetName); CodeLiteProject.Add(CodeLiteProjectAttributeName); // // Select only files we want to add. // TODO Maybe skipping those files directly in the following foreach loop is faster? // List <SourceFile> FilterSourceFile = SourceFiles.FindAll(s => ( s.Reference.HasExtension(".h") || s.Reference.HasExtension(".cpp") || s.Reference.HasExtension(".c") || s.Reference.HasExtension(".cs") || s.Reference.HasExtension(".uproject") || s.Reference.HasExtension(".uplugin") || s.Reference.HasExtension(".ini") || s.Reference.HasExtension(".usf") || s.Reference.HasExtension(".ush") )); // // Find/Create the correct virtual folder and place the file into it. // foreach (SourceFile CurrentFile in FilterSourceFile) { // // Try to get the correct relative folder representation for the project. // String CurrentFilePath = ""; // TODO It seems that the full pathname doesn't work for some files like .ini, .usf, .ush if ((ProjectTargetType == TargetType.Client) || (ProjectTargetType == TargetType.Editor) || (ProjectTargetType == TargetType.Game) || (ProjectTargetType == TargetType.Server)) { if (TargetName.Equals("UE4Client") || TargetName.Equals("UE4Server") || TargetName.Equals("UE4Game") || TargetName.Equals("UE4Editor")) { int Idx = UnrealBuildTool.EngineDirectory.FullName.Length; CurrentFilePath = Path.GetDirectoryName(Path.GetFullPath(CurrentFile.Reference.FullName)).Substring(Idx); } else { int Idx = Path.GetDirectoryName(CurrentFile.Reference.FullName).IndexOf(ProjectNameRaw) + ProjectNameRaw.Length; CurrentFilePath = Path.GetDirectoryName(CurrentFile.Reference.FullName).Substring(Idx); } } else if (ProjectTargetType == TargetType.Program) { // // We do not need all the editors subfolders to show the content. Find the correct programs subfolder. // int Idx = Path.GetDirectoryName(CurrentFile.Reference.FullName).IndexOf(TargetName) + TargetName.Length; CurrentFilePath = Path.GetDirectoryName(CurrentFile.Reference.FullName).Substring(Idx); } char[] Delimiters = new char[] { '/', '\\' }; string [] SplitFolders = CurrentFilePath.Split(Delimiters, StringSplitOptions.RemoveEmptyEntries); // // Set the CodeLite root folder again. // XElement root = CodeLiteProject; // // Iterate through all XElement virtual folders until we find the right place to put the file. // TODO this looks more like a hack to me. // foreach (string FolderName in SplitFolders) { if (FolderName.Equals("")) { continue; } // // Let's look if there is a virtual folder withint the current XElement. // IEnumerable <XElement> tests = root.Elements("VirtualDirectory"); if (IsEmpty(tests)) { // // No, then we have to create. // XElement vf = new XElement("VirtualDirectory"); XAttribute vfn = new XAttribute("Name", FolderName); vf.Add(vfn); root.Add(vf); root = vf; } else { // // Yes, then let's find the correct sub XElement. // bool notfound = true; // // We have some virtual directories let's find the correct one. // foreach (XElement element in tests) { // // Look the the following folder XAttribute attribute = element.Attribute("Name"); if (attribute.Value == FolderName) { // Ok, we found the folder as subfolder, let's use it. root = element; notfound = false; break; } } // // If we are here we didn't find any XElement with that subfolder, then we have to create. // if (notfound) { XElement vf = new XElement("VirtualDirectory"); XAttribute vfn = new XAttribute("Name", FolderName); vf.Add(vfn); root.Add(vf); root = vf; } } } // // If we are at this point we found the correct XElement folder // XElement file = new XElement("File"); XAttribute fileAttribute = new XAttribute("Name", CurrentFile.Reference.FullName); file.Add(fileAttribute); root.Add(file); } XElement CodeLiteSettings = new XElement("Settings"); CodeLiteProject.Add(CodeLiteSettings); XElement CodeLiteGlobalSettings = new XElement("GlobalSettings"); CodeLiteProject.Add(CodeLiteGlobalSettings); foreach (UnrealTargetConfiguration CurConf in InConfigurations) { XElement CodeLiteConfiguration = new XElement("Configuration"); XAttribute CodeLiteConfigurationName = new XAttribute("Name", CurConf.ToString()); CodeLiteConfiguration.Add(CodeLiteConfigurationName); // // Create Configuration General part. // XElement CodeLiteConfigurationGeneral = new XElement("General"); // // Create the executable filename. // string ExecutableToRun = ""; string PlatformConfiguration = "-" + ProjectPlatformName + "-" + CurConf.ToString(); if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Linux) { ExecutableToRun = "./" + TargetName; if ((ProjectTargetType == TargetType.Game) || (ProjectTargetType == TargetType.Program)) { if (CurConf != UnrealTargetConfiguration.Development) { ExecutableToRun += PlatformConfiguration; } } else if (ProjectTargetType == TargetType.Editor) { ExecutableToRun = "./UE4Editor"; if ((CurConf == UnrealTargetConfiguration.Debug) || (CurConf == UnrealTargetConfiguration.Shipping) || (CurConf == UnrealTargetConfiguration.Test)) { ExecutableToRun += PlatformConfiguration; } } } else if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac) { ExecutableToRun = "./" + TargetName; if ((ProjectTargetType == TargetType.Game) || (ProjectTargetType == TargetType.Program)) { if (CurConf != UnrealTargetConfiguration.Development) { ExecutableToRun += PlatformConfiguration; } ExecutableToRun += ".app/Contents/MacOS/" + TargetName; if (CurConf != UnrealTargetConfiguration.Development) { ExecutableToRun += PlatformConfiguration; } } else if (ProjectTargetType == TargetType.Editor) { ExecutableToRun = "./UE4Editor"; if ((CurConf == UnrealTargetConfiguration.Debug) || (CurConf == UnrealTargetConfiguration.Shipping) || (CurConf == UnrealTargetConfiguration.Test)) { ExecutableToRun += PlatformConfiguration; } ExecutableToRun += ".app/Contents/MacOS/UE4Editor"; if ((CurConf != UnrealTargetConfiguration.Development) && (CurConf != UnrealTargetConfiguration.DebugGame)) { ExecutableToRun += PlatformConfiguration; } } } else if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64 || BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win32) { ExecutableToRun = TargetName; if ((ProjectTargetType == TargetType.Game) || (ProjectTargetType == TargetType.Program)) { if (CurConf != UnrealTargetConfiguration.Development) { ExecutableToRun += PlatformConfiguration; } } else if (ProjectTargetType == TargetType.Editor) { ExecutableToRun = "UE4Editor"; if ((CurConf == UnrealTargetConfiguration.Debug) || (CurConf == UnrealTargetConfiguration.Shipping) || (CurConf == UnrealTargetConfiguration.Test)) { ExecutableToRun += PlatformConfiguration; } } ExecutableToRun += ".exe"; } else { throw new BuildException("Unsupported platform."); } // Is this project a Game type? XAttribute GeneralExecutableToRun = new XAttribute("Command", ExecutableToRun); if (ProjectTargetType == TargetType.Game) { if (CurConf.ToString().Contains("Debug")) { string commandArguments = " -debug"; XAttribute GeneralExecutableToRunArguments = new XAttribute("CommandArguments", commandArguments); CodeLiteConfigurationGeneral.Add(GeneralExecutableToRunArguments); } if (TargetName.Equals("UE4Game")) { XAttribute GeneralExecutableWorkingDirectory = new XAttribute("WorkingDirectory", UE4EditorWorkingDirectory); CodeLiteConfigurationGeneral.Add(GeneralExecutableWorkingDirectory); } else { XAttribute GeneralExecutableWorkingDirectory = new XAttribute("WorkingDirectory", GameWorkingDirectory); CodeLiteConfigurationGeneral.Add(GeneralExecutableWorkingDirectory); } } else if (ProjectTargetType == TargetType.Editor) { if (TargetName != "UE4Editor" && GameProjectFile != "") { string commandArguments = "\"" + GameProjectFile + "\"" + " -game"; XAttribute CommandArguments = new XAttribute("CommandArguments", commandArguments); CodeLiteConfigurationGeneral.Add(CommandArguments); } XAttribute WorkingDirectory = new XAttribute("WorkingDirectory", UE4EditorWorkingDirectory); CodeLiteConfigurationGeneral.Add(WorkingDirectory); } else if (ProjectTargetType == TargetType.Program) { XAttribute WorkingDirectory = new XAttribute("WorkingDirectory", UE4EditorWorkingDirectory); CodeLiteConfigurationGeneral.Add(WorkingDirectory); } else if (ProjectTargetType == TargetType.Client) { XAttribute WorkingDirectory = new XAttribute("WorkingDirectory", UE4EditorWorkingDirectory); CodeLiteConfigurationGeneral.Add(WorkingDirectory); } else if (ProjectTargetType == TargetType.Server) { XAttribute WorkingDirectory = new XAttribute("WorkingDirectory", UE4EditorWorkingDirectory); CodeLiteConfigurationGeneral.Add(WorkingDirectory); } CodeLiteConfigurationGeneral.Add(GeneralExecutableToRun); CodeLiteConfiguration.Add(CodeLiteConfigurationGeneral); // // End of Create Configuration General part. // // // Create Configuration Custom Build part. // XElement CodeLiteConfigurationCustomBuild = new XElement("CustomBuild"); CodeLiteConfiguration.Add(CodeLiteConfigurationGeneral); XAttribute CodeLiteConfigurationCustomBuildEnabled = new XAttribute("Enabled", "yes"); CodeLiteConfigurationCustomBuild.Add(CodeLiteConfigurationCustomBuildEnabled); // // Add the working directory for the custom build commands. // XElement CustomBuildWorkingDirectory = new XElement("WorkingDirectory"); XText CustuomBuildWorkingDirectory = new XText(UnrealBuildTool.GetUBTPath().Directory.FullName); CustomBuildWorkingDirectory.Add(CustuomBuildWorkingDirectory); CodeLiteConfigurationCustomBuild.Add(CustomBuildWorkingDirectory); // // End of Add the working directory for the custom build commands. // // // Make Build Target. // XElement CustomBuildCommand = new XElement("BuildCommand"); CodeLiteConfigurationCustomBuild.Add(CustomBuildCommand); string BuildTarget = TargetName + " " + ProjectPlatformName + " " + CurConf.ToString(); if ((BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win64) && (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win32)) { string PlatformName = "Linux"; if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac) { PlatformName = "Mac"; } BuildTarget = Path.Combine(UnrealBuildTool.EngineDirectory.FullName, "Build/BatchFiles", PlatformName, "Build.sh") + " " + BuildTarget; } else { BuildTarget = UnrealBuildTool.GetUBTPath().GetFileName() + " " + BuildTarget; } if (GameProjectFile.Length > 0) { BuildTarget += " -project=" + "\"" + GameProjectFile + "\""; } XText commandLine = new XText(BuildTarget); CustomBuildCommand.Add(commandLine); // // End of Make Build Target // // // Clean Build Target. // XElement CustomCleanCommand = new XElement("CleanCommand"); CodeLiteConfigurationCustomBuild.Add(CustomCleanCommand); string CleanTarget = BuildTarget + " -clean"; XText CleanCommandLine = new XText(CleanTarget); CustomCleanCommand.Add(CleanCommandLine); // // End of Clean Build Target. // // // Rebuild Build Target. // XElement CustomRebuildCommand = new XElement("RebuildCommand"); CodeLiteConfigurationCustomBuild.Add(CustomRebuildCommand); string RebuildTarget = CleanTarget + "\n" + BuildTarget; XText RebuildCommandLine = new XText(RebuildTarget); CustomRebuildCommand.Add(RebuildCommandLine); // // End of Clean Build Target. // // // Some other fun Custom Targets. // if (ProjectTargetType == TargetType.Game) { string CookGameCommandLine = "mono AutomationTool.exe BuildCookRun "; // Projects filename if (OnlyGameProject != null) { CookGameCommandLine += "-project=\"" + OnlyGameProject.FullName + "\" "; } // Disables Perforce functionality CookGameCommandLine += "-noP4 "; // Do not kill any spawned processes on exit CookGameCommandLine += "-nokill "; CookGameCommandLine += "-clientconfig=" + CurConf.ToString() + " "; CookGameCommandLine += "-serverconfig=" + CurConf.ToString() + " "; CookGameCommandLine += "-platform=" + ProjectPlatformName + " "; CookGameCommandLine += "-targetplatform=" + ProjectPlatformName + " "; // TODO Maybe I can add all the supported one. CookGameCommandLine += "-nocompile "; CookGameCommandLine += "-compressed -stage -deploy"; // // Cook Game. // XElement CookGame = new XElement("Target"); XAttribute CookGameName = new XAttribute("Name", "Cook Game"); XText CookGameCommand = new XText(CookGameCommandLine + " -cook"); CookGame.Add(CookGameName); CookGame.Add(CookGameCommand); CodeLiteConfigurationCustomBuild.Add(CookGame); XElement CookGameOnTheFly = new XElement("Target"); XAttribute CookGameNameOnTheFlyName = new XAttribute("Name", "Cook Game on the fly"); XText CookGameOnTheFlyCommand = new XText(CookGameCommandLine + " -cookonthefly"); CookGameOnTheFly.Add(CookGameNameOnTheFlyName); CookGameOnTheFly.Add(CookGameOnTheFlyCommand); CodeLiteConfigurationCustomBuild.Add(CookGameOnTheFly); XElement SkipCook = new XElement("Target"); XAttribute SkipCookName = new XAttribute("Name", "Skip Cook Game"); XText SkipCookCommand = new XText(CookGameCommandLine + " -skipcook"); SkipCook.Add(SkipCookName); SkipCook.Add(SkipCookCommand); CodeLiteConfigurationCustomBuild.Add(SkipCook); } // // End of Some other fun Custom Targets. // CodeLiteConfiguration.Add(CodeLiteConfigurationCustomBuild); // // End of Create Configuration Custom Build part. // CodeLiteSettings.Add(CodeLiteConfiguration); } CodeLiteSettings.Add(CodeLiteGlobalSettings); // // Save the XML file. // CodeLiteProject.Save(ProjectTargetFileName); bSuccess = true; } return(bSuccess); }
/// <summary> /// Constructs a new instance of the <see cref="Target"/> class /// </summary> /// <param name="endpoint"></param> internal Target(TargetType endpoint) { this.Endpoint = endpoint; this.Id = null; }
public static TargetResult CheckTarget(TargetType Target, RequestType request) { MatchFunctions[XacmlFunctions.STRING_EQUAL] = new StringEqual(); ContextHandler ch = new ContextHandler(); int numberOfMatchAnyOf = 0; int numberOfNoMatchAnyOf = 0; int numberOfIndeterminateAnyOf = 0; if (Target != null) { if (Target.AnyOf != null) { foreach (AnyOfType AnyOf in Target.AnyOf) { int numberOfMatchAllOf = 0; int numberOfIndeterminateAllOf = 0; int numberOfNoMatchAllOf = 0; AllOfType[] AllOfs = AnyOf.AllOf; foreach (AllOfType AllOf in AllOfs) { int numberOfFalseMatch = 0; int numberOfIndeterminateMatch = 0; MatchType[] Matches = AllOf.Match; try { foreach (MatchType Match in Matches) { AttributeDesignatorType AttributeDesignator = Match.Item as AttributeDesignatorType; AttributeValueType AttributeValue = Match.AttributeValue; List <AttributeType> Attributes = AttributeDesignatorManager.RequestBagOfValues(AttributeDesignator, request); int numberOfMatch = 0; if (Attributes.Count == 0) { // bag of values je prazan, provera atributa MustBePresented if (AttributeDesignator.MustBePresent) { // TODO zahteva dobavljanje atributa od PIP if (AttributeDesignator.Category.Equals(XacmlSubject.CATEGORY)) { string subjectId = SubjectIdResolver.SubjectId(request); if (!(subjectId == null)) { Attributes = ch.RequestForSubjectAttribute(AttributeDesignator, subjectId); } else { Attributes = null; } } else { Attributes = ch.RequestForEnvironmentAttribute(AttributeDesignator); } // ako PIP ne vrati atribut - zbog true vrednosti MustBePresented if (Attributes != null) { if (Attributes[0] == null) { numberOfIndeterminateMatch++; continue; } } else { numberOfIndeterminateMatch++; continue; } if (Attributes.Count == 0) { numberOfIndeterminateMatch++; continue; } } } string attributeValue = string.Empty; foreach (AttributeType attr in Attributes) { AttributeValueType[] attrValues = attr.AttributeValue; foreach (AttributeValueType attrValue in attrValues) { XmlNode node = attrValue.Any[0]; attributeValue = node.Value; } string value = AttributeValue.Any[0].Value.ToString(); // evaluacija prema funkciji definisanoj MatchId atributom bool decision = MatchFunctions[Match.MatchId].CheckIfMatch(ref value, ref attributeValue); if (decision) { numberOfMatch++; } } if (numberOfMatch == 0) { numberOfFalseMatch++; } } } catch (Exception) { numberOfIndeterminateMatch++; } /// AllOf evaluacija if (numberOfFalseMatch != 0) { numberOfNoMatchAllOf++; } else if (numberOfIndeterminateMatch > 0) { numberOfIndeterminateAllOf++; } else if (numberOfFalseMatch == 0 && numberOfIndeterminateMatch == 0) { numberOfMatchAllOf++; } } /// AnyOf evaluacija if (numberOfIndeterminateAllOf > 0 && numberOfMatchAllOf == 0) { numberOfIndeterminateAnyOf++; } else if (numberOfMatchAllOf > 0) { numberOfMatchAnyOf++; } else if (numberOfNoMatchAllOf > 0) { numberOfNoMatchAnyOf++; } } } else { // empty target return(TargetResult.Match); } } else { // empty target return(TargetResult.Match); } if (numberOfNoMatchAnyOf > 0) { return(TargetResult.NoMatch); } else if (numberOfMatchAnyOf > 0 && numberOfIndeterminateAnyOf == 0) { return(TargetResult.Match); } else { return(TargetResult.Indeterminate); } }
public void AssignTarget(Transform target, TargetType idleMoving, string context) { targetsToActUpon.Add(new TrackTargetEvent(target, idleMoving, context)); }