cache => controlGroups; not sure what i was smoking then. also more sane exceptions in Actor.ctor
This commit is contained in:
@@ -28,24 +28,23 @@ namespace OpenRa.Game
|
||||
CenterLocation = Traits.Util.CenterOfCell(Location);
|
||||
Owner = owner;
|
||||
|
||||
if( Info != null )
|
||||
{
|
||||
if (Info == null) return;
|
||||
|
||||
Health = Info.Strength; /* todo: handle cases where this is not true! */
|
||||
|
||||
if( Info.Traits != null )
|
||||
{
|
||||
if( Info.Traits == null )
|
||||
throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(Info.Name) );
|
||||
|
||||
foreach (var traitName in Info.Traits)
|
||||
{
|
||||
var type = typeof( Traits.Mobile ).Assembly.GetType( typeof( Traits.Mobile ).Namespace + "." + traitName, true, false );
|
||||
{ /* todo: a better solution than `the assembly Mobile lives in`, for mod support & sanity. */
|
||||
var type = typeof(Mobile).Assembly.GetType(typeof(Mobile).Namespace + "." + traitName, true, false);
|
||||
var ctor = type.GetConstructor(new[] { typeof(Actor) });
|
||||
if (ctor == null)
|
||||
throw new InvalidOperationException("Trait {0} does not have the correct constructor: {0}(Actor self)".F(type.Name));
|
||||
|
||||
traits.Add(type, ctor.Invoke(new object[] { this }));
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException( "No Actor traits for " + Info.Name
|
||||
+ "; add Traits= to units.ini for appropriate unit" );
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
@@ -56,7 +55,7 @@ namespace OpenRa.Game
|
||||
nextActivity = nextActivity.Tick( this );
|
||||
}
|
||||
|
||||
foreach (var tick in traits.WithInterface<Traits.ITick>())
|
||||
foreach (var tick in traits.WithInterface<ITick>())
|
||||
tick.Tick(this);
|
||||
}
|
||||
|
||||
@@ -74,7 +73,7 @@ namespace OpenRa.Game
|
||||
|
||||
public IEnumerable<Tuple<Sprite, float2, int>> Render()
|
||||
{
|
||||
return traits.WithInterface<Traits.IRender>().SelectMany( x => x.Render( this ) );
|
||||
return traits.WithInterface<IRender>().SelectMany( x => x.Render( this ) );
|
||||
}
|
||||
|
||||
public Order Order( int2 xy, MouseInput mi )
|
||||
@@ -90,7 +89,7 @@ namespace OpenRa.Game
|
||||
if (underCursor != null && !underCursor.Info.Selectable)
|
||||
underCursor = null;
|
||||
|
||||
return traits.WithInterface<Traits.IOrder>()
|
||||
return traits.WithInterface<IOrder>()
|
||||
.Select( x => x.IssueOrder( this, xy, mi, underCursor ) )
|
||||
.FirstOrDefault( x => x != null );
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace OpenRa.Game
|
||||
}
|
||||
}
|
||||
|
||||
Cache<int, List<Actor>> cache = new Cache<int, List<Actor>>(_ => new List<Actor>());
|
||||
Cache<int, List<Actor>> controlGroups = new Cache<int, List<Actor>>(_ => new List<Actor>());
|
||||
|
||||
public void DoControlGroup(int group, Modifiers mods)
|
||||
{
|
||||
@@ -159,19 +159,19 @@ namespace OpenRa.Game
|
||||
if (uog == null || !uog.selection.Any())
|
||||
return;
|
||||
|
||||
cache[group].Clear();
|
||||
cache[group].AddRange(uog.selection);
|
||||
controlGroups[group].Clear();
|
||||
controlGroups[group].AddRange(uog.selection);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mods.HasModifier(Modifiers.Alt))
|
||||
{
|
||||
Game.viewport.Center(cache[group]);
|
||||
Game.viewport.Center(controlGroups[group]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (uog == null) return;
|
||||
CombineSelection(cache[group], mods.HasModifier(Modifiers.Shift), false);
|
||||
CombineSelection(controlGroups[group], mods.HasModifier(Modifiers.Shift), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Class Name="OpenRa.Game.Game">
|
||||
<Position X="9.5" Y="9.25" Width="1.5" />
|
||||
<Position X="9.5" Y="9.25" Width="2.25" />
|
||||
<Members>
|
||||
<Method Name="FindUnits" Hidden="true" />
|
||||
<Field Name="lastTime" Hidden="true" />
|
||||
<Method Name="LoadMapActors" Hidden="true" />
|
||||
<Field Name="localPlayerIndex" Hidden="true" />
|
||||
<Field Name="oreFrequency" Hidden="true" />
|
||||
<Field Name="oreTicks" Hidden="true" />
|
||||
@@ -24,12 +25,16 @@
|
||||
<Position X="6.5" Y="10.75" Width="1.75" />
|
||||
<Members>
|
||||
<Method Name="ApplyOrders" Hidden="true" />
|
||||
<Method Name="CombineSelection" Hidden="true" />
|
||||
<Field Name="controlGroups" Hidden="true" />
|
||||
<Method Name="CursorForOrderString" Hidden="true" />
|
||||
<Field Name="dragEnd" Hidden="true" />
|
||||
<Field Name="dragStart" Hidden="true" />
|
||||
<Field Name="GetModifierKeys" Hidden="true" />
|
||||
<Field Name="recentOrders" Hidden="true" />
|
||||
</Members>
|
||||
<TypeIdentifier>
|
||||
<HashCode>ACACAACoAAAAAAAAAAQDEgQAABAAAAAAAAAAKAACCAA=</HashCode>
|
||||
<HashCode>AAACAACoAAAAAAAAAAQDEgQAABAAABAAAAAAKAACCAA=</HashCode>
|
||||
<FileName>Controller.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<ShowAsAssociation>
|
||||
@@ -38,14 +43,23 @@
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="OpenRa.Game.Graphics.Viewport">
|
||||
<Position X="12.5" Y="10.25" Width="1.5" />
|
||||
<Position X="13.5" Y="10.25" Width="1.75" />
|
||||
<Members>
|
||||
<Field Name="cursorFrame" Hidden="true" />
|
||||
<Field Name="cursorRenderer" Hidden="true" />
|
||||
<Field Name="dragRegion" Hidden="true" />
|
||||
<Field Name="mousePos" Hidden="true" />
|
||||
<Field Name="renderer" Hidden="true" />
|
||||
<Field Name="screenSize" Hidden="true" />
|
||||
<Field Name="scrollPosition" Hidden="true" />
|
||||
</Members>
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAIAAAAABAAACABCAAYAEEAAAABAAAAAAAAgAEEIwBE=</HashCode>
|
||||
<FileName>Graphics\Viewport.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="OpenRa.Game.World">
|
||||
<Position X="4.75" Y="17.25" Width="1.5" />
|
||||
<Position X="4.75" Y="17.25" Width="2" />
|
||||
<Members>
|
||||
<Field Name="actors" Hidden="true" />
|
||||
<Field Name="effects" Hidden="true" />
|
||||
@@ -61,7 +75,7 @@
|
||||
</ShowAsCollectionAssociation>
|
||||
</Class>
|
||||
<Class Name="OpenRa.Game.Actor">
|
||||
<Position X="9.5" Y="16.75" Width="1.5" />
|
||||
<Position X="9.5" Y="16.75" Width="1.75" />
|
||||
<Members>
|
||||
<Field Name="currentActivity" Hidden="true" />
|
||||
</Members>
|
||||
@@ -81,7 +95,12 @@
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="OpenRa.Game.Player">
|
||||
<Position X="11.75" Y="16.75" Width="1.5" />
|
||||
<Position X="11.75" Y="16.75" Width="2.25" />
|
||||
<Members>
|
||||
<Field Name="displayCashDeltaPerFrame" Hidden="true" />
|
||||
<Method Name="GiveAdvice" Hidden="true" />
|
||||
<Method Name="UpdatePower" Hidden="true" />
|
||||
</Members>
|
||||
<TypeIdentifier>
|
||||
<HashCode>QEEEAAQAAAIAQQAACAMAACCAAAAAAA0gCAEAAQABQAA=</HashCode>
|
||||
<FileName>Player.cs</FileName>
|
||||
@@ -123,7 +142,17 @@
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="OpenRa.Game.PathFinder">
|
||||
<Position X="15" Y="7.75" Width="1.5" />
|
||||
<Position X="9.25" Y="6.25" Width="1.75" />
|
||||
<Members>
|
||||
<Method Name="AvoidUnitsNear" Hidden="true" />
|
||||
<Method Name="CheckSanePath" Hidden="true" />
|
||||
<Method Name="CheckSanePath2" Hidden="true" />
|
||||
<Method Name="FindBidiPath" Hidden="true" />
|
||||
<Method Name="IsBlocked" Hidden="true" />
|
||||
<Method Name="MakeBidiPath" Hidden="true" />
|
||||
<Method Name="MakePath" Hidden="true" />
|
||||
<Field Name="passableCost" Hidden="true" />
|
||||
</Members>
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAgAACAAAICAAgAEoAAMAAAAAAAAgA=</HashCode>
|
||||
<FileName>PathFinder.cs</FileName>
|
||||
|
||||
Reference in New Issue
Block a user