/// <summary>Removes a value.</summary> /// <typeparam name="T">The type of value.</typeparam> /// <param name="structure">The structure to remove the value from.</param> /// <param name="value">The value to be removed.</param> public static void Remove <T>(this IRemovable <T> structure, T value) { if (!structure.TryRemove(value, out Exception exception)) { throw exception; } }
public override void OnPlayerControlTick() { if (!Host.IsServer) { return; } using (Prediction.Off()) { if (this.prop.IsValid()) { this.prop.Delete(); this.prop = null; return; } if (this.removable != null) { this.removable.Remove(); this.removable = null; return; } var input = Owner.Input; if (!input.Pressed(InputButton.Attack1)) { return; } var startPos = Owner.EyePos; var dir = Owner.EyeRot.Forward; var tr = Trace.Ray(startPos, startPos + dir * MaxTraceDistance) .Ignore(Owner) .Run(); if (!tr.Hit || !tr.Entity.IsValid() || tr.Entity.IsWorld) { return; } if (tr.Entity is IRemovable removable) { this.removable = removable; return; } if (tr.Entity is Prop prop) { prop.PhysicsGroup?.Wake(); this.prop = prop; return; } } }
/// <summary>Removes a value.</summary> /// <typeparam name="T">The type of value.</typeparam> /// <param name="structure">The structure to remove the value from.</param> /// <param name="value">The value to be removed.</param> public static void Remove <T>(this IRemovable <T> structure, T value) { if (!structure.TryRemove(value, out Exception? exception)) { throw exception ?? new ArgumentException(nameof(exception), $"{nameof(Remove)} failed but the {nameof(exception)} is null");; } }
/// <summary>Removes a value from a data structure.</summary> /// <typeparam name="T">The type of values stored in this data structure.</typeparam> /// <param name="removable">The data structure to removable the value from.</param> /// <param name="value">The value to remove from the data structure.</param> public static void Remove <T>(this IRemovable <T> removable, T value) { var(success, exception) = removable.TryRemove(value); if (!success) { throw exception ?? new ArgumentException($"{nameof(Remove)} failed but the {nameof(exception)} is null"); } }
private static void RemoveItemsMethod(IRemovable collection, int numberToRemove) { for (int i = 0; i < numberToRemove; i++) { Console.Write(collection.RemoveItem() + " "); } Console.WriteLine(); }
private static void RemoveElementsFromCollection(StringBuilder sBuilder, IRemovable collection, int numberOfRemoves) { for (int i = 0; i < numberOfRemoves; i++) { sBuilder.Append(collection.Remove()); sBuilder.Append(" "); } sBuilder.AppendLine(); }
private static void RemoveElementsFromCollection(IRemovable addRemoveCollection, int countRemoveElements) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < countRemoveElements; i++) { sb.Append(addRemoveCollection.Remove()) .Append(' '); } Console.WriteLine(sb.ToString().Trim()); }
/// <summary>Wrapper for the "Remove" method to help with exceptions.</summary> /// <typeparam name="T">The generic type of the structure.</typeparam> /// <param name="structure">The structure.</param> /// <param name="removal">The item to be removed.</param> /// <returns>True if successful, False if not.</returns> public static bool TryRemove <T>(this IRemovable <T> structure, T removal) { try { structure.Remove(removal); return(true); } catch { return(false); } }
/// <summary> /// Remove an item from the <see cref="IPagedDataSet"/> with the specified position /// </summary> /// <param name="dataSet">The dataset to modify</param> /// <param name="offset">The position to remove relative to the dataset's caret</param> /// <returns></returns> public static async Task RemoveAtOffset(this IRemovable removable, IPagedDataSet dataSet, int offset) { var pi = await dataSet.GetCurrentPageIndex(); var ps = await dataSet.GetPageSize(); var sel = await dataSet.GetSelector(); if (sel == null) { throw new InvalidOperationException("The paged data set does not support selecting items that is required for this method to work"); } await removable.RemoveAt(dataSet, pi *ps + offset + await sel.GetCaretPosition()); }
public linkFactory2(IRemovable owner) { init_Identity(); init_StorageLinks(); owner.event_ObjectDeleted += handler_ownerDelete; unsubscribeOwner = () => { if (owner != null) { owner.event_ObjectDeleted -= handler_ownerDelete; } unsubscribeOwner = null; }; }
/// <summary>Wrapper for the "Remove" method to help with exceptions.</summary> /// <typeparam name="T">The generic type of the structure.</typeparam> /// <param name="structure">The data structure.</param> /// <param name="removal">The item to be removed.</param> /// <returns>True if successful, False if not.</returns> public static bool TryRemove <T>(this IRemovable <T> structure, T removal) { // Note: This is most likely a bad practice. try-catch-ing should // not be used for control flow like this. I will likely be moving this // method into the "IRemovable<T>" interface in the future. try { structure.Remove(removal); return(true); } catch { return(false); } }
private void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId)) { if (touch.phase == TouchPhase.Began) { if (m_selectedTool == Tool.place) { if (Stats.Sheet.m_rockCount < m_maxStones) { Ray ray = m_mainCamera.ScreenPointToRay(touch.position); RaycastHit hit; if (Physics.Raycast(ray, out hit, m_terrainLayer)) { if (m_placeAllowed) { if (hit.point.y < m_maxRockHeight) { StartCoroutine(DelayRock()); Vector3 spawnPoint = hit.point + m_placeOffset; ObjectPooler.SpawnObject(m_rockName, spawnPoint + m_placeOffset, Quaternion.identity, true); Stats.Sheet.m_rockCount++; } } } } } else { Ray ray = m_mainCamera.ScreenPointToRay(touch.position); RaycastHit hit; if (Physics.Raycast(ray, out hit, m_removeLayer)) { IRemovable removable = hit.collider.GetComponent <IRemovable>(); if (removable != null) { removable.OnRemove(); } } } } } } }
public void CheckRemovables() { for (int i = _gameobjects.Count - 1; i >= 0; i--) { GameObject go = _gameobjects[i]; // remove if (go is IRemovable) { IRemovable rmv = go as IRemovable; if (rmv.RemoveMe == true) { _gameobjects.Remove(go); } } } }
/// <summary> /// Add midi signal /// </summary> /// <param name="midiType">type of midi signal</param> private void AddMidi(MidiSignalTypes midiType, BaseMidiSignal midiSignal) { IRemovable midiVM = null; switch (midiType) { case MidiSignalTypes.MidiCC: if (midiSignal == null) { midiSignal = new MidiCC(); m_conditionsBlock.MidiSignals.Add(midiSignal); } midiVM = new MidiCCViewModel((MidiCC)midiSignal); break; case MidiSignalTypes.MidiNote: if (midiSignal == null) { midiSignal = new MidiNote(); m_conditionsBlock.MidiSignals.Add(midiSignal); } midiVM = new MidiNoteViewModel((MidiNote)midiSignal); break; } if (midiVM != null) { MidiSignals.Add(midiVM); //add remove delegate midiVM.DelegateToRemove = () => { m_conditionsBlock.MidiSignals.Remove(midiSignal); MidiSignals.Remove(midiVM); }; } }
/// <summary> /// Add condition /// </summary> /// <param name="conditionType">type of condition</param> private void AddCondition(ConditionTypes conditionType, BaseCondition condition) { IRemovable conditionVM = null; switch (conditionType) { case ConditionTypes.SkeletonPointToCordinate: if (condition == null) { condition = new CuboidCondition(); m_conditionsBlock.Conditions.Add(condition); } conditionVM = new SkeletonPointToCubeViewModel((CuboidCondition)condition); break; case ConditionTypes.SkeletonPointToSkeletonPoint: if (condition == null) { condition = new RelatedSphereCondition(); m_conditionsBlock.Conditions.Add(condition); } conditionVM = new SkeletonPointToSkeletonPointViewModel((RelatedSphereCondition)condition); break; } if (conditionVM != null) { Conditions.Add(conditionVM); //add remove delegate conditionVM.DelegateToRemove = () => { m_conditionsBlock.Conditions.Remove(condition); Conditions.Remove(conditionVM); }; } }
private static void RemoveElementsFromCollection(StringBuilder builder, int numberOfRemoveOperations, IRemovable collection) { for (int i = 0; i < numberOfRemoveOperations; i++) { builder.Append(collection.Remove()) .Append(' '); } builder.AppendLine(); }
public TaskExecutionToken(ITask task, IRemovable <ITask> remover) { _task = task; _remover = remover; _currentState = TokenState.Undefined; }
/// <summary>Tries to removes a value.</summary> /// <typeparam name="T">The type of value.</typeparam> /// <param name="structure">The structure to remove the value from.</param> /// <param name="value">The value to be removed.</param> /// <returns>True if the remove was successful or false if not.</returns> public static bool TryRemove <T>(this IRemovable <T> structure, T value) { return(structure.TryRemove(value, out _)); }
/// <summary> /// Remove an item from the <see cref="IPagedDataSet"/> with the specified position /// </summary> /// <param name="dataSet">The dataset to modify</param> /// <param name="index">The position to remove</param> /// <returns></returns> public static async Task RemoveAt(this IRemovable removable, IPagedDataSet dataSet, int index) => await removable.Remove((await dataSet.GetDataSource()).ElementAtOrDefault(index));
public override void OnPlayerControlTick() { if (!Host.IsServer) { return; } using (Prediction.Off()) { if (prop.IsValid()) { prop.Delete(); prop = null; return; } if (this.removable != null) { this.removable.Remove(); this.removable = null; return; } var input = Owner.Input; if (!input.Pressed(InputButton.Attack1)) { return; } var startPos = Owner.EyePos; var dir = Owner.EyeRot.Forward; var tr = Trace.Ray(startPos, startPos + dir * MaxTraceDistance) .Ignore(Owner) .HitLayer(CollisionLayer.Debris) .Run(); if (!tr.Hit || !tr.Entity.IsValid()) { return; } if (tr.Entity.IsValid()) { if (Owner != tr.Entity.Owner) { return; } } CreateHitEffects(tr.EndPos); if (tr.Entity.IsWorld) { return; } if (tr.Entity is IRemovable removable) { this.removable = removable; } else if (tr.Entity is Prop prop) { prop.PhysicsGroup?.Wake(); this.prop = prop; } else { return; } var particle = Particles.Create("particles/physgun_freeze.vpcf"); particle.SetPos(0, tr.Entity.WorldPos); } }
public Task SetRemover(IRemovable <TItem> remover) { _remover = remover; return(Task.CompletedTask); }
public Engine() { this.addCollection = new AddCollection(); this.addRemoveCollection = new AddRemoveCollection(); this.myListCollection = new MyList(); }
public AceTableViewSource(IRemovable removableModel,UITableView tableView, Type cellType, string cellIdentifier = null) : base(tableView,cellType,cellIdentifier) { tableView.RegisterClassForCellReuse(cellType, cellType.Name); this.RemovableViewModel = removableModel; }
public Delete(IRemovable iRemovableItem) { InitializeComponent(); _iRemovableItem = iRemovableItem; }
public static bool IsRemoved(this IRemovable removable) { return(removable.IsRemoved); }
public UserProfileRepository(ApplicationDbContext dbContext) : base(dbContext) { removableBehavior = new RemovableBehavior <UserProfile, UserProfileMapper>(this); }
public PagedDataSetBuilder <TItem, TResult> WithRemover(IRemovable <TItem> remover) => WithRemover(x => Task.FromResult(remover));