Here are the examples of the csharp api System.Collections.Generic.List.RemoveAt(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
7926 Examples
19
Source : IntraLineViewportAdornmentManager.cs
with MIT License
from Actipro
with MIT License
from Actipro
private AdornmentElement GetCachedElement(object tag) {
AdornmentElement targetElement = null;
if (tag != null) {
for (var index = cachedElements.Count - 1; index >= 0; index--) {
var tagRef = cachedElements[index].Item1;
if (tagRef.IsAlive) {
// If there is a tag match, use the cached element and remove the entry
if (tagRef.Target == tag) {
targetElement = cachedElements[index].Item2;
cachedElements.RemoveAt(index);
}
}
else {
// Remove the entry
cachedElements.RemoveAt(index);
}
}
}
return targetElement;
}
19
Source : NodeSet.cs
with MIT License
from active-logic
with MIT License
from active-logic
public Node<T> Pop(){
int i = list.Count-1;
var n = list[i];
list.RemoveAt(i);
return n;
}
19
Source : SidePanel.cs
with GNU General Public License v3.0
from Adam-Wilkinson
with GNU General Public License v3.0
from Adam-Wilkinson
public void FinishControlDrag()
{
int i = 0;
while (i < layers.Count)
{
if (layers[i].Controls.Count == 0)
{
layers[i].DrawingCanvas?.Children.Remove(layers[i].LayerResizer);
layers.RemoveAt(i);
}
else
{
i++;
}
}
}
19
Source : SidePanelLayer.cs
with GNU General Public License v3.0
from Adam-Wilkinson
with GNU General Public License v3.0
from Adam-Wilkinson
public void RemoveControlAt(int index)
{
ToolbarManager grip = Controls[index];
ToolbarManager gripWithResizer = index < Controls.Count - 1 || index == 0 ? grip : Controls[index - 1];
DrawingCanvas?.Children.Remove(gripWithResizer.Resizer);
grip.SidePanelLayer = null;
grip.Index = -1;
Controls.RemoveAt(index);
for (int i = 0; i < Controls.Count; i++)
{
Controls[i].ToolbarWidth += grip.ToolbarWidth / Controls.Count;
Controls[i].Index = i;
}
if (Controls.Count == 0)
{
Depth = 0;
}
}
19
Source : ObservableList.cs
with MIT License
from Adam4lexander
with MIT License
from Adam4lexander
public void RemoveAt(int index) {
var item = m_list[index];
m_list.RemoveAt(index);
syncToPrevList();
ItemRemoved?.Invoke(item);
OnChanged?.Invoke();
}
19
Source : ObservableList.cs
with MIT License
from Adam4lexander
with MIT License
from Adam4lexander
void syncToPrevList() {
// No need to do this stuff if not in the editor
if (!Application.isEditor) {
return;
}
for (int i = 0; i < m_list.Count; i++) {
if (i < prevList.Count) {
prevList[i] = m_list[i];
} else {
prevList.Add(m_list[i]);
}
}
for (int i = prevList.Count - 1; i >= m_list.Count; i--) {
prevList.RemoveAt(i);
}
prevListInitialized = true;
}
19
Source : ChildrenCodeTemplate.cs
with MIT License
from adamant
with MIT License
from adamant
public string PopIndent()
{
string returnValue = "";
if ((this.indentLengths.Count > 0))
{
int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
if ((indentLength > 0))
{
returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
}
}
return returnValue;
}
19
Source : HookInterceptor.cs
with MIT License
from AdamCarballo
with MIT License
from AdamCarballo
private static bool IsSecure(ref List<string> payload) {
var secured = true;
if (payload[0].StartsWith(UrlSecurity)) {
// Remove secure key scheme from payload
payload[0] = payload[0].Replace(UrlSecurity, string.Empty);
if (!_preferences.UseSecureHooks) {
LogVerbose("Payload contains a security key, but 'Use secure hooks' is disabled, ignoring key...");
} else {
LogVerbose("Payload contains a security key, checking...");
secured = payload[0] == _preferences.SecureKey;
}
// Remove secure key from payload
payload.RemoveAt(0);
} else {
if (_preferences.UseSecureHooks) {
LogDebug("Payload does not contain a security key, but 'Use secure hooks' is enabled");
secured = false;
} else {
LogVerbose("No security key found in payload");
}
}
return secured;
}
19
Source : WorldManager.cs
with MIT License
from adamgoodrich
with MIT License
from adamgoodrich
void RaiseEvent()
{
//Exit if we are not active
if (!m_worldAPIActive)
{
return;
}
//Exit if nothing changed
if (m_changeMask == 0)
{
return;
}
// Go backwards in list in case someone removes a listener
for (var n = m_listeners.Count - 1; n >= 0; --n)
{
var listener = m_listeners[n];
//Remove it if it no longer exists
if (listener == null)
{
m_listeners.RemoveAt(n);
continue;
}
//Send the message, trap errors, remove listener if it generates errots
try
{
listener.OnWorldChanged(new WorldChangeArgs(m_changeMask, this));
}
catch (System.Exception e)
{
//Tell world about it
Debug.LogException(e, this);
//Remove the listener that causes the exception so remaining stuff continues to work
Debug.LogError("Removed listener because it caused error");
m_listeners.RemoveAt(n);
}
}
}
19
Source : paragraph_builder.cs
with MIT License
from adamped
with MIT License
from adamped
public void Pop()
{
if (style_stack_.Count == 0)
{
return;
}
style_stack_.RemoveAt(style_stack_.Count - 1);
runs_.StartRun(PeekStyleIndex(), text_.Count);
}
19
Source : styled_runs.cs
with MIT License
from adamped
with MIT License
from adamped
public void EndRunIfNeeded(int end)
{
if (runs_.Count == 0)
{
return;
}
IndexedRun run = runs_[runs_.Count - 1];
if (run.start == end)
{
// The run is empty. We can skip it.
runs_.RemoveAt(runs_.Count - 1);
}
else
{
//C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy replacedignment (rather than a reference replacedignment) - this should be verified and a 'CopyFrom' method should be created:
//ORIGINAL LINE: run.end = end;
run.end = end;
}
}
19
Source : MatrixSolve.cs
with GNU General Public License v3.0
from AdamWhiteHat
with GNU General Public License v3.0
from AdamWhiteHat
public static void GaussianSolve(CancellationToken cancelToken, GNFS gnfs)
{
Serialization.Save.Relations.Smooth.Append(gnfs); // Persist any relations not already persisted to disk
// Because some operations clear this collection after persisting unsaved relations (to keep memory usage light)...
// We completely reload the entire relations collection from disk.
// This ensure that all the smooth relations are available for the matrix solving step.
Serialization.Load.Relations.Smooth(ref gnfs);
List<Relation> smoothRelations = gnfs.CurrentRelationsProgress.SmoothRelations.ToList();
int smoothCount = smoothRelations.Count;
BigInteger requiredRelationsCount = gnfs.CurrentRelationsProgress.SmoothRelationsRequiredForMatrixStep;
gnfs.LogFunction($"Total relations count: {smoothCount}");
gnfs.LogFunction($"Relations required to proceed: {requiredRelationsCount}");
while (smoothRelations.Count >= requiredRelationsCount)
{
// Randomly select n relations from smoothRelations
List<Relation> selectedRelations = new List<Relation>();
while (
selectedRelations.Count < requiredRelationsCount
||
selectedRelations.Count % 2 != 0 // Force number of relations to be even
)
{
int randomIndex = StaticRandom.Next(0, smoothRelations.Count);
selectedRelations.Add(smoothRelations[randomIndex]);
smoothRelations.RemoveAt(randomIndex);
}
GaussianMatrix gaussianReduction = new GaussianMatrix(gnfs, selectedRelations);
gaussianReduction.TransposeAppend();
gaussianReduction.Elimination();
int number = 1;
int solutionCount = gaussianReduction.FreeVariables.Count(b => b) - 1;
List<List<Relation>> solution = new List<List<Relation>>();
while (number <= solutionCount)
{
List<Relation> relations = gaussianReduction.GetSolutionSet(number);
number++;
BigInteger algebraic = relations.Select(rel => rel.AlgebraicNorm).Product();
BigInteger rational = relations.Select(rel => rel.RationalNorm).Product();
CountDictionary algCountDict = new CountDictionary();
foreach (var rel in relations)
{
algCountDict.Combine(rel.AlgebraicFactorization);
}
bool isAlgebraicSquare = algebraic.IsSquare();
bool isRationalSquare = rational.IsSquare();
gnfs.LogFunction("---");
gnfs.LogFunction($"Relations count: {relations.Count}");
gnfs.LogFunction($"(a,b) pairs: {string.Join(" ", relations.Select(rel => $"({rel.A},{rel.B})"))}");
gnfs.LogFunction($"Rational ∏(a+mb): IsSquare? {isRationalSquare} : {rational}");
gnfs.LogFunction($"Algebraic ∏ƒ(a/b): IsSquare? {isAlgebraicSquare} : {algebraic}");
gnfs.LogFunction($"Algebraic (factorization): {algCountDict.FormatStringAsFactorization()}");
if (isAlgebraicSquare && isRationalSquare)
{
solution.Add(relations);
gnfs.CurrentRelationsProgress.AddFreeRelationSolution(relations);
}
if (cancelToken.IsCancellationRequested)
{
break;
}
}
if (cancelToken.IsCancellationRequested)
{
break;
}
}
}
19
Source : Utilities.cs
with MIT License
from ADeltaX
with MIT License
from ADeltaX
public static string MakeRelativePath(string path, string basePath)
{
List<string> pathElements =
new List<string>(path.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries));
List<string> basePathElements =
new List<string>(basePath.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries));
if (!basePath.EndsWith("\\", StringComparison.Ordinal) && basePathElements.Count > 0)
{
basePathElements.RemoveAt(basePathElements.Count - 1);
}
// Find first part of paths that don't match
int i = 0;
while (i < Math.Min(pathElements.Count - 1, basePathElements.Count))
{
if (pathElements[i].ToUpperInvariant() != basePathElements[i].ToUpperInvariant())
{
break;
}
++i;
}
// For each remaining part of the base path, insert '..'
StringBuilder result = new StringBuilder();
if (i == basePathElements.Count)
{
result.Append(@".\");
}
else if (i < basePathElements.Count)
{
for (int j = 0; j < basePathElements.Count - i; ++j)
{
result.Append(@"..\");
}
}
// For each remaining part of the path, add the path element
for (int j = i; j < pathElements.Count - 1; ++j)
{
result.Append(pathElements[j]);
result.Append(@"\");
}
result.Append(pathElements[pathElements.Count - 1]);
// If the target was a directory, put the terminator back
if (path.EndsWith(@"\", StringComparison.Ordinal))
{
result.Append(@"\");
}
return result.ToString();
}
19
Source : Bin.cs
with MIT License
from ADeltaX
with MIT License
from ADeltaX
public void FreeCell(int index)
{
int freeIndex = index - _header.FileOffset;
int len = EndianUtilities.ToInt32LittleEndian(_buffer, freeIndex);
if (len >= 0)
{
throw new ArgumentException("Attempt to free non-allocated cell");
return;
}
len = Math.Abs(len);
// If there's a free cell before this one, combine
int i = 0;
while (i < _freeCells.Count && _freeCells[i].Offset < freeIndex)
{
if (_freeCells[i].Offset + _freeCells[i].Count == freeIndex)
{
freeIndex = _freeCells[i].Offset;
len += _freeCells[i].Count;
_freeCells.RemoveAt(i);
}
else
{
++i;
}
}
// If there's a free cell after this one, combine
if (i < _freeCells.Count && _freeCells[i].Offset == freeIndex + len)
{
len += _freeCells[i].Count;
_freeCells.RemoveAt(i);
}
// Record the new free cell
_freeCells.Insert(i, new Range<int, int>(freeIndex, len));
// Free cells are indicated by length > 0
EndianUtilities.WriteBytesLittleEndian(len, _buffer, freeIndex);
_fileStream.Position = _streamPos + freeIndex;
_fileStream.Write(_buffer, freeIndex, 4);
}
19
Source : Bin.cs
with MIT License
from ADeltaX
with MIT License
from ADeltaX
internal int AllocateCell(int size)
{
if (size < 8 || size % 8 != 0)
{
throw new ArgumentException("Invalid cell size");
}
// Very inefficient algorithm - will lead to fragmentation
for (int i = 0; i < _freeCells.Count; ++i)
{
int result = _freeCells[i].Offset + _header.FileOffset;
if (_freeCells[i].Count > size)
{
// Record the newly allocated cell
EndianUtilities.WriteBytesLittleEndian(-size, _buffer, _freeCells[i].Offset);
_fileStream.Position = _streamPos + _freeCells[i].Offset;
_fileStream.Write(_buffer, _freeCells[i].Offset, 4);
// Keep the remainder of the free buffer as unallocated
_freeCells[i] = new Range<int, int>(_freeCells[i].Offset + size, _freeCells[i].Count - size);
EndianUtilities.WriteBytesLittleEndian(_freeCells[i].Count, _buffer, _freeCells[i].Offset);
_fileStream.Position = _streamPos + _freeCells[i].Offset;
_fileStream.Write(_buffer, _freeCells[i].Offset, 4);
return result;
}
if (_freeCells[i].Count == size)
{
// Record the whole of the free buffer as a newly allocated cell
EndianUtilities.WriteBytesLittleEndian(-size, _buffer, _freeCells[i].Offset);
_fileStream.Position = _streamPos + _freeCells[i].Offset;
_fileStream.Write(_buffer, _freeCells[i].Offset, 4);
_freeCells.RemoveAt(i);
return result;
}
}
return -1;
}
19
Source : SubKeyHashedListCell.cs
with MIT License
from ADeltaX
with MIT License
from ADeltaX
internal void RemoveAt(int index)
{
_nameHashes.RemoveAt(index);
_subKeyIndexes.RemoveAt(index);
_numElements--;
}
19
Source : SubKeyIndirectListCell.cs
with MIT License
from ADeltaX
with MIT License
from ADeltaX
internal override int UnlinkSubKey(string name)
{
if (ListType == "ri")
{
if (CellIndexes.Count == 0)
{
throw new NotImplementedException("Empty indirect list");
}
for (int i = 0; i < CellIndexes.Count; ++i)
{
int tempIndex;
ListCell cell = _hive.GetCell<ListCell>(CellIndexes[i]);
if (cell.FindKey(name, out tempIndex) <= 0)
{
CellIndexes[i] = cell.UnlinkSubKey(name);
if (cell.Count == 0)
{
_hive.FreeCell(CellIndexes[i]);
CellIndexes.RemoveAt(i);
}
return _hive.UpdateCell(this, false);
}
}
}
else
{
for (int i = 0; i < CellIndexes.Count; ++i)
{
KeyNodeCell cell = _hive.GetCell<KeyNodeCell>(CellIndexes[i]);
if (string.Compare(name, cell.Name, StringComparison.OrdinalIgnoreCase) == 0)
{
CellIndexes.RemoveAt(i);
return _hive.UpdateCell(this, true);
}
}
}
return Index;
}
19
Source : Project.cs
with MIT License
from adrenak
with MIT License
from adrenak
private void ParsePath(string path)
{
//Unity's Application functions return the replacedets path in the Editor.
projectPath = path;
//pop off the last part of the path for the project name, keep the rest for the root path
List<string> pathArray = projectPath.Split(separator).ToList<string>();
name = pathArray.Last();
pathArray.RemoveAt(pathArray.Count() - 1);
rootPath = string.Join(separator[0].ToString(), pathArray.ToArray());
replacedetPath = projectPath + "/replacedets";
projectSettingsPath = projectPath + "/ProjectSettings";
libraryPath = projectPath + "/Library";
packagesPath = projectPath + "/Packages";
autoBuildPath = projectPath + "/AutoBuild";
localPackages = projectPath + "/LocalPackages";
}
19
Source : GenericExtensions.cs
with MIT License
from adrenak
with MIT License
from adrenak
public static T[] RemoveAt<T>(this T[] _array, int _position) {
List<T> list = _array.ToList();
list.RemoveAt(_position);
return list.ToArray();
}
19
Source : Coroutines.cs
with MIT License
from adrenak
with MIT License
from adrenak
public bool Update(float deltaTime) {
if (running.Count > 0) {
for (int i = 0; i < running.Count; i++) {
if (delays[i] > 0f)
delays[i] -= deltaTime;
else if (running[i] == null || !MoveNext(running[i], i)) {
running.RemoveAt(i);
delays.RemoveAt(i--);
}
}
return true;
}
return false;
}
19
Source : DLLCreatorWindow.cs
with MIT License
from adrenak
with MIT License
from adrenak
void DrawDefines() {
EditorGUILayout.BeginHorizontal();
{
EditorGUILayout.LabelField("Defines");
if (GUILayout.Button("Add"))
defines.Add(string.Empty);
EditorGUILayout.BeginVertical();
{
for (int i = 0; i < defines.Count; i++) {
var index = i;
EditorGUILayout.BeginHorizontal();
{
defines[i] = EditorGUILayout.TextField(defines[i]);
if (GUILayout.Button("Remove")) {
Debug.Log(index);
defines.RemoveAt(index);
}
}
EditorGUILayout.EndHorizontal();
}
}
EditorGUILayout.EndVertical();
}
EditorGUILayout.EndHorizontal();
}
19
Source : DLLCreatorWindow.cs
with MIT License
from adrenak
with MIT License
from adrenak
void DrawCode() {
EditorGUILayout.BeginHorizontal();
{
EditorGUILayout.LabelField("Source");
if (GUILayout.Button("Add"))
codes.Add(new Object());
EditorGUILayout.BeginVertical();
{
for (int i = 0; i < codes.Count; i++) {
var index = i;
EditorGUILayout.BeginHorizontal();
{
codes[i] = EditorGUILayout.ObjectField(codes[i], typeof(Object), false);
if (GUILayout.Button("Remove"))
codes.RemoveAt(index);
}
EditorGUILayout.EndHorizontal();
}
}
EditorGUILayout.EndVertical();
}
EditorGUILayout.EndHorizontal();
}
19
Source : Program.cs
with GNU General Public License v3.0
from AdvancedHacker101
with GNU General Public License v3.0
from AdvancedHacker101
public dnsRequest runXML()
{
dnsRequest copy = req;
if (authoritiveProtection)
{
List<int> auth = new List<int>();
int t = 0;
foreach (dnsRequest.GeneralRecord gr in copy.records)
{
if (gr.resource_type == dnsRequest.DnsResourceType.Authority)
{
auth.Add(t);
}
t++;
}
foreach (int i in auth)
{
copy.records.RemoveAt(i);
}
authoritiveProtection = false;
}
foreach (string item in blackList)
{
if (copy.response == (int)dnsRequest.DnsResponse.response)
{
bool removeResp = true;
foreach (dnsRequest.GeneralRecord gr in copy.records)
{
if (gr.rType == (int)dnsRequest.DnsResourceType.Query)
{
if (gr.rName == item)
{
removeResp = true;
copy.return_code = (int)dnsRequest.DnsReturnCodes.NonExistentDomain;
}
}
}
if (removeResp)
{
List<dnsRequest.GeneralRecord> lcpy = new List<dnsRequest.GeneralRecord>();
foreach (dnsRequest.GeneralRecord r in lcpy)
{
if (r.resource_type != (int)dnsRequest.DnsResourceType.Query)
{
copy.records.Remove(r);
}
}
copy.additional_resource_record_count = 0;
copy.answer_resource_record_count = 0;
copy.authority_resource_record_count = 0;
break;
}
}
}
foreach (string item in redirect)
{
if (copy.response == (int)dnsRequest.DnsResponse.response)
{
int i = 0;
bool canBreak = false;
List<int> authoritive = new List<int>();
foreach (dnsRequest.GeneralRecord gr in copy.records)
{
if (gr.resource_type == dnsRequest.DnsResourceType.Answer && copy.return_code == (int)dnsRequest.DnsReturnCodes.Success)
{
if (copy.records[i].rName == item.Split(':')[0])
{
((dnsRequest.AnswerRecord)copy.records[i]).result = item.Split(':')[1];
canBreak = true;
}
}
i++;
}
if (canBreak)
{
authoritiveProtection = true;
break;
}
}
}
return copy;
}
19
Source : kcp.cs
with Apache License 2.0
from advancer68
with Apache License 2.0
from advancer68
private void Parse_ack(int sn)
{
if (_itimediff(sn, snd_una) < 0 || _itimediff(sn, snd_nxt) >= 0)
{
return;
}
for (int i = 0; i < snd_buf.Count; i++)
{
Segment seg = snd_buf[i];
if (sn == seg.sn)
{
snd_buf.RemoveAt(i);
SegmentDelete(seg);
break;
}
if (_itimediff(sn, seg.sn) < 0)
{
break;
}
}
}
19
Source : LocationPatches.cs
with GNU General Public License v3.0
from aedenthorn
with GNU General Public License v3.0
from aedenthorn
private static void GetSpouseRooms(FarmHouse fh, List<string> orderableSpouses, out List<string> orderedSpouses, out List<string> customSpouses)
{
customSpouses = new List<string>();
for (int i = orderableSpouses.Count - 1; i >= 0; i--)
{
if (ModEntry.customRoomData.ContainsKey(orderableSpouses[i]) &&
(ModEntry.customRoomData[orderableSpouses[i]].upgradeLevel == fh.upgradeLevel || ModEntry.customRoomData[orderableSpouses[i]].upgradeLevel < 0) &&
ModEntry.customRoomData[orderableSpouses[i]].startPos.X > -1
)
{
customSpouses.Add(orderableSpouses[i]);
orderableSpouses.RemoveAt(i);
}
}
orderedSpouses = new List<string>();
string[] roomOrder = Config.SpouseRoomOrder.Split(',');
foreach (string str in roomOrder)
{
string s = str.Trim();
if (orderableSpouses.Contains(s))
{
orderedSpouses.Add(s);
orderableSpouses.Remove(s);
}
}
foreach (string str in orderableSpouses)
{
orderedSpouses.Add(str);
Config.SpouseRoomOrder += (Config.SpouseRoomOrder.Trim().Length > 0 ? "," : "") + str;
}
Helper.WriteConfig(Config);
}
19
Source : BatFamiliar.cs
with GNU General Public License v3.0
from aedenthorn
with GNU General Public License v3.0
from aedenthorn
protected override void updateAnimation(GameTime time)
{
if (followingOwner)
{
Sprite.Animate(time, 0, 4, 80f);
if (Sprite.currentFrame % 3 == 0 && Utility.isOnScreen(Position, 512) && (batFlap == null || !batFlap.IsPlaying) && Game1.soundBank != null && currentLocation == Game1.currentLocation && !cursedDoll)
{
batFlap = Game1.soundBank.GetCue("batFlap");
//batFlap.Play();
}
if (cursedDoll.Value)
{
shakeTimer -= time.ElapsedGameTime.Milliseconds;
if (shakeTimer < 0)
{
if (!hauntedSkull.Value)
{
currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("Maps\\springobjects", Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 103, 16, 16), position + new Vector2(0f, -32f), false, 0.1f, new Color(255, 50, 255) * 0.8f)
{
scale = 4f
});
}
shakeTimer = 50;
}
previousPositions.Add(Position);
if (previousPositions.Count > 8)
{
previousPositions.RemoveAt(0);
}
}
}
else
{
Sprite.currentFrame = 4;
Halt();
}
resetAnimationSpeed();
}
19
Source : SkullBoss.cs
with GNU General Public License v3.0
from aedenthorn
with GNU General Public License v3.0
from aedenthorn
protected override void updateAnimation(GameTime time)
{
if (base.focusedOnFarmers || this.withinPlayerThreshold(20) || this.seenPlayer)
{
this.Sprite.Animate(time, 0, 4, 80f);
this.shakeTimer -= time.ElapsedGameTime.Milliseconds;
if (this.shakeTimer < 0)
{
base.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("Maps\\springobjects", Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 103, width, height), this.position + new Vector2(0f, -32f), false, 0.1f, new Color(255, 50, 255) * 0.8f)
{
scale = 4f
});
this.shakeTimer = 50;
}
this.previousPositions.Add(base.Position);
if (this.previousPositions.Count > 8)
{
this.previousPositions.RemoveAt(0);
}
}
base.resetAnimationSpeed();
}
19
Source : ModEntry.cs
with GNU General Public License v3.0
from aedenthorn
with GNU General Public License v3.0
from aedenthorn
private void GameLoop_DayStarted(object sender, StardewModdingAPI.Events.DayStartedEventArgs e)
{
if (!config.EnableMod || coinDataDict.Count == 0)
return;
coinLocationDict.Clear();
foreach (GameLocation gl in Game1.locations)
{
if (gl.IsOutdoors && Game1.random.NextDouble() < config.MapHasCoinsChance)
{
int coins = Game1.random.Next(config.MinCoinsPerMap, config.MaxCoinsPerMap + 1 + (int)Math.Round(Game1.player.LuckLevel * config.LuckFactor));
if (coins == 0)
continue;
List<Vector2> diggableTiles = new List<Vector2>();
for (int x = 0; x < gl.map.GetLayer("Back").LayerWidth; x++)
{
for (int y = 0; y < gl.map.GetLayer("Back").LayerHeight; y++)
{
if (gl.doesTileHaveProperty(x, y, "Diggable", "Back") != null && !gl.isTileOccupied(new Vector2(x, y), "", false) && gl.isTilePreplacedable(new Location(x, y), Game1.viewport))
diggableTiles.Add(new Vector2(x, y));
}
}
if (diggableTiles.Count == 0)
continue;
Monitor.Log($"Adding coins to {gl.Name}");
if (!coinLocationDict.ContainsKey(gl.Name))
{
coinLocationDict.Add(gl.Name, new Dictionary<Vector2, string>());
}
for(int i = 0; i < coins; i++)
{
double whichRarity = Game1.random.NextDouble() * totalRarities;
float rarities = 0;
foreach (var coin in coinDataDict.Values)
{
rarities += coin.rarity;
if(whichRarity < rarities)
{
int idx = Game1.random.Next(diggableTiles.Count);
coinLocationDict[gl.Name][diggableTiles[idx]] = coin.id;
Monitor.Log($"Added coin {coin.id} to {gl.Name} at {diggableTiles[idx]}");
diggableTiles.RemoveAt(idx);
break;
}
}
if (diggableTiles.Count == 0)
break;
}
}
}
}
19
Source : ModEntry.cs
with GNU General Public License v3.0
from aedenthorn
with GNU General Public License v3.0
from aedenthorn
private void GameLoop_UpdateTicking(object sender, StardewModdingAPI.Events.UpdateTickingEventArgs e)
{
for (int i = animations.Count - 1; i >= 0; i--)
{
if (animations[i].update(Game1.currentGameTime))
{
animations.RemoveAt(i);
}
}
if (sparklingText != null && sparklingText.update(Game1.currentGameTime))
{
sparklingText = null;
}
if (fishCaught)
{
lastUser.addItemToInventoryBool(new Object(whichFish, caughtDoubleFish ? 2 : 1, false, -1, fishQuality), false);
fishCaught = false;
}
}
19
Source : Reminiscence.cs
with GNU General Public License v3.0
from aedenthorn
with GNU General Public License v3.0
from aedenthorn
internal void WeedOutUnseen()
{
if (events.Count == 0)
return;
for (int i = events.Count - 1; i >= 0; i--)
{
string ids = events[i].eventId;
if(!int.TryParse(ids, out int id))
{
if (!int.TryParse(ids.Split('/')[0], out id))
continue;
}
if (!Game1.player.eventsSeen.Contains(id))
events.RemoveAt(i);
}
}
19
Source : Utils.cs
with GNU General Public License v3.0
from Aekras1a
with GNU General Public License v3.0
from Aekras1a
public static void Replace<T>(this List<T> list, int index, IEnumerable<T> newItems)
{
list.RemoveAt(index);
list.InsertRange(index, newItems);
}
19
Source : Utils.cs
with GNU General Public License v3.0
from Aekras1a
with GNU General Public License v3.0
from Aekras1a
public static void Replace(this List<IRInstruction> list, int index, IEnumerable<IRInstruction> newItems)
{
var instr = list[index];
list.RemoveAt(index);
foreach(var i in newItems)
i.ILAST = instr.ILAST;
list.InsertRange(index, newItems);
}
19
Source : SyncList.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void RemoveAt(int index)
{
QueueAction(() => items.RemoveAt(index));
}
19
Source : DiscordRPC.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
internal void FreeMem()
{
for (var i = _buffers.Count - 1; i >= 0; i--)
{
Marshal.FreeHGlobal(_buffers[i]);
_buffers.RemoveAt(i);
}
}
19
Source : DarksVMStack.cs
with GNU General Public License v3.0
from Aekras1a
with GNU General Public License v3.0
from Aekras1a
public void SetTopPosition(uint topPos)
{
if(topPos > 0x7fffffff)
throw new StackOverflowException();
var sectionIndex = topPos >> SectionSize;
if(sectionIndex >= sections.Count)
do
{
sections.Add(new DarksVMSlot[1 << SectionSize]);
} while(sectionIndex >= sections.Count);
else if(sectionIndex < sections.Count - 2)
do
{
sections.RemoveAt(sections.Count - 1);
} while(sectionIndex < sections.Count - 2);
// Clear stack object references
var stackIndex = (topPos & IndexMask) + 1;
var section = sections[(int) sectionIndex];
while(stackIndex < section.Length && section[stackIndex].O != null)
section[stackIndex++] = DarksVMSlot.Null;
if(stackIndex == section.Length && sectionIndex + 1 < sections.Count)
{
stackIndex = 0;
section = sections[(int) sectionIndex + 1];
while(stackIndex < section.Length && section[stackIndex].O != null)
section[stackIndex++] = DarksVMSlot.Null;
}
this.topPos = topPos;
CheckFreeLocalloc();
}
19
Source : ScatterCommand.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public override bool Execute(string[] args)
{
var points = new List<Vector3>(Optimization.Caching.RespawnPositions.replacedanPositions);
foreach(var replacedan in FengGameManagerMKII.replacedans)
{
int index = UnityEngine.Random.Range(0, points.Count);
replacedan.baseT.position = points[index];
points.RemoveAt(index);
if(points.Count <= 0)
{
points = new List<Vector3>(Optimization.Caching.RespawnPositions.replacedanPositions);
}
}
return true;
}
19
Source : BanList.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool Unban(string name)
{
name = name.ToLower().RemoveHex();
for (int i = 0; i < BannedPlayers.Count; i++)
{
if (BannedPlayers[i].Name.ToLower() == name)
{
InfoLine($"Player [{BannedPlayers[i].ID}] {BannedPlayers[i].Name} unbanned. Ban reason was: {BannedPlayers[i].Reason}");
BannedPlayers.RemoveAt(i);
return true;
}
}
return false;
}
19
Source : BanList.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool Unban(int id)
{
for (int i = 0; i < BannedPlayers.Count; i++)
{
if (BannedPlayers[i].ID == id)
{
InfoLine($"Player [{id}] {BannedPlayers[i].Name} unbanned. Ban reason was: {BannedPlayers[i].Reason}");
BannedPlayers.RemoveAt(i);
return true;
}
}
return false;
}
19
Source : SkinsPanel.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void DrawControlElements()
{
LabelCenter(left, locale["sets"], true);
Label(left, locale["name"], false);
left.MoveOffsetX(Style.LabelOffset);
newSetName = TextField(left, newSetName, string.Empty, 0f, true);
left.ResetX();
left.BeginHorizontal(2);
if (Button(left, locale["btnAdd"], false))
{
SkinPreset add = null;
if (pageSelection == Humans)
{
add = new HumanSkinPreset(newSetName);
}
else if (pageSelection == replacedans)
{
add = new replacedanSkinPreset(newSetName);
}
else if (pageSelection == City)
{
add = new CityPreset(newSetName);
}
else if (pageSelection == Forest)
{
add = new ForestPreset(newSetName);
}
else if (pageSelection == Skyboxes)
{
add = new SkyboxPreset(newSetName);
}
else if (pageSelection == Custom)
{
add = new CustomMapPreset(newSetName);
}
if (add != null)
{
presets.Add(add);
skinSelection = presets.Count - 1;
newSetName = locale["set"] + " " + (presets.Count + 1).ToString();
presetLabels = new string[presets.Count];
for (int i = 0; i < presetLabels.Length; i++)
{
presetLabels[i] = presets[i].Name;
}
}
}
left.MoveX();
if (Button(left, locale["btnDelete"], true))
{
if (skinSelection >= 0)
{
presets[skinSelection].Delete();
presets.RemoveAt(skinSelection);
}
skinSelection = presets.Count > 0 ? presets.Count - 1 : -1;
presetLabels = new string[presets.Count];
for (int i = 0; i < presetLabels.Length; i++)
{
presetLabels[i] = presets[i].Name;
}
}
left.ResetX();
scrollArea.y = left.y;
left.MoveToEndY(WindowPosition, Style.Height + Style.VerticalMargin);
scrollArea.height = left.y - scrollArea.y;
scrollRect.Reset();
scrollAreaView.height = (Style.Height * presetLabels.Length) + (Style.VerticalMargin * (presetLabels.Length + 1));
scroll = BeginScrollView(scrollArea, scroll, scrollAreaView);
skinSelection = SelectionGrid(scrollRect, skinSelection, presetLabels, 1, true);
EndScrollView();
}
19
Source : ClothFactory.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static GameObject GetHair(GameObject reference, string name, Material material, Color color)
{
List<GameObject> list;
bool flag = ClothFactory.clothCache.TryGetValue(name, out list);
GameObject result;
if (flag)
{
for (int i = 0; i < list.Count; i++)
{
GameObject gameObject = list[i];
bool flag2 = gameObject == null;
if (flag2)
{
Debug.Log("Hair is null");
list.RemoveAt(i);
i = Mathf.Max(i - 1, 0);
}
else
{
ParentFollow component = gameObject.GetComponent<ParentFollow>();
bool flag3 = !component.isActiveInScene;
if (flag3)
{
component.isActiveInScene = true;
gameObject.renderer.material = material;
gameObject.renderer.material.color = color;
gameObject.GetComponent<Cloth>().enabled = true;
gameObject.GetComponent<SkinnedMeshRenderer>().enabled = true;
gameObject.GetComponent<ParentFollow>().SetParent(reference.transform);
ClothFactory.ReapplyClothBones(reference, gameObject);
return gameObject;
}
}
}
GameObject gameObject2 = ClothFactory.GenerateCloth(reference, name);
gameObject2.renderer.material = material;
gameObject2.renderer.material.color = color;
gameObject2.AddComponent<ParentFollow>().SetParent(reference.transform);
list.Add(gameObject2);
ClothFactory.clothCache[name] = list;
result = gameObject2;
}
else
{
GameObject gameObject2 = ClothFactory.GenerateCloth(reference, name);
gameObject2.renderer.material = material;
gameObject2.renderer.material.color = color;
gameObject2.AddComponent<ParentFollow>().SetParent(reference.transform);
list = new List<GameObject>
{
gameObject2
};
ClothFactory.clothCache.Add(name, list);
result = gameObject2;
}
return result;
}
19
Source : ClothFactory.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static GameObject GetCape(GameObject reference, string name, Material material)
{
List<GameObject> list;
bool flag = ClothFactory.clothCache.TryGetValue(name, out list);
GameObject result;
if (flag)
{
for (int i = 0; i < list.Count; i++)
{
GameObject gameObject = list[i];
bool flag2 = gameObject == null;
if (flag2)
{
list.RemoveAt(i);
i = Mathf.Max(i - 1, 0);
}
else
{
ParentFollow component = gameObject.GetComponent<ParentFollow>();
bool flag3 = !component.isActiveInScene;
if (flag3)
{
component.isActiveInScene = true;
gameObject.renderer.material = material;
gameObject.GetComponent<Cloth>().enabled = true;
gameObject.GetComponent<SkinnedMeshRenderer>().enabled = true;
gameObject.GetComponent<ParentFollow>().SetParent(reference.transform);
ClothFactory.ReapplyClothBones(reference, gameObject);
return gameObject;
}
}
}
GameObject gameObject2 = ClothFactory.GenerateCloth(reference, name);
gameObject2.renderer.material = material;
gameObject2.AddComponent<ParentFollow>().SetParent(reference.transform);
list.Add(gameObject2);
ClothFactory.clothCache[name] = list;
result = gameObject2;
}
else
{
GameObject gameObject2 = ClothFactory.GenerateCloth(reference, name);
gameObject2.renderer.material = material;
gameObject2.AddComponent<ParentFollow>().SetParent(reference.transform);
list = new List<GameObject>
{
gameObject2
};
ClothFactory.clothCache.Add(name, list);
result = gameObject2;
}
return result;
}
19
Source : FengGameManagerMKII.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void SpawnreplacedansCustom(int rate, int count, bool punk = false)
{
var num = count;
if (Level.Name.Contains("Custom"))
{
num = 5;
if (RCManager.GameType.Value == 1)
{
num = 3;
}
else if (RCManager.GameType.Value == 2 || RCManager.GameType.Value == 3)
{
num = 0;
}
}
if (IN_GAME_MAIN_CAMERA.GameMode == GameMode.SurviveMode)
{
if (count == 3 && !punk && GameModes.CustomAmount.Enabled)
{
num = GameModes.CustomAmount.GetInt(0);
}
else
{
num = GameModes.CustomAmount.Enabled ? GameModes.CustomAmount.GetInt(0) : count;
if (punk)
{
num = count;
}
else
{
if (GameModes.replacedansWaveAmount.Enabled)
{
num += GameModes.replacedansWaveAmount.GetInt(0);
}
}
}
}
else if (GameModes.CustomAmount.Enabled)
{
num = GameModes.CustomAmount.GetInt(0);
}
num = Mathf.Min(50, num);
if (GameModes.SpawnRate.Enabled)
{
var rates = new float[5];
for (var i = 0; i < rates.Length; i++)
{
rates[i] = GameModes.SpawnRate.GetFloat(i);
}
if (punk && GameModes.PunkOverride.Enabled)
{
rates = new[] { 0f, 0f, 0f, 0f, 100f };
}
List<Vector3> positions;
if (Level.Name.StartsWith("Custom") && CustomLevel.spawnPositions["replacedan"].Count > 0)
{
positions = new List<Vector3>(CustomLevel.spawnPositions["replacedan"]);
}
else
{
if (RespawnPositions.replacedanPositions.Length > 0)
{
positions = new List<Vector3>(RespawnPositions.replacedanPositions);
}
else
{
positions = new List<Vector3>(new Vector3[num].Select(x => new Vector3(Random.Range(-100f, 100f), 0f, Random.Range(-100f, 100f))).ToArray());
}
}
var summ = rates[0] + rates[1] + rates[2] + rates[3] + rates[4];
for (var i = 0; i < num; i++)
{
Vector3 position;
if (positions.Count == 0)
{
position = RespawnPositions.RandomreplacedanPos;
}
else
{
var index = Random.Range(0, positions.Count);
position = positions[index];
positions.RemoveAt(index);
}
var cRate = Random.Range(0, 100f);
if (cRate <= summ)
{
var startRate = 0f;
var endRate = 0f;
var type = 0;
for (var j = 0; j < 5; j++)
{
endRate += rates[j];
if (cRate >= startRate && cRate < endRate)
{
type = j;
break;
}
startRate += rates[j];
}
SpawnreplacedanRaw(position, Quaternion.idenreplacedy).SetAbnormalType((AbnormalType)type);
}
else
{
Spawnreplacedan(rate, position, Quaternion.idenreplacedy, punk);
}
}
}
else
{
if (Level.Name.Contains("Custom"))
{
List<Vector3> positions;
if (CustomLevel.spawnPositions["replacedan"].Count > 0)
{
positions = new List<Vector3>(CustomLevel.spawnPositions["replacedan"]);
}
else
{
if (RespawnPositions.replacedanPositions.Length > 0)
{
positions = new List<Vector3>(RespawnPositions.replacedanPositions);
}
else
{
positions = new List<Vector3>(new Vector3[num].Select(x =>
new Vector3(Random.Range(-400f, 400f), 0f, Random.Range(-400f, 400f))).ToArray());
}
}
for (var i = 0; i < num; i++)
{
Vector3 position;
if (positions.Count == 0)
{
position = new Vector3(Random.Range(-400f, 400f), 0f, Random.Range(-400f, 400f));
}
else
{
var index = Random.Range(0, positions.Count);
position = positions[index];
positions.RemoveAt(index);
}
Spawnreplacedan(rate, position, Quaternion.idenreplacedy, punk);
}
}
else
{
RandomSpawnreplacedans("replacedanRespawn", rate, num, punk);
}
}
}
19
Source : FengGameManagerMKII.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void RandomSpawnreplacedans(string place, int rate, int num, bool punk = false)
{
if (num == -1)
{
num = 1;
}
var list = new List<Vector3>(RespawnPositions.replacedanPositions);
if (list.Count <= 0)
{
return;
}
for (var i = 0; i < num; i++)
{
if (list.Count <= 0)
{
return;
}
var pos = Random.Range(0, list.Count);
Spawnreplacedan(rate, list[pos], Quaternion.idenreplacedy, punk);
list.RemoveAt(pos);
}
}
19
Source : NGUIDebug.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void Log(string text)
{
if (Application.isPlaying)
{
if (NGUIDebug.mLines.Count > 20)
{
NGUIDebug.mLines.RemoveAt(0);
}
NGUIDebug.mLines.Add(text);
if (NGUIDebug.mInstance == null)
{
GameObject gameObject = new GameObject("_NGUI Debug");
NGUIDebug.mInstance = gameObject.AddComponent<NGUIDebug>();
UnityEngine.Object.DontDestroyOnLoad(gameObject);
}
}
else
{
Debug.Log(text);
}
}
19
Source : UpdateManager.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void UpdateList(List<UpdateManager.UpdateEntry> list, float delta)
{
int i = list.Count;
while (i > 0)
{
UpdateManager.UpdateEntry updateEntry = list[--i];
if (updateEntry.isMonoBehaviour)
{
if (updateEntry.mb == null)
{
list.RemoveAt(i);
continue;
}
if (!updateEntry.mb.enabled || !NGUITools.GetActive(updateEntry.mb.gameObject))
{
continue;
}
}
updateEntry.func(delta);
}
}
19
Source : UICamera.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private static void Highlight(GameObject go, bool highlighted)
{
if (go != null)
{
int i = UICamera.mHighlighted.Count;
while (i > 0)
{
UICamera.Highlighted highlighted2 = UICamera.mHighlighted[--i];
if (highlighted2 == null || highlighted2.go == null)
{
UICamera.mHighlighted.RemoveAt(i);
}
else if (highlighted2.go == go)
{
if (highlighted)
{
highlighted2.counter++;
}
else if (--highlighted2.counter < 1)
{
UICamera.mHighlighted.Remove(highlighted2);
UICamera.Notify(go, "OnHover", false);
}
return;
}
}
if (highlighted)
{
UICamera.Highlighted highlighted3 = new UICamera.Highlighted();
highlighted3.go = go;
highlighted3.counter = 1;
UICamera.mHighlighted.Add(highlighted3);
UICamera.Notify(go, "OnHover", true);
}
}
}
19
Source : UITextList.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
protected void Add(string text, bool updateVisible)
{
UITextList.Paragraph paragraph;
if (this.mParagraphs.Count < this.maxEntries)
{
paragraph = new UITextList.Paragraph();
}
else
{
paragraph = this.mParagraphs[0];
this.mParagraphs.RemoveAt(0);
}
paragraph.text = text;
this.mParagraphs.Add(paragraph);
if (this.textLabel != null && this.textLabel.font != null)
{
paragraph.lines = this.textLabel.font.WrapText(paragraph.text, this.maxWidth / this.textLabel.transform.localScale.y, this.textLabel.maxLineCount, this.textLabel.supportEncoding, this.textLabel.symbolStyle).Split(this.mSeparator);
this.mTotalLines = 0;
int i = 0;
int count = this.mParagraphs.Count;
while (i < count)
{
this.mTotalLines += this.mParagraphs[i].lines.Length;
i++;
}
}
if (updateVisible)
{
this.UpdateVisibleText();
}
}
19
Source : NGUITools.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static int ParseSymbol(string text, int index, List<Color> colors, bool premultiply)
{
int length = text.Length;
if (index + 2 < length)
{
if (text[index + 1] == '-')
{
if (text[index + 2] == ']')
{
if (colors != null && colors.Count > 1)
{
colors.RemoveAt(colors.Count - 1);
}
return 3;
}
}
else if (index + 7 < length && text[index + 7] == ']')
{
if (colors != null)
{
Color color = NGUITools.ParseColor(text, index + 1);
if (NGUITools.EncodeColor(color) != text.Substring(index + 1, 6).ToUpper())
{
return 0;
}
color.a = colors[colors.Count - 1].a;
if (premultiply && color.a != 1f)
{
color = Color.Lerp(NGUITools.mInvisible, color, color.a);
}
colors.Add(color);
}
return 8;
}
}
return 0;
}
19
Source : XWeaponTrail.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void RecordCurElem()
{
var item = new Element(PointStart.position, PointEnd.position);
if (mSnapshotList.Count < MaxFrame)
{
mSnapshotList.Insert(1, item);
}
else
{
mSnapshotList.RemoveAt(mSnapshotList.Count - 1);
mSnapshotList.Insert(1, item);
}
}
19
Source : Monster.cs
with GNU General Public License v3.0
from aenemenate
with GNU General Public License v3.0
from aenemenate
private Point GetNextPosition()
{
Block[] blocks = CurrentFloor >= 0 ? Program.WorldMap[WorldIndex.X, WorldIndex.Y].Dungeon.Floors[CurrentFloor].Blocks : Program.WorldMap[WorldIndex.X, WorldIndex.Y].Blocks;
int width = Program.WorldMap[WorldIndex.X, WorldIndex.Y].Width, height = Program.WorldMap[WorldIndex.X, WorldIndex.Y].Height;
int GetPosValue(Point pos) {
bool playerIsNearby = WorldIndex.Equals(Program.Player.WorldIndex) && CurrentFloor == Program.Player.CurrentFloor && (Position.DistFrom(Program.Player.Position) <= SightDist);
return (playerIsNearby ? Program.WorldMap[WorldIndex.X, WorldIndex.Y].DijkstraMaps.DistToPlayerMap[pos.X * width + pos.Y] * CurrentDesires[DesireType.KillPlayer] : 0)
+ Program.WorldMap[WorldIndex.X, WorldIndex.Y].DijkstraMaps.DistToItemsMap[pos.X * width + pos.Y] * CurrentDesires[DesireType.Treasure];
}
int GetPatrolPosValue(Point pos)
{
return Program.WorldMap[WorldIndex.X, WorldIndex.Y].Dungeon.Floors[CurrentFloor].PatrolMaps.PatrolGoals[curPatrolDestIndex][pos.X * width + pos.Y];
}
List<Point> bestPositions = new List<Point>();
int bestVal = !patrolling ? GetPosValue(Position) : GetPatrolPosValue(Position);
for (int i = Math.Max(0, Position.X - 1); i <= Math.Min(width - 1, Position.X + 1); i++)
for (int j = Math.Max(0, Position.Y - 1); j <= Math.Min(height - 1, Position.Y + 1); j++) {
if (Position.Equals( new Point( i, j ) ) || blocks[i * width + j].Solid)
continue;
int thisVal = !patrolling ? GetPosValue(new Point(i, j)) : GetPatrolPosValue(new Point(i, j));
if (thisVal <= bestVal) {
bestPositions.Add( new Point( i, j ) );
bestVal = thisVal;
}
}
for ( int i = bestPositions.Count - 1; i >= 0; i-- )
if ((!patrolling ? GetPosValue(bestPositions[i]) : GetPatrolPosValue(bestPositions[i])) != bestVal)
bestPositions.RemoveAt(i);
return bestPositions.Count > 0 ? bestPositions[Program.RNG.Next(0, bestPositions.Count)] : new Point();
}
See More Examples