Update copyright header. Normalize line endings to LF.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2011 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.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,160 +1,160 @@
|
||||
#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
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.GameRules;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class AttackPopupTurretedInfo : AttackBaseInfo
|
||||
{
|
||||
public int CloseDelay = 125;
|
||||
public int DefaultFacing = 0;
|
||||
public float ClosedDamageMultiplier = 0.5f;
|
||||
public override object Create(ActorInitializer init) { return new AttackPopupTurreted( init.self, this ); }
|
||||
}
|
||||
|
||||
class AttackPopupTurreted : AttackBase, INotifyBuildComplete, INotifyIdle, IDamageModifier
|
||||
{
|
||||
enum PopupState
|
||||
{
|
||||
Open,
|
||||
Rotating,
|
||||
Transitioning,
|
||||
Closed
|
||||
};
|
||||
|
||||
protected Target target;
|
||||
AttackPopupTurretedInfo Info;
|
||||
Turreted Turret;
|
||||
int IdleTicks = 0;
|
||||
PopupState State = PopupState.Open;
|
||||
|
||||
public AttackPopupTurreted(Actor self, AttackPopupTurretedInfo info) : base(self)
|
||||
{
|
||||
Info = info;
|
||||
Turret = self.Trait<Turreted>();
|
||||
}
|
||||
|
||||
protected override bool CanAttack( Actor self, Target target )
|
||||
{
|
||||
if (State == PopupState.Transitioning)
|
||||
return false;
|
||||
|
||||
if( self.HasTrait<Building>() && !buildComplete )
|
||||
return false;
|
||||
|
||||
if (!base.CanAttack( self, target ))
|
||||
return false;
|
||||
|
||||
IdleTicks = 0;
|
||||
if (State == PopupState.Closed)
|
||||
{
|
||||
State = PopupState.Transitioning;
|
||||
var rb = self.Trait<RenderBuilding>();
|
||||
rb.PlayCustomAnimThen(self, "opening", () =>
|
||||
{
|
||||
State = PopupState.Open;
|
||||
rb.PlayCustomAnimRepeating(self, "idle");
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
Turret.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, Turret.turretFacing );
|
||||
if( Turret.desiredFacing != Turret.turretFacing )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
DoAttack( self, target );
|
||||
}
|
||||
|
||||
public void TickIdle(Actor self)
|
||||
{
|
||||
if (State == PopupState.Open && IdleTicks++ > Info.CloseDelay)
|
||||
{
|
||||
Turret.desiredFacing = Info.DefaultFacing;
|
||||
State = PopupState.Rotating;
|
||||
}
|
||||
else if (State == PopupState.Rotating && Turret.turretFacing == Info.DefaultFacing)
|
||||
{
|
||||
State = PopupState.Transitioning;
|
||||
var rb = self.Trait<RenderBuilding>();
|
||||
rb.PlayCustomAnimThen(self, "closing", () =>
|
||||
{
|
||||
State = PopupState.Closed;
|
||||
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
||||
Turret.desiredFacing = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
return new AttackActivity( newTarget );
|
||||
}
|
||||
|
||||
public override void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
base.ResolveOrder(self, order);
|
||||
|
||||
if (order.OrderString == "Stop")
|
||||
target = Target.None;
|
||||
}
|
||||
|
||||
bool buildComplete = false;
|
||||
public void BuildingComplete(Actor self) { buildComplete = true; }
|
||||
|
||||
public float GetDamageModifier(Actor attacker, WarheadInfo warhead)
|
||||
{
|
||||
return State == PopupState.Closed ? Info.ClosedDamageMultiplier : 1f;
|
||||
}
|
||||
|
||||
class AttackActivity : CancelableActivity
|
||||
{
|
||||
readonly Target target;
|
||||
public AttackActivity( Target newTarget ) { this.target = newTarget; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||
|
||||
if (self.TraitsImplementing<IDisable>().Any(d => d.Disabled))
|
||||
return this;
|
||||
|
||||
var attack = self.Trait<AttackPopupTurreted>();
|
||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||
var weapon = attack.ChooseWeaponForTarget(target);
|
||||
if (weapon != null)
|
||||
{
|
||||
attack.target = target;
|
||||
|
||||
if (self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
|
||||
return Util.SequenceActivities(
|
||||
new Follow( target, Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ),
|
||||
this );
|
||||
}
|
||||
return NextActivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.GameRules;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class AttackPopupTurretedInfo : AttackBaseInfo
|
||||
{
|
||||
public int CloseDelay = 125;
|
||||
public int DefaultFacing = 0;
|
||||
public float ClosedDamageMultiplier = 0.5f;
|
||||
public override object Create(ActorInitializer init) { return new AttackPopupTurreted( init.self, this ); }
|
||||
}
|
||||
|
||||
class AttackPopupTurreted : AttackBase, INotifyBuildComplete, INotifyIdle, IDamageModifier
|
||||
{
|
||||
enum PopupState
|
||||
{
|
||||
Open,
|
||||
Rotating,
|
||||
Transitioning,
|
||||
Closed
|
||||
};
|
||||
|
||||
protected Target target;
|
||||
AttackPopupTurretedInfo Info;
|
||||
Turreted Turret;
|
||||
int IdleTicks = 0;
|
||||
PopupState State = PopupState.Open;
|
||||
|
||||
public AttackPopupTurreted(Actor self, AttackPopupTurretedInfo info) : base(self)
|
||||
{
|
||||
Info = info;
|
||||
Turret = self.Trait<Turreted>();
|
||||
}
|
||||
|
||||
protected override bool CanAttack( Actor self, Target target )
|
||||
{
|
||||
if (State == PopupState.Transitioning)
|
||||
return false;
|
||||
|
||||
if( self.HasTrait<Building>() && !buildComplete )
|
||||
return false;
|
||||
|
||||
if (!base.CanAttack( self, target ))
|
||||
return false;
|
||||
|
||||
IdleTicks = 0;
|
||||
if (State == PopupState.Closed)
|
||||
{
|
||||
State = PopupState.Transitioning;
|
||||
var rb = self.Trait<RenderBuilding>();
|
||||
rb.PlayCustomAnimThen(self, "opening", () =>
|
||||
{
|
||||
State = PopupState.Open;
|
||||
rb.PlayCustomAnimRepeating(self, "idle");
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
Turret.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, Turret.turretFacing );
|
||||
if( Turret.desiredFacing != Turret.turretFacing )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
DoAttack( self, target );
|
||||
}
|
||||
|
||||
public void TickIdle(Actor self)
|
||||
{
|
||||
if (State == PopupState.Open && IdleTicks++ > Info.CloseDelay)
|
||||
{
|
||||
Turret.desiredFacing = Info.DefaultFacing;
|
||||
State = PopupState.Rotating;
|
||||
}
|
||||
else if (State == PopupState.Rotating && Turret.turretFacing == Info.DefaultFacing)
|
||||
{
|
||||
State = PopupState.Transitioning;
|
||||
var rb = self.Trait<RenderBuilding>();
|
||||
rb.PlayCustomAnimThen(self, "closing", () =>
|
||||
{
|
||||
State = PopupState.Closed;
|
||||
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
||||
Turret.desiredFacing = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
return new AttackActivity( newTarget );
|
||||
}
|
||||
|
||||
public override void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
base.ResolveOrder(self, order);
|
||||
|
||||
if (order.OrderString == "Stop")
|
||||
target = Target.None;
|
||||
}
|
||||
|
||||
bool buildComplete = false;
|
||||
public void BuildingComplete(Actor self) { buildComplete = true; }
|
||||
|
||||
public float GetDamageModifier(Actor attacker, WarheadInfo warhead)
|
||||
{
|
||||
return State == PopupState.Closed ? Info.ClosedDamageMultiplier : 1f;
|
||||
}
|
||||
|
||||
class AttackActivity : CancelableActivity
|
||||
{
|
||||
readonly Target target;
|
||||
public AttackActivity( Target newTarget ) { this.target = newTarget; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||
|
||||
if (self.TraitsImplementing<IDisable>().Any(d => d.Disabled))
|
||||
return this;
|
||||
|
||||
var attack = self.Trait<AttackPopupTurreted>();
|
||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||
var weapon = attack.ChooseWeaponForTarget(target);
|
||||
if (weapon != null)
|
||||
{
|
||||
attack.target = target;
|
||||
|
||||
if (self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
|
||||
return Util.SequenceActivities(
|
||||
new Follow( target, Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ),
|
||||
this );
|
||||
}
|
||||
return NextActivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2011 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.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Cnc
|
||||
WidgetUtils.FillRectWithSprite(BgRect, Bg);
|
||||
WidgetUtils.FillRectWithSprite(StripeRect, Stripe);
|
||||
r.RgbaSpriteRenderer.DrawSprite(Logo, LogoPos);
|
||||
Font.DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.Black);
|
||||
Font.DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.Black);
|
||||
r.EndFrame( new NullInputHandler() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +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
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Traits;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class CncWaterPaletteRotationInfo : TraitInfo<CncWaterPaletteRotation> {}
|
||||
|
||||
class CncWaterPaletteRotation : ITick, IPaletteModifier
|
||||
{
|
||||
|
||||
float t = 0;
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
t += .25f;
|
||||
}
|
||||
|
||||
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
||||
{
|
||||
// Only modify the terrain palette
|
||||
var pal = palettes["terrain"];
|
||||
|
||||
var copy = (uint[])pal.Values.Clone();
|
||||
var rotate = (int)t % 7;
|
||||
for (int i = 0; i < 7; i++)
|
||||
pal.SetColor(0x20 + (rotate + i) % 7, copy[0x20 + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Traits;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class CncWaterPaletteRotationInfo : TraitInfo<CncWaterPaletteRotation> {}
|
||||
|
||||
class CncWaterPaletteRotation : ITick, IPaletteModifier
|
||||
{
|
||||
|
||||
float t = 0;
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
t += .25f;
|
||||
}
|
||||
|
||||
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
||||
{
|
||||
// Only modify the terrain palette
|
||||
var pal = palettes["terrain"];
|
||||
|
||||
var copy = (uint[])pal.Values.Clone();
|
||||
var rotate = (int)t % 7;
|
||||
for (int i = 0; i < 7; i++)
|
||||
pal.SetColor(0x20 + (rotate + i) % 7, copy[0x20 + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
#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
|
||||
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class DeadBuildingStateInfo : ITraitInfo, ITraitPrerequisite<HealthInfo>, ITraitPrerequisite<RenderSimpleInfo>
|
||||
{
|
||||
public readonly int LingerTime = 20;
|
||||
public readonly bool Zombie = false; // Civilian structures stick around after death
|
||||
public object Create(ActorInitializer init) { return new DeadBuildingState(init.self, this); }
|
||||
}
|
||||
|
||||
class DeadBuildingState : INotifyDamage
|
||||
{
|
||||
DeadBuildingStateInfo info;
|
||||
RenderSimple rs;
|
||||
public DeadBuildingState(Actor self, DeadBuildingStateInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
rs = self.Trait<RenderSimple>();
|
||||
self.Trait<Health>().RemoveOnDeath = !rs.anim.HasSequence("dead");
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageStateChanged && e.DamageState == DamageState.Dead)
|
||||
{
|
||||
if (!rs.anim.HasSequence("dead")) return;
|
||||
rs.anim.PlayRepeating("dead");
|
||||
if (!info.Zombie)
|
||||
self.World.AddFrameEndTask(
|
||||
w => w.Add(
|
||||
new DelayedAction(info.LingerTime,
|
||||
() => self.Destroy())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class DeadBuildingStateInfo : ITraitInfo, ITraitPrerequisite<HealthInfo>, ITraitPrerequisite<RenderSimpleInfo>
|
||||
{
|
||||
public readonly int LingerTime = 20;
|
||||
public readonly bool Zombie = false; // Civilian structures stick around after death
|
||||
public object Create(ActorInitializer init) { return new DeadBuildingState(init.self, this); }
|
||||
}
|
||||
|
||||
class DeadBuildingState : INotifyDamage
|
||||
{
|
||||
DeadBuildingStateInfo info;
|
||||
RenderSimple rs;
|
||||
public DeadBuildingState(Actor self, DeadBuildingStateInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
rs = self.Trait<RenderSimple>();
|
||||
self.Trait<Health>().RemoveOnDeath = !rs.anim.HasSequence("dead");
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageStateChanged && e.DamageState == DamageState.Dead)
|
||||
{
|
||||
if (!rs.anim.HasSequence("dead")) return;
|
||||
rs.anim.PlayRepeating("dead");
|
||||
if (!info.Zombie)
|
||||
self.World.AddFrameEndTask(
|
||||
w => w.Add(
|
||||
new DelayedAction(info.LingerTime,
|
||||
() => self.Destroy())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
#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
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Effects
|
||||
{
|
||||
public class IonCannon : IEffect
|
||||
{
|
||||
Target target;
|
||||
Animation anim;
|
||||
Actor firedBy;
|
||||
|
||||
public IonCannon(Actor firedBy, World world, int2 location)
|
||||
{
|
||||
this.firedBy = firedBy;
|
||||
target = Target.FromCell(location);
|
||||
anim = new Animation("ionsfx");
|
||||
anim.PlayThen("idle", () => Finish(world));
|
||||
}
|
||||
|
||||
public void Tick(World world) { anim.Tick(); }
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,
|
||||
target.CenterLocation - new float2(.5f * anim.Image.size.X, anim.Image.size.Y - Game.CellSize),
|
||||
"effect", (int)target.CenterLocation.Y);
|
||||
}
|
||||
|
||||
void Finish( World world )
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Combat.DoExplosion(firedBy, "IonCannon", target.CenterLocation, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Effects
|
||||
{
|
||||
public class IonCannon : IEffect
|
||||
{
|
||||
Target target;
|
||||
Animation anim;
|
||||
Actor firedBy;
|
||||
|
||||
public IonCannon(Actor firedBy, World world, int2 location)
|
||||
{
|
||||
this.firedBy = firedBy;
|
||||
target = Target.FromCell(location);
|
||||
anim = new Animation("ionsfx");
|
||||
anim.PlayThen("idle", () => Finish(world));
|
||||
}
|
||||
|
||||
public void Tick(World world) { anim.Tick(); }
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,
|
||||
target.CenterLocation - new float2(.5f * anim.Image.size.X, anim.Image.size.Y - Game.CellSize),
|
||||
"effect", (int)target.CenterLocation.Y);
|
||||
}
|
||||
|
||||
void Finish( World world )
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Combat.DoExplosion(firedBy, "IonCannon", target.CenterLocation, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
#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
|
||||
|
||||
using OpenRA.Mods.Cnc.Effects;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class IonCannonPowerInfo : SupportPowerInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new IonCannonPower(init.self, this); }
|
||||
}
|
||||
|
||||
class IonCannonPower : SupportPower
|
||||
{
|
||||
public IonCannonPower(Actor self, IonCannonPowerInfo info) : base(self, info) { }
|
||||
public override void Activate(Actor self, Order order)
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
Sound.Play(Info.LaunchSound, Game.CellSize * order.TargetLocation.ToFloat2());
|
||||
w.Add(new IonCannon(self, w, order.TargetLocation));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.Cnc.Effects;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class IonCannonPowerInfo : SupportPowerInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new IonCannonPower(init.self, this); }
|
||||
}
|
||||
|
||||
class IonCannonPower : SupportPower
|
||||
{
|
||||
public IonCannonPower(Actor self, IonCannonPowerInfo info) : base(self, info) { }
|
||||
public override void Activate(Actor self, Order order)
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
Sound.Play(Info.LaunchSound, Game.CellSize * order.TargetLocation.ToFloat2());
|
||||
w.Add(new IonCannon(self, w, order.TargetLocation));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2011 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.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
@@ -22,28 +22,28 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
class CncShellmapScript: IWorldLoaded, ITick
|
||||
{
|
||||
Dictionary<string, Actor> Actors;
|
||||
Dictionary<string, Actor> Actors;
|
||||
static int2 ViewportOrigin;
|
||||
Map Map;
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
{
|
||||
Map = w.Map;
|
||||
var b = w.Map.Bounds;
|
||||
ViewportOrigin = new int2(b.Left + b.Width/2, b.Top + b.Height/2);
|
||||
Game.MoveViewport(ViewportOrigin);
|
||||
Game.MoveViewport(ViewportOrigin);
|
||||
|
||||
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||
Sound.SoundVolumeModifier = 0.25f;
|
||||
}
|
||||
|
||||
int ticks = 0;
|
||||
int ticks = 0;
|
||||
float speed = 4f;
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var loc = new float2(
|
||||
(float)(-System.Math.Sin((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 15f + ViewportOrigin.X),
|
||||
(float)(0.4f*System.Math.Cos((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 10f + ViewportOrigin.Y));
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var loc = new float2(
|
||||
(float)(-System.Math.Sin((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 15f + ViewportOrigin.X),
|
||||
(float)(0.4f*System.Math.Cos((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 10f + ViewportOrigin.Y));
|
||||
Game.MoveViewport(loc);
|
||||
|
||||
if (ticks == 0)
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2011 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.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
Map = w.Map;
|
||||
Map = w.Map;
|
||||
Players = w.players.Values.ToDictionary(p => p.InternalName);
|
||||
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||
var b = w.Map.Bounds;
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Cnc
|
||||
new OwnerInit( Players["BadGuy"] ),
|
||||
new FacingInit( 0 ),
|
||||
new LocationInit ( Actors["nod0"].Location ),
|
||||
});
|
||||
});
|
||||
var mobile = a.Trait<Mobile>();
|
||||
a.QueueActivity( mobile.MoveTo( Actors["nod1"].Location, 2 ) );
|
||||
a.QueueActivity( mobile.MoveTo( Actors["nod2"].Location, 2 ) );
|
||||
@@ -164,8 +164,8 @@ namespace OpenRA.Mods.Cnc
|
||||
}
|
||||
|
||||
void SetGunboatPath()
|
||||
{
|
||||
var self = Actors[ "Gunboat" ];
|
||||
{
|
||||
var self = Actors[ "Gunboat" ];
|
||||
var mobile = self.Trait<Mobile>();
|
||||
self.QueueActivity(mobile.ScriptedMove( Actors["gunboatLeft"].Location ));
|
||||
self.QueueActivity(mobile.ScriptedMove( Actors["gunboatRight"].Location ));
|
||||
@@ -183,8 +183,8 @@ namespace OpenRA.Mods.Cnc
|
||||
new LocationInit( startPos ),
|
||||
new OwnerInit( Players["GoodGuy"] ),
|
||||
new FacingInit( 0 ),
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var mobile = a.Trait<Mobile>();
|
||||
var cargo = a.Trait<Cargo>();
|
||||
foreach (var i in items)
|
||||
@@ -202,7 +202,7 @@ namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
var b = cargo.Unload(a);
|
||||
world.AddFrameEndTask(w2 =>
|
||||
{
|
||||
{
|
||||
if (b.Destroyed) return;
|
||||
w2.Add(b);
|
||||
b.TraitsImplementing<IMove>().FirstOrDefault().SetPosition(b, a.Location);
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
#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
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class PoisonedByTiberiumInfo : ITraitInfo
|
||||
{
|
||||
[WeaponReference]
|
||||
public readonly string Weapon = "Tiberium";
|
||||
public readonly string[] Resources = { "Tiberium", "BlueTiberium" };
|
||||
|
||||
public object Create(ActorInitializer init) { return new PoisonedByTiberium(this); }
|
||||
}
|
||||
|
||||
class PoisonedByTiberium : ITick, ISync
|
||||
{
|
||||
PoisonedByTiberiumInfo info;
|
||||
[Sync] int poisonTicks;
|
||||
|
||||
public PoisonedByTiberium(PoisonedByTiberiumInfo info) { this.info = info; }
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (--poisonTicks > 0) return;
|
||||
|
||||
var rl = self.World.WorldActor.Trait<ResourceLayer>();
|
||||
var r = rl.GetResource(self.Location);
|
||||
if( r == null ) return;
|
||||
if( !info.Resources.Contains(r.info.Name) ) return;
|
||||
|
||||
var weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
||||
|
||||
self.InflictDamage( self.World.WorldActor, weapon.Warheads[ 0 ].Damage, weapon.Warheads[ 0 ] );
|
||||
poisonTicks = weapon.ROF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class PoisonedByTiberiumInfo : ITraitInfo
|
||||
{
|
||||
[WeaponReference]
|
||||
public readonly string Weapon = "Tiberium";
|
||||
public readonly string[] Resources = { "Tiberium", "BlueTiberium" };
|
||||
|
||||
public object Create(ActorInitializer init) { return new PoisonedByTiberium(this); }
|
||||
}
|
||||
|
||||
class PoisonedByTiberium : ITick, ISync
|
||||
{
|
||||
PoisonedByTiberiumInfo info;
|
||||
[Sync] int poisonTicks;
|
||||
|
||||
public PoisonedByTiberium(PoisonedByTiberiumInfo info) { this.info = info; }
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (--poisonTicks > 0) return;
|
||||
|
||||
var rl = self.World.WorldActor.Trait<ResourceLayer>();
|
||||
var r = rl.GetResource(self.Location);
|
||||
if( r == null ) return;
|
||||
if( !info.Resources.Contains(r.info.Name) ) return;
|
||||
|
||||
var weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
||||
|
||||
self.InflictDamage( self.World.WorldActor, weapon.Warheads[ 0 ].Damage, weapon.Warheads[ 0 ] );
|
||||
poisonTicks = weapon.ROF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +1,73 @@
|
||||
#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
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
public class ProductionAirdropInfo : ProductionInfo
|
||||
{
|
||||
public readonly string ReadyAudio = "reinfor1.aud";
|
||||
public override object Create(ActorInitializer init) { return new ProductionAirdrop(this); }
|
||||
}
|
||||
|
||||
class ProductionAirdrop : Production
|
||||
{
|
||||
public ProductionAirdrop(ProductionAirdropInfo info) : base(info) {}
|
||||
|
||||
public override bool Produce( Actor self, ActorInfo producee )
|
||||
{
|
||||
var owner = self.Owner;
|
||||
|
||||
// Start and end beyond the edge of the map, to give a finite delay, and ability to land when AFLD is on map edge
|
||||
var startPos = new int2(owner.World.Map.Bounds.Right + 5, self.Location.Y);
|
||||
var endPos = new int2(owner.World.Map.Bounds.Left - 5, self.Location.Y);
|
||||
|
||||
// Assume a single exit point for simplicity
|
||||
var exit = self.Info.Traits.WithInterface<ExitInfo>().First();
|
||||
|
||||
var rb = self.Trait<RenderBuilding>();
|
||||
rb.PlayCustomAnimRepeating(self, "active");
|
||||
owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var a = w.CreateActor("C17", new TypeDictionary
|
||||
{
|
||||
new LocationInit( startPos ),
|
||||
new OwnerInit( owner ),
|
||||
new FacingInit( 64 ),
|
||||
new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
|
||||
});
|
||||
|
||||
a.QueueActivity(Fly.ToCell(self.Location + new int2(6,0)));
|
||||
a.QueueActivity(new Land(Target.FromActor(self)));
|
||||
a.QueueActivity(new CallFunc(() =>
|
||||
{
|
||||
if (!self.IsInWorld || self.IsDead())
|
||||
return;
|
||||
|
||||
rb.PlayCustomAnimRepeating(self, "idle");
|
||||
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
|
||||
Sound.PlayToPlayer(self.Owner, (Info as ProductionAirdropInfo).ReadyAudio);
|
||||
}));
|
||||
a.QueueActivity(Fly.ToCell(endPos));
|
||||
a.QueueActivity(new RemoveSelf());
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
public class ProductionAirdropInfo : ProductionInfo
|
||||
{
|
||||
public readonly string ReadyAudio = "reinfor1.aud";
|
||||
public override object Create(ActorInitializer init) { return new ProductionAirdrop(this); }
|
||||
}
|
||||
|
||||
class ProductionAirdrop : Production
|
||||
{
|
||||
public ProductionAirdrop(ProductionAirdropInfo info) : base(info) {}
|
||||
|
||||
public override bool Produce( Actor self, ActorInfo producee )
|
||||
{
|
||||
var owner = self.Owner;
|
||||
|
||||
// Start and end beyond the edge of the map, to give a finite delay, and ability to land when AFLD is on map edge
|
||||
var startPos = new int2(owner.World.Map.Bounds.Right + 5, self.Location.Y);
|
||||
var endPos = new int2(owner.World.Map.Bounds.Left - 5, self.Location.Y);
|
||||
|
||||
// Assume a single exit point for simplicity
|
||||
var exit = self.Info.Traits.WithInterface<ExitInfo>().First();
|
||||
|
||||
var rb = self.Trait<RenderBuilding>();
|
||||
rb.PlayCustomAnimRepeating(self, "active");
|
||||
owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var a = w.CreateActor("C17", new TypeDictionary
|
||||
{
|
||||
new LocationInit( startPos ),
|
||||
new OwnerInit( owner ),
|
||||
new FacingInit( 64 ),
|
||||
new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
|
||||
});
|
||||
|
||||
a.QueueActivity(Fly.ToCell(self.Location + new int2(6,0)));
|
||||
a.QueueActivity(new Land(Target.FromActor(self)));
|
||||
a.QueueActivity(new CallFunc(() =>
|
||||
{
|
||||
if (!self.IsInWorld || self.IsDead())
|
||||
return;
|
||||
|
||||
rb.PlayCustomAnimRepeating(self, "idle");
|
||||
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
|
||||
Sound.PlayToPlayer(self.Owner, (Info as ProductionAirdropInfo).ReadyAudio);
|
||||
}));
|
||||
a.QueueActivity(Fly.ToCell(endPos));
|
||||
a.QueueActivity(new RemoveSelf());
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2011 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.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2011 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.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
#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
|
||||
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class SpawnViceroidInfo : ITraitInfo
|
||||
{
|
||||
[ActorReference]
|
||||
public readonly string ViceroidActor = "vice";
|
||||
public readonly int Probability = 10;
|
||||
public readonly string Owner = "Creeps";
|
||||
public readonly int InfDeath = 5;
|
||||
|
||||
public object Create(ActorInitializer init) { return new SpawnViceroid(this); }
|
||||
}
|
||||
|
||||
class SpawnViceroid : INotifyDamage
|
||||
{
|
||||
readonly SpawnViceroidInfo Info;
|
||||
|
||||
public SpawnViceroid(SpawnViceroidInfo info)
|
||||
{
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead && e.Warhead.InfDeath == Info.InfDeath
|
||||
&& self.World.SharedRandom.Next(100) <= Info.Probability)
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var td = new TypeDictionary
|
||||
{
|
||||
new LocationInit( self.Location ),
|
||||
new OwnerInit( self.World.players.Values.First(p => p.InternalName == Info.Owner) )
|
||||
};
|
||||
|
||||
if (self.HasTrait<IFacing>())
|
||||
td.Add(new FacingInit( self.Trait<IFacing>().Facing ));
|
||||
w.CreateActor(Info.ViceroidActor, td);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class SpawnViceroidInfo : ITraitInfo
|
||||
{
|
||||
[ActorReference]
|
||||
public readonly string ViceroidActor = "vice";
|
||||
public readonly int Probability = 10;
|
||||
public readonly string Owner = "Creeps";
|
||||
public readonly int InfDeath = 5;
|
||||
|
||||
public object Create(ActorInitializer init) { return new SpawnViceroid(this); }
|
||||
}
|
||||
|
||||
class SpawnViceroid : INotifyDamage
|
||||
{
|
||||
readonly SpawnViceroidInfo Info;
|
||||
|
||||
public SpawnViceroid(SpawnViceroidInfo info)
|
||||
{
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead && e.Warhead.InfDeath == Info.InfDeath
|
||||
&& self.World.SharedRandom.Next(100) <= Info.Probability)
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var td = new TypeDictionary
|
||||
{
|
||||
new LocationInit( self.Location ),
|
||||
new OwnerInit( self.World.players.Values.First(p => p.InternalName == Info.Owner) )
|
||||
};
|
||||
|
||||
if (self.HasTrait<IFacing>())
|
||||
td.Add(new FacingInit( self.Trait<IFacing>().Facing ));
|
||||
w.CreateActor(Info.ViceroidActor, td);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2011 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.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
@@ -13,7 +13,7 @@ using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2011 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.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2011 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.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user