more
This commit is contained in:
@@ -339,7 +339,7 @@ namespace OpenRa.Game
|
|||||||
heuristic = loc =>
|
heuristic = loc =>
|
||||||
{
|
{
|
||||||
var b = Game.BuildingInfluence.GetBuildingAt(loc);
|
var b = Game.BuildingInfluence.GetBuildingAt(loc);
|
||||||
if (b != null && b.Owner == p && (b.LegacyInfo as LegacyBuildingInfo).BaseNormal) return 0;
|
if (b != null && b.Owner == p && b.Info.Traits.Get<BuildingInfo>().BaseNormal) return 0;
|
||||||
if ((loc - position).Length > maxDistance)
|
if ((loc - position).Length > maxDistance)
|
||||||
return float.PositiveInfinity; /* not quite right */
|
return float.PositiveInfinity; /* not quite right */
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using IjwFramework.Collections;
|
using IjwFramework.Collections;
|
||||||
|
using OpenRa.Game.Traits;
|
||||||
|
|
||||||
namespace OpenRa.Game.GameRules
|
namespace OpenRa.Game.GameRules
|
||||||
{
|
{
|
||||||
@@ -21,8 +22,8 @@ namespace OpenRa.Game.GameRules
|
|||||||
public Cache<string, List<Actor>> GatherBuildings( Player player )
|
public Cache<string, List<Actor>> GatherBuildings( Player player )
|
||||||
{
|
{
|
||||||
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
|
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
|
||||||
foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.LegacyInfo is LegacyBuildingInfo ) )
|
foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info != null && x.Info.Traits.Contains<BuildingInfo>() ) )
|
||||||
ret[ b.LegacyInfo.Name ].Add( b );
|
ret[ b.Info.Name ].Add( b );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRa.Game.Orders
|
|||||||
var underCursor = Game.FindUnits(loc, loc)
|
var underCursor = Game.FindUnits(loc, loc)
|
||||||
.Where(a => a.Owner == Game.LocalPlayer
|
.Where(a => a.Owner == Game.LocalPlayer
|
||||||
&& a.traits.Contains<Building>()
|
&& a.traits.Contains<Building>()
|
||||||
&& a.LegacyInfo.Selectable).FirstOrDefault();
|
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||||
|
|
||||||
var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null;
|
var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null;
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ namespace OpenRa.Game.Orders
|
|||||||
var underCursor = Game.FindUnits(loc, loc)
|
var underCursor = Game.FindUnits(loc, loc)
|
||||||
.Where(a => a.Owner == Game.LocalPlayer
|
.Where(a => a.Owner == Game.LocalPlayer
|
||||||
&& a.traits.Contains<Building>()
|
&& a.traits.Contains<Building>()
|
||||||
&& a.LegacyInfo.Selectable).FirstOrDefault();
|
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||||
|
|
||||||
var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null;
|
var building = underCursor != null ? underCursor.Info.Traits.Get<BuildingInfo>() : null;
|
||||||
|
|
||||||
if (building != null && building.Repairable && underCursor.Health < building.Strength)
|
if (building != null && building.Repairable && underCursor.Health < building.HP)
|
||||||
yield return new Order("Repair", underCursor, null, int2.Zero, null);
|
yield return new Order("Repair", underCursor, null, int2.Zero, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders
|
|||||||
var underCursor = Game.FindUnits(loc, loc)
|
var underCursor = Game.FindUnits(loc, loc)
|
||||||
.Where(a => a.Owner == Game.LocalPlayer
|
.Where(a => a.Owner == Game.LocalPlayer
|
||||||
&& a.traits.Contains<Building>()
|
&& a.traits.Contains<Building>()
|
||||||
&& a.LegacyInfo.Selectable).FirstOrDefault();
|
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||||
|
|
||||||
var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null;
|
var building = underCursor != null ? underCursor.Info.Traits.Get<BuildingInfo>() : null;
|
||||||
|
|
||||||
if (building != null && !building.Unsellable)
|
if (building != null && !building.Unsellable)
|
||||||
yield return new Order("Sell", underCursor, null, int2.Zero, null);
|
yield return new Order("Sell", underCursor, null, int2.Zero, null);
|
||||||
|
|||||||
@@ -24,9 +24,11 @@ namespace OpenRa.Game.Traits.Activities
|
|||||||
if (isCanceled) return NextActivity;
|
if (isCanceled) return NextActivity;
|
||||||
var dest = ChooseHelipad(self);
|
var dest = ChooseHelipad(self);
|
||||||
|
|
||||||
|
var initialFacing = self.Info.Traits.WithInterface<OwnedActorInfo>().First().InitialFacing;
|
||||||
|
|
||||||
if (dest == null)
|
if (dest == null)
|
||||||
return Util.SequenceActivities(
|
return Util.SequenceActivities(
|
||||||
new Turn(self.LegacyInfo.InitialFacing),
|
new Turn(initialFacing),
|
||||||
new HeliLand(true),
|
new HeliLand(true),
|
||||||
NextActivity);
|
NextActivity);
|
||||||
|
|
||||||
@@ -34,12 +36,13 @@ namespace OpenRa.Game.Traits.Activities
|
|||||||
if (res != null)
|
if (res != null)
|
||||||
self.traits.Get<Helicopter>().reservation = res.Reserve(self);
|
self.traits.Get<Helicopter>().reservation = res.Reserve(self);
|
||||||
|
|
||||||
var offset = (dest.LegacyInfo as LegacyBuildingInfo).SpawnOffset;
|
var pi = dest.Info.Traits.GetOrDefault<ProductionInfo>();
|
||||||
|
var offset = pi != null ? pi.SpawnOffset : null;
|
||||||
var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero;
|
var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero;
|
||||||
|
|
||||||
return Util.SequenceActivities(
|
return Util.SequenceActivities(
|
||||||
new HeliFly(dest.CenterLocation + offsetVec),
|
new HeliFly(dest.CenterLocation + offsetVec),
|
||||||
new Turn(self.LegacyInfo.InitialFacing),
|
new Turn(initialFacing),
|
||||||
new HeliLand(false),
|
new HeliLand(false),
|
||||||
new Rearm(),
|
new Rearm(),
|
||||||
NextActivity);
|
NextActivity);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace OpenRa.Game.Traits
|
|||||||
public readonly string[] Produces = { }; // does this go somewhere else?
|
public readonly string[] Produces = { }; // does this go somewhere else?
|
||||||
public readonly int2 Dimensions = new int2(1, 1);
|
public readonly int2 Dimensions = new int2(1, 1);
|
||||||
public readonly bool WaterBound = false;
|
public readonly bool WaterBound = false;
|
||||||
|
public readonly bool Unsellable = false;
|
||||||
|
|
||||||
public object Create(Actor self) { return new Building(self); }
|
public object Create(Actor self) { return new Building(self); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRa.Game.Traits
|
|||||||
if (mi.Button != MouseButton.Right) return null;
|
if (mi.Button != MouseButton.Right) return null;
|
||||||
if (underCursor == null) return null;
|
if (underCursor == null) return null;
|
||||||
|
|
||||||
if (underCursor.LegacyInfo == Rules.UnitInfo["FIX"]
|
if (underCursor.Info.Name == "fix"
|
||||||
&& underCursor.Owner == self.Owner
|
&& underCursor.Owner == self.Owner
|
||||||
&& !Reservable.IsReserved(underCursor))
|
&& !Reservable.IsReserved(underCursor))
|
||||||
return new Order("Enter", self, underCursor, int2.Zero, null);
|
return new Order("Enter", self, underCursor, int2.Zero, null);
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ namespace RulesConverter
|
|||||||
{ "Crewed", "Crewed" },
|
{ "Crewed", "Crewed" },
|
||||||
{ "WaterBound", "WaterBound" },
|
{ "WaterBound", "WaterBound" },
|
||||||
{ "InitialFacing", "InitialFacing" },
|
{ "InitialFacing", "InitialFacing" },
|
||||||
{ "Sight", "Sight" } }
|
{ "Sight", "Sight" },
|
||||||
|
{ "Unsellable", "Unsellable" } }
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "StoresOre", new PL {
|
{ "StoresOre", new PL {
|
||||||
|
|||||||
Reference in New Issue
Block a user