minelayer works in mod dll
This commit is contained in:
@@ -3,6 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRa.FileFormats;
|
using OpenRa.FileFormats;
|
||||||
using OpenRa.Traits;
|
using OpenRa.Traits;
|
||||||
|
using System.Reflection;
|
||||||
|
using IjwFramework.Types;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace OpenRa.GameRules
|
namespace OpenRa.GameRules
|
||||||
{
|
{
|
||||||
@@ -49,16 +52,25 @@ namespace OpenRa.GameRules
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: use mod metadata to do this
|
||||||
|
static Pair<Assembly, string>[] ModAssemblies =
|
||||||
|
{
|
||||||
|
Pair.New( typeof(ITraitInfo).Assembly, typeof(ITraitInfo).Namespace ),
|
||||||
|
Pair.New( Assembly.LoadFile(Path.GetFullPath(@"mods\ra\OpenRa.Mods.RA.dll")), "OpenRa.Mods.RA" )
|
||||||
|
};
|
||||||
|
|
||||||
static ITraitInfo LoadTraitInfo(string traitName, MiniYaml my)
|
static ITraitInfo LoadTraitInfo(string traitName, MiniYaml my)
|
||||||
{
|
{
|
||||||
var fullTypeName = typeof(ITraitInfo).Namespace + "." + traitName + "Info";
|
foreach (var mod in ModAssemblies)
|
||||||
var info = (ITraitInfo)typeof(ITraitInfo).Assembly.CreateInstance(fullTypeName);
|
{
|
||||||
|
var fullTypeName = mod.Second + "." + traitName + "Info";
|
||||||
|
var info = (ITraitInfo)mod.First.CreateInstance(fullTypeName);
|
||||||
|
if (info == null) continue;
|
||||||
|
FieldLoader.Load(info, my);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
if (info == null)
|
throw new InvalidOperationException("Cannot locate trait: {0}".F(traitName));
|
||||||
throw new NotImplementedException("Missing traitinfo type `{0}`".F(fullTypeName));
|
|
||||||
|
|
||||||
FieldLoader.Load(info, my);
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,6 @@
|
|||||||
<Compile Include="Traits\Activities\Turn.cs" />
|
<Compile Include="Traits\Activities\Turn.cs" />
|
||||||
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
||||||
<Compile Include="Traits\Activities\UnloadCargo.cs" />
|
<Compile Include="Traits\Activities\UnloadCargo.cs" />
|
||||||
<Compile Include="Traits\Mine.cs" />
|
|
||||||
<Compile Include="Traits\AttackBase.cs" />
|
<Compile Include="Traits\AttackBase.cs" />
|
||||||
<Compile Include="Traits\AttackFrontal.cs" />
|
<Compile Include="Traits\AttackFrontal.cs" />
|
||||||
<Compile Include="Traits\AttackHeli.cs" />
|
<Compile Include="Traits\AttackHeli.cs" />
|
||||||
@@ -237,8 +236,6 @@
|
|||||||
<Compile Include="Traits\IronCurtain.cs" />
|
<Compile Include="Traits\IronCurtain.cs" />
|
||||||
<Compile Include="Traits\IronCurtainable.cs" />
|
<Compile Include="Traits\IronCurtainable.cs" />
|
||||||
<Compile Include="Traits\LightPaletteRotator.cs" />
|
<Compile Include="Traits\LightPaletteRotator.cs" />
|
||||||
<Compile Include="Traits\MineImmune.cs" />
|
|
||||||
<Compile Include="Traits\Minelayer.cs" />
|
|
||||||
<Compile Include="Traits\LimitedAmmo.cs" />
|
<Compile Include="Traits\LimitedAmmo.cs" />
|
||||||
<Compile Include="Traits\Passenger.cs" />
|
<Compile Include="Traits\Passenger.cs" />
|
||||||
<Compile Include="Traits\ProvidesRadar.cs" />
|
<Compile Include="Traits\ProvidesRadar.cs" />
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRa.Effects;
|
|
||||||
|
|
||||||
namespace OpenRa.Traits
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
namespace OpenRa.Traits
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace OpenRa.Traits
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using OpenRa.Traits;
|
|
||||||
using OpenRa.Effects;
|
using OpenRa.Effects;
|
||||||
|
using OpenRa.Traits;
|
||||||
|
|
||||||
namespace OpenRa.Mods.RA
|
namespace OpenRa.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -54,7 +52,4 @@ namespace OpenRa.Mods.RA
|
|||||||
|
|
||||||
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
|
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
|
||||||
}
|
}
|
||||||
|
|
||||||
class MineImmuneInfo : StatelessTraitInfo<MineImmune> { }
|
|
||||||
class MineImmune { }
|
|
||||||
}
|
}
|
||||||
|
|||||||
7
OpenRa.Mods.RA/MineImmune.cs
Normal file
7
OpenRa.Mods.RA/MineImmune.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
using OpenRa.Traits;
|
||||||
|
|
||||||
|
namespace OpenRa.Mods.RA
|
||||||
|
{
|
||||||
|
class MineImmuneInfo : StatelessTraitInfo<MineImmune> { }
|
||||||
|
class MineImmune { }
|
||||||
|
}
|
||||||
@@ -1,20 +1,11 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using OpenRa.Traits;
|
using OpenRa.Traits;
|
||||||
using OpenRa;
|
|
||||||
|
|
||||||
namespace OpenRa.Mods.RA
|
namespace OpenRa.Mods.RA
|
||||||
{
|
{
|
||||||
class MinelayerInfo : ITraitInfo
|
class MinelayerInfo : StatelessTraitInfo<Minelayer>
|
||||||
{
|
{
|
||||||
public readonly string Mine = "minv";
|
public readonly string Mine = "minv";
|
||||||
|
|
||||||
public object Create(Actor self)
|
|
||||||
{
|
|
||||||
return new Minelayer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Minelayer : IIssueOrder, IResolveOrder
|
class Minelayer : IIssueOrder, IResolveOrder
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Mine.cs" />
|
<Compile Include="Mine.cs" />
|
||||||
|
<Compile Include="MineImmune.cs" />
|
||||||
<Compile Include="Minelayer.cs" />
|
<Compile Include="Minelayer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -67,4 +68,8 @@
|
|||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
|
<PropertyGroup>
|
||||||
|
<PostBuildEvent>mkdir "$(SolutionDir)mods/ra/"
|
||||||
|
copy "$(TargetPath)" "$(SolutionDir)mods/ra/"</PostBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
BIN
mods/ra/OpenRa.Mods.RA.dll
Normal file
BIN
mods/ra/OpenRa.Mods.RA.dll
Normal file
Binary file not shown.
Reference in New Issue
Block a user