Hey, im having a bug in counting the Foundations since the last Update.
Code to count:
and usage:Code:private int Count(List<BuildingBlock> ConnectingStructure, string buildingobject) { int count = 0; var templist = ConnectingStructure.ToList(); foreach (BuildingBlock block in templist) { if (block == null) ConnectingStructure.Remove(block); else { if (block.name == buildingobject) count++; } } return count; }
the strange thing is, it appears random.Code:var trifcount = Count(ConnectingStructure, TriangleFoundation); var fcount = Count(ConnectingStructure, Foundation);
is there any better way to count them without getting random problems?
thank you!
sorry for my bad english
Counting foundations?
Discussion in 'Rust Development' started by Alfred 2, Apr 8, 2018.
-
Here you go
Code:var entity = UnityEngine.Object.FindObjectsOfType<BuildingBlock>() .Where(x => x.PrefabName.Contains("foundation")); Puts(entity.Count().ToString());
-