more cleanup
This commit is contained in:
@@ -34,12 +34,22 @@ namespace OpenRA.Editor
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var owner = "Neutral";
|
var owner = "Neutral";
|
||||||
var id = surface.NextActorName();
|
var id = NextActorName(surface);
|
||||||
surface.Map.Actors[id] = new ActorReference(Actor.Info.Name.ToLowerInvariant())
|
surface.Map.Actors[id] = new ActorReference(Actor.Info.Name.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
new LocationInit( surface.GetBrushLocation() ),
|
new LocationInit( surface.GetBrushLocation() ),
|
||||||
new OwnerInit( owner)
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
using SGraphics = System.Drawing.Graphics;
|
using SGraphics = System.Drawing.Graphics;
|
||||||
@@ -26,7 +27,7 @@ namespace OpenRA.Editor
|
|||||||
= new TileReference<byte, byte>
|
= new TileReference<byte, byte>
|
||||||
{
|
{
|
||||||
type = (byte)Resource.Info.ResourceType,
|
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
|
image = (byte)Resource.Value
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,5 +45,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
surface.DrawImage(g, Resource.Bitmap, surface.GetBrushLocation());
|
surface.DrawImage(g, Resource.Bitmap, surface.GetBrushLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Random random = new Random();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,25 +186,6 @@ namespace OpenRA.Editor
|
|||||||
void Draw()
|
void Draw()
|
||||||
{
|
{
|
||||||
if (Tool != null) Tool.Apply(this);
|
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();
|
AfterChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user