mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-29 16:43:30 -04:00
Rename NoiseBrush to CloudyBrush and allow brushes to perform configuration/calculation for particular draw ops.
This commit is contained in:
parent
c4af44ecfc
commit
ba62aae7af
@ -30,6 +30,9 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
/// <summary> Description of the brush, in addition to its syntax. </summary>
|
||||
public abstract string[] Help { get; }
|
||||
|
||||
/// <summary> Performs calcuations (if necessary) for the given drawop. </summary>
|
||||
public virtual void Configure(DrawOp op, Player p) { }
|
||||
|
||||
public abstract byte NextBlock(DrawOp op);
|
||||
|
||||
public abstract byte NextExtBlock(DrawOp op);
|
||||
@ -40,7 +43,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
{ "checkered", CheckeredBrush.Process }, { "rainbow", RainbowBrush.Process },
|
||||
{ "bwrainbow", BWRainbowBrush.Process }, { "striped", StripedBrush.Process },
|
||||
{ "replace", ReplaceBrush.Process }, { "replacenot", ReplaceNotBrush.Process },
|
||||
{ "random", RandomBrush.Process }, { "noise", NoiseBrush.Process },
|
||||
{ "random", RandomBrush.Process }, { "cloudy", CloudyBrush.Process },
|
||||
};
|
||||
|
||||
public static Dictionary<string, string[]> BrushesHelp = new Dictionary<string, string[]> {
|
||||
@ -48,7 +51,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
{ "checkered", CheckeredBrush.HelpString }, { "rainbow", RainbowBrush.HelpString },
|
||||
{ "bwrainbow", BWRainbowBrush.HelpString }, { "striped", StripedBrush.HelpString },
|
||||
{ "replace", ReplaceBrush.HelpString }, { "replacenot", ReplaceNotBrush.HelpString },
|
||||
{ "random", RandomBrush.HelpString }, { "noise", NoiseBrush.HelpString },
|
||||
{ "random", RandomBrush.HelpString }, { "cloudy", CloudyBrush.HelpString },
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,11 @@ using MCGalaxy.Generator;
|
||||
|
||||
namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public sealed class NoiseBrush : FrequencyBrush {
|
||||
public sealed class CloudyBrush : FrequencyBrush {
|
||||
readonly ExtBlock[] blocks;
|
||||
readonly ImprovedNoise noise;
|
||||
|
||||
public NoiseBrush(ExtBlock[] blocks, NoiseArgs n) {
|
||||
public CloudyBrush(ExtBlock[] blocks, NoiseArgs n) {
|
||||
this.blocks = blocks;
|
||||
Random r = n.Seed == int.MinValue ? new Random() : new Random(n.Seed);
|
||||
noise = new ImprovedNoise(r);
|
||||
@ -39,7 +39,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
noise.Persistence = n.Persistence;
|
||||
}
|
||||
|
||||
public override string Name { get { return "Noise"; } }
|
||||
public override string Name { get { return "Cloudy"; } }
|
||||
|
||||
public override string[] Help { get { return HelpString; } }
|
||||
|
||||
@ -57,7 +57,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
n.Amplitude = 1; n.Frequency = 1; n.Octaves = 1;
|
||||
n.Seed = int.MinValue; n.Persistence = 2; n.Lacunarity = 2;
|
||||
if (args.Message == "")
|
||||
return new NoiseBrush(new[] { new ExtBlock(args.Type, args.ExtType),
|
||||
return new CloudyBrush(new[] { new ExtBlock(args.Type, args.ExtType),
|
||||
new ExtBlock(Block.Zero, 0) }, n);
|
||||
|
||||
string[] parts = args.Message.Split(' ');
|
||||
@ -67,7 +67,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
if (toAffect == null) return null;
|
||||
ExtBlock[] blocks = Combine(toAffect, count);
|
||||
return new NoiseBrush(blocks, n);
|
||||
return new CloudyBrush(blocks, n);
|
||||
}
|
||||
|
||||
// We want to handle non block options.
|
||||
@ -105,6 +105,11 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Configure(DrawOp op, Player p) {
|
||||
Player.Message(p, "Calculating noise distribution...");
|
||||
Player.Message(p, "Finished calculating, now drawing.");
|
||||
}
|
||||
|
||||
int next;
|
||||
public override byte NextBlock(DrawOp op) {
|
||||
float N = noise.NormalisedNoise(op.Coords.X, op.Coords.Y, op.Coords.Z);
|
@ -116,6 +116,8 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
entry.Start = Server.StartTime.AddTicks(timeDelta * TimeSpan.TicksPerSecond);
|
||||
|
||||
bool needReveal = item.Op.DetermineDrawOpMethod(item.Level, item.Affected);
|
||||
if (item.Brush != null)
|
||||
item.Brush.Configure(item.Op, p);
|
||||
item.Op.Perform(item.Marks, p, item.Level, item.Brush);
|
||||
timeDelta = (int)DateTime.UtcNow.Subtract(Server.StartTime).TotalSeconds;
|
||||
entry.End = Server.StartTime.AddTicks(timeDelta * TimeSpan.TicksPerSecond);
|
||||
|
@ -432,7 +432,7 @@
|
||||
<Compile Include="Drawing\Brushes\Brush.cs" />
|
||||
<Compile Include="Drawing\Brushes\CheckeredBrush.cs" />
|
||||
<Compile Include="Drawing\Brushes\FrequencyBrush.cs" />
|
||||
<Compile Include="Drawing\Brushes\NoiseBrush.cs" />
|
||||
<Compile Include="Drawing\Brushes\CloudyBrush.cs" />
|
||||
<Compile Include="Drawing\Brushes\PasteBrush.cs" />
|
||||
<Compile Include="Drawing\Brushes\RainbowBrush.cs" />
|
||||
<Compile Include="Drawing\Brushes\RandomBrush.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user