An example mod. Chrome doesn't restrict the set of tabs any more, though i'm not sure what happens if you make a new tab :D
This commit is contained in:
@@ -47,7 +47,6 @@ namespace OpenRa.Game
|
||||
// Build Palette tabs
|
||||
string currentTab = "Building";
|
||||
bool paletteOpen = false;
|
||||
static string[] groups = new string[] { "Building", "Infantry", "Vehicle", "Plane", "Ship" };
|
||||
readonly Dictionary<string, string[]> tabImageNames;
|
||||
readonly Dictionary<string, Sprite> tabSprites;
|
||||
|
||||
@@ -111,7 +110,6 @@ namespace OpenRa.Game
|
||||
optionsBackground = SpriteSheetBuilder.LoadAllSprites("dd-bkgnd")[Game.CosmeticRandom.Next(4)];
|
||||
|
||||
tabSprites = Rules.NewUnitInfo.Values
|
||||
.Where(x => groups.Contains(x.Category))
|
||||
.Where(u => u.Traits.Contains<BuildableInfo>())
|
||||
.ToDictionary(
|
||||
u => u.Name,
|
||||
@@ -122,6 +120,8 @@ namespace OpenRa.Game
|
||||
u => u.Key,
|
||||
u => SpriteSheetBuilder.LoadAllSprites(u.Value.Image)[0]);
|
||||
|
||||
var groups = Rules.NewUnitInfo.Values.Select( x => x.Category ).Distinct().ToList();
|
||||
|
||||
tabImageNames = groups.Select(
|
||||
(g, i) => Pair.New(g,
|
||||
OpenRa.Game.Graphics.Util.MakeArray(3,
|
||||
@@ -644,27 +644,27 @@ namespace OpenRa.Game
|
||||
|
||||
void StartProduction( string item )
|
||||
{
|
||||
var group = Rules.NewUnitInfo[item].Category;
|
||||
Sound.Play((group == "Building") ? "abldgin1.aud" : "train1.aud");
|
||||
var unit = Rules.NewUnitInfo[item];
|
||||
Sound.Play(unit.Traits.Contains<BuildingInfo>() ? "abldgin1.aud" : "train1.aud");
|
||||
Game.controller.AddOrder(Order.StartProduction(Game.LocalPlayer, item));
|
||||
}
|
||||
|
||||
void HandleBuildPalette(string item, bool isLmb)
|
||||
{
|
||||
var player = Game.LocalPlayer;
|
||||
var group = Rules.NewUnitInfo[item].Category;
|
||||
var unit = Rules.NewUnitInfo[item];
|
||||
var queue = player.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
||||
var producing = queue.AllItems(group).FirstOrDefault( a => a.Item == item );
|
||||
var producing = queue.AllItems(unit.Category).FirstOrDefault( a => a.Item == item );
|
||||
|
||||
Sound.Play("ramenu1.aud");
|
||||
|
||||
if (isLmb)
|
||||
{
|
||||
if (producing != null && producing == queue.CurrentItem(group))
|
||||
if (producing != null && producing == queue.CurrentItem(unit.Category))
|
||||
{
|
||||
if (producing.Done)
|
||||
{
|
||||
if (group == "Building")
|
||||
if (unit.Traits.Contains<BuildingInfo>())
|
||||
Game.controller.orderGenerator = new PlaceBuildingOrderGenerator(player.PlayerActor, item);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,8 @@ namespace OpenRa.Game
|
||||
if( useAftermath )
|
||||
yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "aftermath.yaml" ), yamlRules );
|
||||
|
||||
yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "[mod]Separate buildqueue for defense.yaml" ), yamlRules );
|
||||
|
||||
NewUnitInfo = new Dictionary<string, NewUnitInfo>();
|
||||
foreach( var kv in yamlRules )
|
||||
NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules));
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
case "StartProduction":
|
||||
{
|
||||
string group = Rules.NewUnitInfo[ order.TargetString ].Category;
|
||||
var ui = Rules.NewUnitInfo[ order.TargetString ].Traits.Get<BuildableInfo>();
|
||||
var unit = Rules.NewUnitInfo[ order.TargetString ];
|
||||
var ui = unit.Traits.Get<BuildableInfo>();
|
||||
var time = ui.Cost
|
||||
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
||||
* ( 25 * 60 ) /* frames per min */ /* todo: build acceleration, if we do that */
|
||||
@@ -42,17 +42,17 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
time = .08f * time; /* temporary hax so we can build stuff fast for test */
|
||||
|
||||
if( !Rules.TechTree.BuildableItems( order.Player, group ).Contains( order.TargetString ) )
|
||||
if( !Rules.TechTree.BuildableItems( order.Player, unit.Category ).Contains( order.TargetString ) )
|
||||
return; /* you can't build that!! */
|
||||
|
||||
bool hasPlayedSound = false;
|
||||
|
||||
BeginProduction( group,
|
||||
BeginProduction( unit.Category,
|
||||
new ProductionItem( order.TargetString, (int)time, ui.Cost,
|
||||
() => Game.world.AddFrameEndTask(
|
||||
_ =>
|
||||
{
|
||||
var isBuilding = group == "Building";
|
||||
var isBuilding = unit.Traits.Contains<BuildingInfo>();
|
||||
if( !hasPlayedSound && order.Player == Game.LocalPlayer )
|
||||
{
|
||||
Sound.Play( isBuilding ? "conscmp1.aud" : "unitrdy1.aud" );
|
||||
|
||||
23
[mod]Separate buildqueue for defense.yaml
Executable file
23
[mod]Separate buildqueue for defense.yaml
Executable file
@@ -0,0 +1,23 @@
|
||||
IRON:
|
||||
Category: Defense
|
||||
PDOX:
|
||||
Category: Defense
|
||||
PBOX:
|
||||
Category: Defense
|
||||
HBOX:
|
||||
Category: Defense
|
||||
TSLA:
|
||||
Category: Defense
|
||||
GUN:
|
||||
Category: Defense
|
||||
AGUN:
|
||||
Category: Defense
|
||||
FTUR:
|
||||
Category: Defense
|
||||
GAP:
|
||||
Category: Defense
|
||||
SAM:
|
||||
Category: Defense
|
||||
MSLO:
|
||||
Category: Defense
|
||||
|
||||
Reference in New Issue
Block a user