/// <summary> /// Resets the cache for the specified ModifiableStat /// </summary> private void ResetCache(ModifiableStat resetFor) { int cacheSize = _cache.Length; for (int i = 0; i < cacheSize; ++i) { if (_cache[i].stat == resetFor) { _cache[i].isValid = false; return; } } // If here, need to create Cache. if (_cache[cacheSize - 1].stat != ModifiableStat.None) { // Have to add an entry to the array first. _cache = AHArray.Added(_cache, new ModifierCache() { stat = ModifiableStat.None, isValid = false }); cacheSize += 1; } // Use the next available entry as the cache. for (int i = 0; i < cacheSize; ++i) { if (_cache[i].stat == ModifiableStat.None) { _cache[i].stat = resetFor; break; } } }
/// <summary> /// Adds a new InventorySpace to the list of spaces in this /// InventoryView. /// </summary> public void Add(InventorySpace space) { int index = -1; for (int i = 0; i < _sets.Length; ++i) { if (_sets[i].space == null) { _sets[i].Set(space); index = i; break; } } if (index != -1) { index = _sets.Length; // Otherwise, have to grow array. This should happen rarely, if ever. Debug.LogWarning("Growing array in InventoryView from [" + index + "]"); _sets = AHArray.Added(_sets, new InventoryViewSet()); _sets[index].Set(space); } ++_count; if (Active) { Filter(_sets[index]); Sort(_sets[index]); } }
/// <summary> /// Add a HardPoint into the group, if it doesn't already exist. /// </summary> /// <param name="hardpoint">The HardPoint to add to the group.</param> /// <returns>True if the hardpoint was added, false if it already is in the group.</returns> public bool Add(Hardpoint hardpoint) { if (Contains(hardpoint.name)) { return(false); } hardpoints = AHArray.Added(hardpoints, hardpoint); return(true); }
/// <summary> /// Remove the specified socket from the socket group. /// </summary> /// <param name="socketName">The name of the socket to remove.</param> /// <returns>The ShipSocket that was removed, or null if the socket wasn't found.</returns> public Hardpoint Remove(string socketName) { for (int i = 0; i < hardpoints.Length; ++i) { if (hardpoints[i].name == socketName) { Hardpoint hardpoint = hardpoints[i]; hardpoints = AHArray.Removed(hardpoints, i); return(hardpoint); } } return(null); }
/// <summary> /// Register a new component into the system list. If the component has /// autoEnable true, then it will try and enable the component as well. /// </summary> public void Register(SystemComponent component) { if (component.autoEnable) { _auto = AHArray.Added(_auto, component); if (component.Activate() != OperationResult.Status.OK) { ++_autoDisabled; } } else { _manual = AHArray.Added(_manual, component); } }