Assembly resolving, fixes to crate dropping.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace OpenRA.FileFormats
|
namespace OpenRA.FileFormats
|
||||||
{
|
{
|
||||||
@@ -134,5 +135,34 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Dictionary<string, Assembly> assemblyCache = new Dictionary<string, Assembly>();
|
||||||
|
|
||||||
|
public static Assembly ResolveAssembly(object sender, ResolveEventArgs e)
|
||||||
|
{
|
||||||
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
if (assembly.FullName == e.Name)
|
||||||
|
return assembly;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] frags = e.Name.Split(',');
|
||||||
|
var filename = frags[0] + ".dll";
|
||||||
|
Assembly a;
|
||||||
|
if (assemblyCache.TryGetValue(filename, out a))
|
||||||
|
return a;
|
||||||
|
|
||||||
|
if (FileSystem.Exists(filename))
|
||||||
|
using (Stream s = FileSystem.Open(filename))
|
||||||
|
{
|
||||||
|
byte[] buf = new byte[s.Length];
|
||||||
|
s.Read(buf, 0, buf.Length);
|
||||||
|
a = Assembly.Load(buf);
|
||||||
|
assemblyCache.Add(filename, a);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,6 +348,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void PreInit(Settings settings)
|
public static void PreInit(Settings settings)
|
||||||
{
|
{
|
||||||
|
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
||||||
while (!Directory.Exists("mods"))
|
while (!Directory.Exists("mods"))
|
||||||
{
|
{
|
||||||
var current = Directory.GetCurrentDirectory();
|
var current = Directory.GetCurrentDirectory();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Traits.Activities;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA_NG
|
namespace OpenRA.Mods.RA_NG
|
||||||
{
|
{
|
||||||
@@ -72,9 +73,11 @@ namespace OpenRA.Mods.RA_NG
|
|||||||
{
|
{
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var crate = new Actor(w, "crate", new int2(0, 0), self.Owner);
|
var crate = new Actor(w, "crate", new int2(0, 0), w.NeutralPlayer);
|
||||||
crates.Add(crate);
|
crates.Add(crate);
|
||||||
var plane = w.CreateActor("BADR", w.ChooseRandomEdgeCell(), self.Owner);
|
var plane = w.CreateActor("BADR", w.ChooseRandomEdgeCell(), w.NeutralPlayer);
|
||||||
|
plane.CancelActivity();
|
||||||
|
plane.QueueActivity(new FlyCircle(p));
|
||||||
plane.traits.Get<ParaDrop>().SetLZ(p);
|
plane.traits.Get<ParaDrop>().SetLZ(p);
|
||||||
plane.traits.Get<Cargo>().Load(plane, crate);
|
plane.traits.Get<Cargo>().Load(plane, crate);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -65,9 +65,16 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
world.AddFrameEndTask(w =>
|
world.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
w.Remove(this);
|
w.Remove(this);
|
||||||
w.Add(cargo);
|
int2 loc = ((1 / 24f) * location).ToInt2();
|
||||||
cargo.CancelActivity();
|
cargo.CancelActivity();
|
||||||
cargo.traits.Get<Mobile>().TeleportTo(cargo, ((1 / 24f) * location).ToInt2());
|
if (cargo.traits.Contains<Mobile>())
|
||||||
|
cargo.traits.Get<Mobile>().TeleportTo(cargo, loc);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cargo.Location = loc;
|
||||||
|
cargo.CenterLocation = Util.CenterOfCell(loc);
|
||||||
|
}
|
||||||
|
w.Add(cargo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user