Remove AftermathInfo and move some Rules.GeneralInfo settings onto traits

This commit is contained in:
Paul Chote
2010-02-07 14:15:05 +13:00
parent 31881edade
commit 2e97f3d308
10 changed files with 66 additions and 56 deletions

View File

@@ -6,6 +6,9 @@ namespace OpenRa.Traits
{
class CloakInfo : ITraitInfo
{
public readonly float CloakDelay = 1.2f; // Seconds
public readonly string CloakSound = "ironcur9.aud";
public readonly string UncloakSound = "ironcur9.aud";
public object Create(Actor self) { return new Cloak(self); }
}
@@ -14,14 +17,18 @@ namespace OpenRa.Traits
[Sync]
int remainingUncloakTime = 2; /* setup for initial cloak */
public Cloak(Actor self) {}
Actor self;
public Cloak(Actor self)
{
this.self = self;
}
public void Attacking(Actor self)
{
if (remainingUncloakTime <= 0)
OnCloak();
remainingUncloakTime = (int)(Rules.General.SubmergeDelay * 60 * 25);
remainingUncloakTime = (int)(self.Info.Traits.Get<CloakInfo>().CloakDelay * 25);
}
public IEnumerable<Renderable>
@@ -45,12 +52,12 @@ namespace OpenRa.Traits
void OnCloak()
{
Sound.Play("ironcur9.aud");
Sound.Play(self.Info.Traits.Get<CloakInfo>().CloakSound);
}
void OnUncloak()
{
Sound.Play("ironcur9.aud"); /* is this the right sound?? */
Sound.Play(self.Info.Traits.Get<CloakInfo>().UncloakSound);
}
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Traits
{
class CrateSpawnerInfo : ITraitInfo
{
public readonly int CrateMinimum = 1; // Minumum number of crates
public readonly int CrateMaximum = 255; // Maximum number of crates
public readonly int CrateRadius = 3; // Radius of crate effect TODO: This belongs on the crate effect itself
public readonly int CrateRegen = 180; // Average time (seconds) between crate spawn
public readonly float WaterCrateChance = 0.2f; // Change of generating a water crate instead of a land crate
public object Create(Actor self) { return new CrateSpawner(self); }
}
class CrateSpawner
{
Actor self;
public CrateSpawner(Actor self)
{
this.self = self;
}
}
}

View File

@@ -5,7 +5,8 @@ namespace OpenRa.Traits
{
class HarvesterInfo : ITraitInfo
{
public object Create(Actor self) { return new Harvester(); }
public readonly int BailCount = 28;
public object Create(Actor self) { return new Harvester(self); }
}
public class Harvester : IIssueOrder, IResolveOrder, IPips
@@ -14,8 +15,14 @@ namespace OpenRa.Traits
public int oreCarried = 0; /* sum of these must not exceed capacity */
[Sync]
public int gemsCarried = 0;
Actor self;
public Harvester(Actor self)
{
this.self = self;
}
public bool IsFull { get { return oreCarried + gemsCarried == Rules.General.BailCount; } }
public bool IsFull { get { return oreCarried + gemsCarried == self.Info.Traits.Get<HarvesterInfo>().BailCount; } }
public bool IsEmpty { get { return oreCarried == 0 && gemsCarried == 0; } }
public void AcceptResource(bool isGem)
@@ -67,13 +74,13 @@ namespace OpenRa.Traits
const int numPips = 7;
for (int i = 0; i < numPips; i++)
{
if (gemsCarried * 1.0f / Rules.General.BailCount > i * 1.0f / numPips)
if (gemsCarried * 1.0f / self.Info.Traits.Get<HarvesterInfo>().BailCount > i * 1.0f / numPips)
{
yield return PipType.Red;
continue;
}
if ((gemsCarried + oreCarried) * 1.0f / Rules.General.BailCount > i * 1.0f / numPips)
if ((gemsCarried + oreCarried) * 1.0f / self.Info.Traits.Get<HarvesterInfo>().BailCount > i * 1.0f / numPips)
{
yield return PipType.Yellow;
continue;

View File

@@ -6,6 +6,9 @@ namespace OpenRa.Traits
{
class SubmarineInfo : ITraitInfo
{
public readonly float SubmergeDelay = 1.2f; // Seconds
public readonly string SubmergeSound = "subshow1.aud";
public readonly string SurfaceSound = "subshow1.aud";
public object Create(Actor self) { return new Submarine(self); }
}
@@ -13,15 +16,19 @@ namespace OpenRa.Traits
{
[Sync]
int remainingSurfaceTime = 2; /* setup for initial dive */
public Submarine(Actor self) { }
Actor self;
public Submarine(Actor self)
{
this.self = self;
}
void DoSurface()
{
if (remainingSurfaceTime <= 0)
OnSurface();
remainingSurfaceTime = (int)(Rules.General.SubmergeDelay * 60 * 25);
remainingSurfaceTime = (int)(self.Info.Traits.Get<SubmarineInfo>().SubmergeDelay * 25);
}
public void Attacking(Actor self) { DoSurface(); }
@@ -48,12 +55,12 @@ namespace OpenRa.Traits
void OnSurface()
{
Sound.Play("subshow1.aud");
Sound.Play(self.Info.Traits.Get<SubmarineInfo>().SurfaceSound);
}
void OnDive()
{
Sound.Play("subshow1.aud"); /* is this the right sound?? */
Sound.Play(self.Info.Traits.Get<SubmarineInfo>().SubmergeSound);
}
}
}