Autoload.txt should also work with physics = 4 and physics = 5.

This commit is contained in:
UnknownShadow200 2016-06-11 12:23:02 +10:00
parent a94007b459
commit 7b58e480df
4 changed files with 19 additions and 20 deletions

View File

@ -23,7 +23,7 @@ using MCGalaxy.Generator;
namespace MCGalaxy.Drawing.Brushes {
public sealed class CloudyBrush : FrequencyBrush {
public sealed class CloudyBrush : Brush {
readonly ExtBlock[] blocks;
readonly int[] counts;
readonly float[] thresholds;
@ -68,17 +68,16 @@ namespace MCGalaxy.Drawing.Brushes {
n.Lacunarity = 2;
int[] count;
ExtBlock[] toAffect = GetBlocks(args, out count,
ExtBlock[] toAffect = FrequencyBrush.GetBlocks(args, out count,
Filter, arg => Handler(arg, args.Player, ref n));
if (toAffect == null) return null;
return new CloudyBrush(toAffect, count, n);
}
// We want to handle non block options.
// Only want to handle non block options.
static bool Filter(string arg) {
if (arg.Length < 2) return true;
return arg[1] != '_';
return arg.Length < 2 || arg[1] != '_';
}
static bool Handler(string arg, Player p, ref NoiseArgs args) {

View File

@ -16,24 +16,24 @@
permissions and limitations under the Licenses.
*/
using System;
using System.Collections.Generic;
using MCGalaxy.Commands.Building;
using MCGalaxy.Drawing.Ops;
namespace MCGalaxy.Drawing.Brushes {
public abstract class FrequencyBrush : Brush {
/// <summary> Contains helper methods for brushes that have blocks with
/// optional frequency counts (e.g. random and cloudy brushes) </summary>
public static class FrequencyBrush {
protected static ExtBlock[] GetBlocks(BrushArgs args, out int[] count,
Predicate<string> filter, Predicate<string> handler) {
string[] parts = args.Message.Split(' ');
Player p = args.Player;
public static ExtBlock[] GetBlocks(BrushArgs args, out int[] count,
Predicate<string> filter, Predicate<string> handler) {
string[] parts = args.Message.Split(' ');
Player p = args.Player;
ExtBlock[] blocks;
GetRaw(parts, filter, args, out blocks, out count);
for (int i = 0, j = 0; i < parts.Length; i++ ) {
if (parts[i] == "") continue;
if (parts[i] == "") continue;
// Brush specific args
if (!filter(parts[i])) {
if (!handler(parts[i])) return null;
@ -48,6 +48,7 @@ namespace MCGalaxy.Drawing.Brushes {
blocks[j].Type = type; blocks[j].ExtType = extType;
if (sepIndex < 0) { j++; continue; }
int chance;
if (!int.TryParse(parts[i].Substring(sepIndex + 1), out chance)
|| chance <= 0 || chance > 10000) {
@ -80,10 +81,9 @@ namespace MCGalaxy.Drawing.Brushes {
blocks[0] = new ExtBlock(args.Type, args.ExtType);
}
protected static ExtBlock[] Combine(ExtBlock[] toAffect, int[] count) {
public static ExtBlock[] Combine(ExtBlock[] toAffect, int[] count) {
int sum = 0;
for (int i = 0; i < count.Length; i++) sum += count[i];
if (toAffect.Length == 1) sum += 1;
ExtBlock[] blocks = new ExtBlock[sum];
for (int i = 0, index = 0; i < toAffect.Length; i++) {

View File

@ -22,7 +22,7 @@ using MCGalaxy.Drawing.Ops;
namespace MCGalaxy.Drawing.Brushes {
public sealed class RandomBrush : FrequencyBrush {
public sealed class RandomBrush : Brush {
readonly ExtBlock[] blocks;
readonly int seed;
@ -44,10 +44,10 @@ namespace MCGalaxy.Drawing.Brushes {
public static Brush Process(BrushArgs args) {
int[] count;
ExtBlock[] toAffect = GetBlocks(args, out count, P => true, null);
ExtBlock[] toAffect = FrequencyBrush.GetBlocks(args, out count, P => true, null);
if (toAffect == null) return null;
ExtBlock[] blocks = Combine(toAffect, count);
ExtBlock[] blocks = FrequencyBrush.Combine(toAffect, count);
return new RandomBrush(blocks);
}

View File

@ -105,7 +105,7 @@ namespace MCGalaxy {
} else {
try {
int temp = int.Parse(value);
if (temp >= 0 && temp <= 3)
if (temp >= 0 && temp <= 5)
mainLevel.setPhysics(temp);
} catch {
s.Log("Physics variable invalid");