private void PlaceModuleRandom(ModuleTypes moduleType, int numObjects)
    {
        var moduleIndex = moduleType.GetHashCode();

        for (var i = 0; i < numObjects; i++)
        {
            var listPosition     = Random.Range(0, moduleSpaces.Count);
            var spatialPosition  = moduleSpaces[listPosition];
            var absolutePosition = NumberToPosition(spatialPosition, innerSize);
            innerModuleGrid[absolutePosition[0], absolutePosition[1]] = moduleIndex;
            moduleSpaces.RemoveAt(listPosition);

            if (supportItems.Contains(moduleType))
            {
                // Prefer to place items here.
                itemSpaces.Add(spatialPosition);
                itemSpaces.Add(spatialPosition);
            }
            else
            {
                // Can't place an item here.
                itemSpaces.RemoveAll(value => value == spatialPosition);
            }
        }
    }
예제 #2
0
 public void SetModulePosition(int x, int z, ModuleTypes moduleType)
 {
     moduleGrid[x, z] = moduleType.GetHashCode();
 }