diff --git a/OpenRA.Mods.RA-NG/CrateDrop.cs b/OpenRA.Mods.RA-NG/CrateDrop.cs new file mode 100644 index 0000000000..af7547d795 --- /dev/null +++ b/OpenRA.Mods.RA-NG/CrateDrop.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using OpenRA.Mods.RA; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA_NG +{ + public class CrateDropInfo : ITraitInfo + { + public readonly int Minimum = 1; // Minumum number of crates + public readonly int Maximum = 255; // Maximum number of crates + public readonly int SpawnInterval = 180; // Average time (seconds) between crate spawn + public readonly float WaterChance = .2f; // Chance of generating a water crate instead of a land crate + + public object Create(Actor self) + { + return new CrateDrop(); + } + } + + public class CrateDrop : ITick + { + List crates = new List(); + int ticks = 0; + + public void Tick(Actor self) + { + if (--ticks <= 0) + { + var info = self.Info.Traits.Get(); + ticks = info.SpawnInterval * 25; // todo: randomize + + crates.RemoveAll(x => !x.IsInWorld); + + var toSpawn = Math.Max(0, info.Minimum - crates.Count) + + (crates.Count < info.Maximum ? 1 : 0); + + for (var n = 0; n < toSpawn; n++) + SpawnCrate(self, info); + } + } + + void SpawnCrate(Actor self, CrateDropInfo info) + { + var inWater = self.World.SharedRandom.NextDouble() < info.WaterChance; + var umt = inWater ? UnitMovementType.Float : UnitMovementType.Wheel; + int count = 0, threshold = 100; + for (; ; ) + { + var p = new int2(self.World.SharedRandom.Next(0, 127), self.World.SharedRandom.Next(0, 127)); + if (self.World.IsCellBuildable(p, umt)) + { + self.World.AddFrameEndTask(w => + { + var crate = new Actor(w, "crate", new int2(0, 0), self.Owner); + crates.Add(crate); + var plane = w.CreateActor("BADR", w.ChooseRandomEdgeCell(), self.Owner); + plane.traits.Get().SetLZ(p); + plane.traits.Get().Load(plane, crate); + }); + break; + } + if (count++ > threshold) + break; + } + } + } +} diff --git a/OpenRA.Mods.RA-NG/OpenRA.Mods.RA_NG.csproj b/OpenRA.Mods.RA-NG/OpenRA.Mods.RA_NG.csproj new file mode 100644 index 0000000000..9c1b20a5b3 --- /dev/null +++ b/OpenRA.Mods.RA-NG/OpenRA.Mods.RA_NG.csproj @@ -0,0 +1,77 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {6CA925E5-4A47-46AC-9DE3-FA341F7C94A7} + Library + Properties + OpenRA.Mods.RA_NG + OpenRA.Mods.RA_NG + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA} + OpenRA.FileFormats + + + {0DFB103F-2962-400F-8C6D-E2C28CCBA633} + OpenRA.Game + + + {4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E} + OpenRA.Mods.RA + + + + + + mkdir "$(SolutionDir)mods/ra-ng/" +copy "$(TargetPath)" "$(SolutionDir)mods/ra-ng/" + + \ No newline at end of file diff --git a/OpenRA.Mods.RA-NG/Properties/AssemblyInfo.cs b/OpenRA.Mods.RA-NG/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..9a24a407e9 --- /dev/null +++ b/OpenRA.Mods.RA-NG/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenRA.Mods.RA-NG")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("OpenRA.Mods.RA-NG")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3c94e0bf-6350-4703-a770-59cbc260d0a1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenRA.Mods.RA/ParaDrop.cs b/OpenRA.Mods.RA/ParaDrop.cs index 03c933cf39..bf7005bed2 100644 --- a/OpenRA.Mods.RA/ParaDrop.cs +++ b/OpenRA.Mods.RA/ParaDrop.cs @@ -25,13 +25,13 @@ using OpenRA.Traits.Activities; namespace OpenRA.Mods.RA { - class ParaDropInfo : ITraitInfo + public class ParaDropInfo : ITraitInfo { public readonly int LZRange = 4; public object Create(Actor self) { return new ParaDrop(); } } - class ParaDrop : ITick + public class ParaDrop : ITick { readonly List droppedAt = new List(); int2 lz; diff --git a/OpenRA.sln b/OpenRA.sln index 2ca505c31f..3132c46cdf 100644 --- a/OpenRA.sln +++ b/OpenRA.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Mods.Cnc", "OpenRA.M EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Gl", "OpenRA.Gl\OpenRA.Gl.csproj", "{67CF1A10-C5F6-48FA-B1A7-FE83BE4CE2CC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Mods.RA_NG", "OpenRA.Mods.RA-NG\OpenRA.Mods.RA_NG.csproj", "{6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -78,6 +80,14 @@ Global {67CF1A10-C5F6-48FA-B1A7-FE83BE4CE2CC}.Release|Any CPU.Build.0 = Release|Any CPU {67CF1A10-C5F6-48FA-B1A7-FE83BE4CE2CC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {67CF1A10-C5F6-48FA-B1A7-FE83BE4CE2CC}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}.Release|Any CPU.Build.0 = Release|Any CPU + {6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/mods/ra-ng/mod.yaml b/mods/ra-ng/mod.yaml index a216eb87e4..ee5f5e27d1 100644 --- a/mods/ra-ng/mod.yaml +++ b/mods/ra-ng/mod.yaml @@ -5,8 +5,11 @@ Packages: LegacyRules: Rules: + mods/ra-ng/rules.yaml mods/ra-ng/defense-queue.yaml Sequences: Assemblies: + mods/ra-ng/OpenRA.Mods.RA_NG.dll: + mods/ra/OpenRA.Mods.RA.dll: diff --git a/mods/ra-ng/rules.yaml b/mods/ra-ng/rules.yaml new file mode 100644 index 0000000000..4883a1ee3d --- /dev/null +++ b/mods/ra-ng/rules.yaml @@ -0,0 +1,7 @@ +World: + -CrateSpawner: + CrateDrop: + Minimum: 1 + Maximum: 3 + SpawnInterval: 20 + WaterChance: .2