Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisforbes committed Jan 30, 2011
1 parent 8874b6e commit c3b08a6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
12 changes: 11 additions & 1 deletion OpenRA.Editor/ActorTool.cs
Expand Up @@ -34,12 +34,22 @@ public void Apply(Surface surface)
return;

var owner = "Neutral";
var id = surface.NextActorName();
var id = NextActorName(surface);
surface.Map.Actors[id] = new ActorReference(Actor.Info.Name.ToLowerInvariant())
{
new LocationInit( surface.GetBrushLocation() ),
new OwnerInit( owner)
};
}

string NextActorName(Surface surface)
{
var id = 0;
for (; ; )
{
var possible = "Actor{0}".F(id++);
if (!surface.Map.Actors.ContainsKey(possible)) return possible;
}
}
}
}
5 changes: 4 additions & 1 deletion OpenRA.Editor/ResourceTool.cs
Expand Up @@ -8,6 +8,7 @@
*/
#endregion

using System;
using OpenRA.FileFormats;

using SGraphics = System.Drawing.Graphics;
Expand All @@ -26,7 +27,7 @@ public void Apply(Surface surface)
= new TileReference<byte, byte>
{
type = (byte)Resource.Info.ResourceType,
index = (byte)surface.random.Next(Resource.Info.SpriteNames.Length),
index = (byte)random.Next(Resource.Info.SpriteNames.Length),
image = (byte)Resource.Value
};

Expand All @@ -44,5 +45,7 @@ public void Preview(Surface surface, SGraphics g)
{
surface.DrawImage(g, Resource.Bitmap, surface.GetBrushLocation());
}

Random random = new Random();
}
}
19 changes: 0 additions & 19 deletions OpenRA.Editor/Surface.cs
Expand Up @@ -186,25 +186,6 @@ void Erase()
void Draw()
{
if (Tool != null) Tool.Apply(this);

AfterChange();
}

int id;
public string NextActorName()
{
for (; ; )
{
var possible = "Actor{0}".F(id++);
if (!Map.Actors.ContainsKey(possible)) return possible;
}
}

public System.Random random = new System.Random();
void DrawWithResource()
{


AfterChange();
}

Expand Down

0 comments on commit c3b08a6

Please sign in to comment.