Shift Sight onto its own trait. Only cnc for now.

This commit is contained in:
Paul Chote
2010-07-28 21:37:10 +12:00
parent 8fab45ae39
commit eaa80fab74
10 changed files with 144 additions and 69 deletions

View File

@@ -227,6 +227,7 @@
<Compile Include="Widgets\WorldInteractionControllerWidget.cs" /> <Compile Include="Widgets\WorldInteractionControllerWidget.cs" />
<Compile Include="Widgets\ViewportScrollControllerWidget.cs" /> <Compile Include="Widgets\ViewportScrollControllerWidget.cs" />
<Compile Include="Traits\Player\DeveloperMode.cs" /> <Compile Include="Traits\Player\DeveloperMode.cs" />
<Compile Include="Traits\RevealsShroud.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -22,7 +22,6 @@ namespace OpenRA.Traits
{ {
public readonly int HP = 0; public readonly int HP = 0;
public readonly ArmorType Armor = ArmorType.none; public readonly ArmorType Armor = ArmorType.none;
public readonly int Sight = 0;
public readonly string[] TargetType = {"Ground"}; public readonly string[] TargetType = {"Ground"};
} }
@@ -47,7 +46,7 @@ namespace OpenRA.Traits
public object Create(ActorInitializer init) { return new Building(init); } public object Create(ActorInitializer init) { return new Building(init); }
} }
public class Building : INotifyDamage, IResolveOrder, ITick, IRenderModifier, IOccupySpace, IRadarSignature, IRevealShroud public class Building : INotifyDamage, IResolveOrder, ITick, IRenderModifier, IOccupySpace, IRadarSignature
{ {
readonly Actor self; readonly Actor self;
public readonly BuildingInfo Info; public readonly BuildingInfo Info;

View File

@@ -0,0 +1,40 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
namespace OpenRA.Traits
{
class RevealsShroudInfo : ITraitInfo
{
public readonly int Range = 0;
public object Create(ActorInitializer init) { return new RevealsShroud(this); }
}
class RevealsShroud : ITick
{
RevealsShroudInfo Info;
int2 previousLocation;
public RevealsShroud(RevealsShroudInfo info)
{
Info = info;
}
public void Tick(Actor self)
{
if (!self.IsIdle && previousLocation != self.Location)
{
previousLocation = self.Location;
self.World.WorldActor.traits.Get<Shroud>().UpdateActor(self);
}
}
public int RevealRange { get { return Info.Range; } }
}
}

View File

@@ -59,7 +59,6 @@ namespace OpenRA.Traits
public interface IVisibilityModifier { bool IsVisible(Actor self); } public interface IVisibilityModifier { bool IsVisible(Actor self); }
public interface IRadarColorModifier { Color RadarColorOverride(Actor self); } public interface IRadarColorModifier { Color RadarColorOverride(Actor self); }
public interface IRevealShroud {}
public interface IOccupySpace public interface IOccupySpace
{ {
int2 TopLeft { get; } int2 TopLeft { get; }

View File

@@ -23,22 +23,12 @@ namespace OpenRA.Traits
public object Create( ActorInitializer init ) { return new Unit(); } public object Create( ActorInitializer init ) { return new Unit(); }
} }
public class Unit : INotifyDamage, IRadarSignature, IRevealShroud, ITick public class Unit : INotifyDamage, IRadarSignature
{ {
[Sync] [Sync]
public int Facing; public int Facing;
[Sync] [Sync]
public int Altitude; public int Altitude;
int2 previousLocation;
public void Tick(Actor self)
{
if (!self.IsIdle && previousLocation != self.Location)
{
previousLocation = self.Location;
self.World.WorldActor.traits.Get<Shroud>().UpdateActor(self);
}
}
public void Damaged(Actor self, AttackInfo e) public void Damaged(Actor self, AttackInfo e)
{ {

View File

@@ -64,9 +64,9 @@ namespace OpenRA.Traits
void AddActor(Actor a) void AddActor(Actor a)
{ {
if (a.traits.WithInterface<IRevealShroud>().Count() == 0) if (!a.traits.Contains<RevealsShroud>())
return; return;
if (a.Owner == null || a.Owner.World.LocalPlayer == null if (a.Owner == null || a.Owner.World.LocalPlayer == null
|| a.Owner.Stances[a.Owner.World.LocalPlayer] != Stance.Ally) return; || a.Owner.Stances[a.Owner.World.LocalPlayer] != Stance.Ally) return;
@@ -78,7 +78,7 @@ namespace OpenRA.Traits
var v = new ActorVisibility var v = new ActorVisibility
{ {
range = a.Info.Traits.Get<OwnedActorInfo>().Sight, range = a.traits.Get<RevealsShroud>().RevealRange,
vis = GetVisOrigins(a).ToArray() vis = GetVisOrigins(a).ToArray()
}; };

View File

@@ -53,7 +53,8 @@
Category: Infantry Category: Infantry
Unit: Unit:
Armor: none Armor: none
Sight: 4 RevealsShroud:
Range: 4
Mobile: Mobile:
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 90%, 80%, 0% TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 90%, 80%, 0%
@@ -130,7 +131,6 @@
BuildSounds: hvydoor1.aud BuildSounds: hvydoor1.aud
Capturable: false Capturable: false
BaseNormal: no BaseNormal: no
Sight: 0
DamagedSound: xplos.aud DamagedSound: xplos.aud
DestroyedSound: xplobig4.aud DestroyedSound: xplobig4.aud
Adjacent: 7 Adjacent: 7

View File

@@ -143,7 +143,8 @@ RMBO:
Unit: Unit:
HP: 200 HP: 200
Speed: 5 Speed: 5
Sight: 5 RevealsShroud:
Range: 5
AttackBase: AttackBase:
PrimaryWeapon: Sniper PrimaryWeapon: Sniper
TakeCover: TakeCover:
@@ -160,8 +161,9 @@ C1:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol
@@ -175,8 +177,9 @@ C2:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol
@@ -190,8 +193,9 @@ C3:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol
@@ -205,8 +209,9 @@ C4:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol
@@ -220,8 +225,9 @@ C5:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol
@@ -235,8 +241,9 @@ C6:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol
@@ -250,8 +257,9 @@ C7:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol
C8: C8:
@@ -264,8 +272,9 @@ C8:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol
@@ -279,8 +288,9 @@ C9:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol
@@ -294,7 +304,8 @@ C10:
Description: Technician Description: Technician
Unit: Unit:
HP: 20 HP: 20
Sight: 2
Speed: 4 Speed: 4
RevealsShroud:
Range: 2
AttackBase: AttackBase:
PrimaryWeapon: Pistol PrimaryWeapon: Pistol

View File

@@ -10,7 +10,8 @@ FACT:
Capturable: true Capturable: true
HP: 800 HP: 800
Armor: wood Armor: wood
Sight: 5 RevealsShroud:
Range: 5
Bib: Bib:
Production: Production:
Produces: Building,Defense Produces: Building,Defense
@@ -32,7 +33,8 @@ NUKE:
Capturable: true Capturable: true
HP: 400 HP: 400
Armor: wood Armor: wood
Sight: 4 RevealsShroud:
Range: 4
Bib: Bib:
PROC.proxy: PROC.proxy:
@@ -52,7 +54,8 @@ PROC.proxy:
Capturable: true Capturable: true
HP: 900 HP: 900
Armor: wood Armor: wood
Sight: 6 RevealsShroud:
Range: 6
ReplaceWithActor: ReplaceWithActor:
Actor: proc Actor: proc
@@ -69,7 +72,8 @@ PROC:
Capturable: true Capturable: true
HP: 900 HP: 900
Armor: wood Armor: wood
Sight: 6 RevealsShroud:
Range: 6
Bib: Bib:
OreRefinery: OreRefinery:
LocalStorage: yes LocalStorage: yes
@@ -110,7 +114,8 @@ SILO:
Capturable: true Capturable: true
HP: 300 HP: 300
Armor: wood Armor: wood
Sight: 4 RevealsShroud:
Range: 4
RenderBuildingOre: RenderBuildingOre:
StoresOre: StoresOre:
PipCount: 5 PipCount: 5
@@ -137,7 +142,8 @@ PYLE:
Capturable: true Capturable: true
HP: 800 HP: 800
Armor: wood Armor: wood
Sight: 5 RevealsShroud:
Range: 5
Bib: Bib:
RallyPoint: RallyPoint:
Production: Production:
@@ -161,7 +167,8 @@ HAND:
Capturable: true Capturable: true
HP: 800 HP: 800
Armor: wood Armor: wood
Sight: 5 RevealsShroud:
Range: 5
Bib: Bib:
RallyPoint: RallyPoint:
Production: Production:
@@ -185,7 +192,8 @@ AFLD:
Capturable: true Capturable: true
HP: 1000 HP: 1000
Armor: heavy Armor: heavy
Sight: 7 RevealsShroud:
Range: 7
Bib: Bib:
RallyPoint: RallyPoint:
BelowUnits: BelowUnits:
@@ -210,7 +218,8 @@ WEAP:
Capturable: true Capturable: true
HP: 400 HP: 400
Armor: light Armor: light
Sight: 4 RevealsShroud:
Range: 4
Bib: Bib:
RenderWarFactory: RenderWarFactory:
RallyPoint: RallyPoint:
@@ -236,7 +245,8 @@ HQ:
Capturable: true Capturable: true
HP: 1000 HP: 1000
Armor: wood Armor: wood
Sight: 10 RevealsShroud:
Range: 10
Bib: Bib:
ProvidesRadar: ProvidesRadar:
DetectCloaked: DetectCloaked:
@@ -259,7 +269,8 @@ NUK2:
Capturable: true Capturable: true
HP: 600 HP: 600
Armor: wood Armor: wood
Sight: 4 RevealsShroud:
Range: 4
Bib: Bib:
FIX: FIX:
@@ -279,7 +290,8 @@ FIX:
Capturable: true Capturable: true
HP: 800 HP: 800
Armor: wood Armor: wood
Sight: 5 RevealsShroud:
Range: 5
BelowUnits: BelowUnits:
Reservable: Reservable:
RepairsUnits: RepairsUnits:
@@ -302,7 +314,8 @@ HPAD:
Capturable: true Capturable: true
HP: 800 HP: 800
Armor: wood Armor: wood
Sight: 5 RevealsShroud:
Range: 5
Bib: Bib:
Production: Production:
SpawnOffset: 0,-4 SpawnOffset: 0,-4
@@ -332,7 +345,8 @@ EYE:
Capturable: true Capturable: true
HP: 1000 HP: 1000
Armor: wood Armor: wood
Sight: 10 RevealsShroud:
Range: 10
Bib: Bib:
ProvidesRadar: ProvidesRadar:
IonControl: IonControl:
@@ -357,7 +371,8 @@ TMPL:
Capturable: false Capturable: false
HP: 2000 HP: 2000
Armor: light Armor: light
Sight: 6 RevealsShroud:
Range: 6
Bib: Bib:
NukeSilo: NukeSilo:
MissileWeapon: atomic MissileWeapon: atomic
@@ -380,7 +395,8 @@ OBLI:
Dimensions: 1,2 Dimensions: 1,2
HP: 400 HP: 400
Armor: light Armor: light
Sight: 8 RevealsShroud:
Range: 8
RenderBuildingCharge: RenderBuildingCharge:
ChargeAudio: obelpowr.aud ChargeAudio: obelpowr.aud
AttackOmni: AttackOmni:
@@ -458,7 +474,8 @@ GUN:
Power: -20 Power: -20
HP: 400 HP: 400
Armor: heavy Armor: heavy
Sight: 7 RevealsShroud:
Range: 7
Turreted: Turreted:
ROT: 12 ROT: 12
InitialFacing: 50 InitialFacing: 50
@@ -486,7 +503,8 @@ SAM:
Dimensions: 2,1 Dimensions: 2,1
HP: 400 HP: 400
Armor: heavy Armor: heavy
Sight: 5 RevealsShroud:
Range: 5
Turreted: Turreted:
ROT: 30 ROT: 30
InitialFacing: 0 InitialFacing: 0
@@ -512,7 +530,8 @@ GTWR:
Power: -10 Power: -10
HP: 400 HP: 400
Armor: wood Armor: wood
Sight: 6 RevealsShroud:
Range: 6
AttackOmni: AttackOmni:
PrimaryWeapon: HighV PrimaryWeapon: HighV
AutoTarget: AutoTarget:
@@ -535,7 +554,8 @@ ATWR:
Power: -20 Power: -20
HP: 600 HP: 600
Armor: light Armor: light
Sight: 8 RevealsShroud:
Range: 8
AttackOmni: AttackOmni:
PrimaryWeapon: Tomahawk PrimaryWeapon: Tomahawk
SecondaryWeapon: Tomahawk SecondaryWeapon: Tomahawk

View File

@@ -13,8 +13,9 @@ MCV:
Unit: Unit:
HP: 600 HP: 600
Armor: light Armor: light
Sight: 4
Speed: 6 Speed: 6
RevealsShroud:
Range: 4
TransformsOnDeploy: TransformsOnDeploy:
TransformsInto: fact TransformsInto: fact
Offset:-1,-1 Offset:-1,-1
@@ -44,8 +45,9 @@ HARV:
Unit: Unit:
HP: 600 HP: 600
Armor: light Armor: light
Sight: 4
Speed: 6 Speed: 6
RevealsShroud:
Range: 4
RenderUnit: RenderUnit:
APC: APC:
@@ -62,8 +64,9 @@ APC:
HP: 200 HP: 200
Armor: heavy Armor: heavy
ROT: 5 ROT: 5
Sight: 5
Speed: 15 Speed: 15
RevealsShroud:
Range: 5
AttackBase: AttackBase:
PrimaryWeapon: MachineGun PrimaryWeapon: MachineGun
PrimaryOffset: 0,0,0,-4 PrimaryOffset: 0,0,0,-4
@@ -90,8 +93,9 @@ ARTY:
HP: 75 HP: 75
Armor: light Armor: light
ROT: 2 ROT: 2
Sight: 6
Speed: 6 Speed: 6
RevealsShroud:
Range: 6
AttackBase: AttackBase:
PrimaryWeapon: Ballistic PrimaryWeapon: Ballistic
RenderUnit: RenderUnit:
@@ -112,8 +116,9 @@ FTNK:
HP: 300 HP: 300
Armor: heavy Armor: heavy
ROT: 5 ROT: 5
Sight: 4
Speed: 9 Speed: 9
RevealsShroud:
Range: 4
AttackBase: AttackBase:
PrimaryWeapon: BigFlamer PrimaryWeapon: BigFlamer
PrimaryOffset: 0,0,0,-2 PrimaryOffset: 0,0,0,-2
@@ -135,8 +140,9 @@ BGGY:
HP: 140 HP: 140
Armor: light Armor: light
ROT: 10 ROT: 10
Sight: 5
Speed: 18 Speed: 18
RevealsShroud:
Range: 5
Turreted: Turreted:
ROT: 10 ROT: 10
AttackTurreted: AttackTurreted:
@@ -160,8 +166,9 @@ BIKE:
HP: 160 HP: 160
Armor: none Armor: none
ROT: 10 ROT: 10
Sight: 7
Speed: 20 Speed: 20
RevealsShroud:
Range: 7
AttackBase: AttackBase:
PrimaryWeapon: Rockets PrimaryWeapon: Rockets
PrimaryOffset: 0,0,0,-2 PrimaryOffset: 0,0,0,-2
@@ -186,8 +193,9 @@ JEEP:
HP: 150 HP: 150
Armor: light Armor: light
ROT: 10 ROT: 10
Sight: 7
Speed: 15 Speed: 15
RevealsShroud:
Range: 7
Turreted: Turreted:
ROT: 10 ROT: 10
AttackTurreted: AttackTurreted:
@@ -210,8 +218,9 @@ LTNK:
Unit: Unit:
HP: 300 HP: 300
Armor: Heavy Armor: Heavy
Sight: 4
Speed: 9 Speed: 9
RevealsShroud:
Range: 4
Turreted: Turreted:
ROT: 5 ROT: 5
AttackTurreted: AttackTurreted:
@@ -238,8 +247,9 @@ MTNK:
Unit: Unit:
HP: 400 HP: 400
Armor: heavy Armor: heavy
Sight: 5
Speed: 9 Speed: 9
RevealsShroud:
Range: 5
Turreted: Turreted:
ROT: 5 ROT: 5
AttackTurreted: AttackTurreted:
@@ -266,8 +276,9 @@ HTNK:
Unit: Unit:
HP: 600 HP: 600
Armor: heavy Armor: heavy
Sight: 6
Speed: 3 Speed: 3
RevealsShroud:
Range: 6
Turreted: Turreted:
ROT: 2 ROT: 2
AttackTurreted: AttackTurreted:
@@ -300,8 +311,9 @@ MSAM:
Unit: Unit:
HP: 120 HP: 120
Armor: light Armor: light
Sight: 6
Speed: 6 Speed: 6
RevealsShroud:
Range: 6
Turreted: Turreted:
ROT: 5 ROT: 5
AttackTurreted: AttackTurreted:
@@ -327,8 +339,9 @@ MLRS:
Unit: Unit:
HP: 120 HP: 120
Armor: light Armor: light
Sight: 10
Speed: 6 Speed: 6
RevealsShroud:
Range: 10
Turreted: Turreted:
ROT: 5 ROT: 5
AttackTurreted: AttackTurreted:
@@ -350,8 +363,9 @@ STNK:
Unit: Unit:
HP: 110 HP: 110
Armor: light Armor: light
Sight: 4
Speed: 15 Speed: 15
RevealsShroud:
Range: 4
Cloak: Cloak:
InitialDelay: .4 InitialDelay: .4
CloakDelay: 2.0 CloakDelay: 2.0
@@ -378,8 +392,9 @@ TRAN:
Armor: light Armor: light
InitialFacing: 20 InitialFacing: 20
ROT: 5 ROT: 5
Sight: 8
Speed: 15 Speed: 15
RevealsShroud:
Range: 8
RenderUnitRotor: RenderUnitRotor:
PrimaryOffset: 0,14,0,-4 PrimaryOffset: 0,14,0,-4
SecondaryOffset: 0,-14,0,-2 SecondaryOffset: 0,-14,0,-2
@@ -404,8 +419,9 @@ HELI:
Armor: heavy Armor: heavy
InitialFacing: 20 InitialFacing: 20
ROT: 4 ROT: 4
Sight: 8
Speed: 20 Speed: 20
RevealsShroud:
Range: 8
AttackBase: AttackBase:
PrimaryWeapon: HighV PrimaryWeapon: HighV
SecondaryWeapon: HighV SecondaryWeapon: HighV
@@ -431,8 +447,9 @@ ORCA:
Armor: heavy Armor: heavy
InitialFacing: 20 InitialFacing: 20
ROT: 4 ROT: 4
Sight: 8
Speed: 20 Speed: 20
RevealsShroud:
Range: 8
AttackBase: AttackBase:
PrimaryWeapon: Rockets.Orca PrimaryWeapon: Rockets.Orca
SecondaryWeapon: Rockets.Orca SecondaryWeapon: Rockets.Orca
@@ -450,7 +467,6 @@ C17:
HP: 25 HP: 25
Armor: light Armor: light
ROT: 5 ROT: 5
Sight: 0
Speed: 25 Speed: 25
Plane: Plane:
RenderUnit: RenderUnit:
@@ -467,7 +483,6 @@ A10:
HP: 60 HP: 60
Armor: light Armor: light
ROT: 4 ROT: 4
Sight: 0
Speed: 25 Speed: 25
Plane: Plane:
RenderUnit: RenderUnit: