fixed line-endings on *.cs
This commit is contained in:
@@ -56,7 +56,7 @@ namespace OpenRA.Traits.Activities
|
||||
.FirstOrDefault(a => a.traits.Contains<RenderBuilding>());
|
||||
|
||||
if (hostBuilding != null)
|
||||
hostBuilding.traits.Get<RenderBuilding>()
|
||||
hostBuilding.traits.Get<RenderBuilding>()
|
||||
.PlayCustomAnim(hostBuilding, "active");
|
||||
|
||||
remainingTicks = (int)(Rules.General.RepairRate * 60 * 25);
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
{
|
||||
|
||||
public class Wait: IActivity
|
||||
{
|
||||
int remainingTicks;
|
||||
|
||||
public Wait (int period)
|
||||
{
|
||||
remainingTicks = period;
|
||||
}
|
||||
|
||||
public IActivity Tick (Actor self)
|
||||
{
|
||||
if (remainingTicks-- == 0) return NextActivity;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public void Cancel (Actor self)
|
||||
{
|
||||
remainingTicks = 0; NextActivity = null;
|
||||
}
|
||||
|
||||
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
{
|
||||
|
||||
public class Wait: IActivity
|
||||
{
|
||||
int remainingTicks;
|
||||
|
||||
public Wait (int period)
|
||||
{
|
||||
remainingTicks = period;
|
||||
}
|
||||
|
||||
public IActivity Tick (Actor self)
|
||||
{
|
||||
if (remainingTicks-- == 0) return NextActivity;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public void Cancel (Actor self)
|
||||
{
|
||||
remainingTicks = 0; NextActivity = null;
|
||||
}
|
||||
|
||||
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Effects;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class CrateActionInfo : ITraitInfo
|
||||
{
|
||||
public int SelectionShares = 10;
|
||||
public string Effect = null;
|
||||
public string Notification = null;
|
||||
public virtual object Create(Actor self) { return new CrateAction(self, this); }
|
||||
}
|
||||
|
||||
public class CrateAction
|
||||
{
|
||||
public Actor self;
|
||||
public CrateActionInfo info;
|
||||
|
||||
public CrateAction(Actor self, CrateActionInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public virtual int GetSelectionShares(Actor collector)
|
||||
{
|
||||
return info.SelectionShares;
|
||||
}
|
||||
|
||||
public virtual void Activate(Actor collector)
|
||||
{
|
||||
Sound.PlayToPlayer(collector.Owner, info.Notification);
|
||||
|
||||
collector.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (info.Effect != null)
|
||||
w.Add(new CrateEffect(collector, info.Effect));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Effects;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class CrateActionInfo : ITraitInfo
|
||||
{
|
||||
public int SelectionShares = 10;
|
||||
public string Effect = null;
|
||||
public string Notification = null;
|
||||
public virtual object Create(Actor self) { return new CrateAction(self, this); }
|
||||
}
|
||||
|
||||
public class CrateAction
|
||||
{
|
||||
public Actor self;
|
||||
public CrateActionInfo info;
|
||||
|
||||
public CrateAction(Actor self, CrateActionInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public virtual int GetSelectionShares(Actor collector)
|
||||
{
|
||||
return info.SelectionShares;
|
||||
}
|
||||
|
||||
public virtual void Activate(Actor collector)
|
||||
{
|
||||
Sound.PlayToPlayer(collector.Owner, info.Notification);
|
||||
|
||||
collector.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (info.Effect != null)
|
||||
w.Add(new CrateEffect(collector, info.Effect));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
|
||||
class HasUnitOnBuildInfo : ITraitInfo
|
||||
{
|
||||
public readonly string Unit = null;
|
||||
public readonly string InitialActivity = null;
|
||||
public readonly int2 SpawnOffset = int2.Zero;
|
||||
public readonly int Facing = 0;
|
||||
|
||||
public object Create( Actor self ) { return new HasUnitOnBuild(self); }
|
||||
}
|
||||
|
||||
public class HasUnitOnBuild
|
||||
{
|
||||
|
||||
public HasUnitOnBuild(Actor self)
|
||||
{
|
||||
var info = self.Info.Traits.Get<HasUnitOnBuildInfo>();
|
||||
|
||||
self.World.AddFrameEndTask(
|
||||
w =>
|
||||
{
|
||||
var unit = w.CreateActor(info.Unit, self.Location
|
||||
+ info.SpawnOffset, self.Owner);
|
||||
var unitTrait = unit.traits.Get<Unit>();
|
||||
unitTrait.Facing = info.Facing;
|
||||
|
||||
if (info.InitialActivity != null)
|
||||
{
|
||||
foreach (var mod in Game.ModAssemblies)
|
||||
{
|
||||
var fullTypeName = mod.Second + "." + info.InitialActivity;
|
||||
var activity = (IActivity)mod.First.CreateInstance(fullTypeName);
|
||||
if (activity == null) continue;
|
||||
|
||||
unit.QueueActivity( activity );
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Cannot locate Activity: `{0}`".F(info.InitialActivity));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
|
||||
class HasUnitOnBuildInfo : ITraitInfo
|
||||
{
|
||||
public readonly string Unit = null;
|
||||
public readonly string InitialActivity = null;
|
||||
public readonly int2 SpawnOffset = int2.Zero;
|
||||
public readonly int Facing = 0;
|
||||
|
||||
public object Create( Actor self ) { return new HasUnitOnBuild(self); }
|
||||
}
|
||||
|
||||
public class HasUnitOnBuild
|
||||
{
|
||||
|
||||
public HasUnitOnBuild(Actor self)
|
||||
{
|
||||
var info = self.Info.Traits.Get<HasUnitOnBuildInfo>();
|
||||
|
||||
self.World.AddFrameEndTask(
|
||||
w =>
|
||||
{
|
||||
var unit = w.CreateActor(info.Unit, self.Location
|
||||
+ info.SpawnOffset, self.Owner);
|
||||
var unitTrait = unit.traits.Get<Unit>();
|
||||
unitTrait.Facing = info.Facing;
|
||||
|
||||
if (info.InitialActivity != null)
|
||||
{
|
||||
foreach (var mod in Game.ModAssemblies)
|
||||
{
|
||||
var fullTypeName = mod.Second + "." + info.InitialActivity;
|
||||
var activity = (IActivity)mod.First.CreateInstance(fullTypeName);
|
||||
if (activity == null) continue;
|
||||
|
||||
unit.QueueActivity( activity );
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Cannot locate Activity: `{0}`".F(info.InitialActivity));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class LineBuildInfo : StatelessTraitInfo<LineBuild>
|
||||
{
|
||||
public readonly int Range = 5;
|
||||
}
|
||||
public class LineBuild {}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class LineBuildInfo : StatelessTraitInfo<LineBuild>
|
||||
{
|
||||
public readonly int Range = 5;
|
||||
}
|
||||
public class LineBuild {}
|
||||
}
|
||||
|
||||
@@ -1,63 +1,63 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class EvaAlertsInfo : StatelessTraitInfo<EvaAlerts>
|
||||
{
|
||||
// Sound effects
|
||||
public readonly string TabClick = "ramenu1.aud";
|
||||
|
||||
public readonly string ChatBeep = "rabeep1.aud";
|
||||
public readonly string RadarUp = "radaron2.aud";
|
||||
public readonly string RadarDown = "radardn1.aud";
|
||||
|
||||
public readonly string CashTickUp = "cashup1.aud";
|
||||
public readonly string CashTickDown = "cashdn1.aud";
|
||||
|
||||
// Build Palette
|
||||
public readonly string BuildPaletteOpen = "bleep13.aud";
|
||||
public readonly string BuildPaletteClose = "bleep13.aud";
|
||||
public readonly string BuildingSelectAudio = "abldgin1.aud";
|
||||
public readonly string BuildingReadyAudio = "conscmp1.aud";
|
||||
public readonly string BuildingCannotPlaceAudio = "nodeply1.aud";
|
||||
public readonly string UnitSelectAudio = "train1.aud";
|
||||
public readonly string UnitReadyAudio = "unitrdy1.aud";
|
||||
public readonly string OnHoldAudio = "onhold1.aud";
|
||||
public readonly string CancelledAudio = "cancld1.aud";
|
||||
public readonly string ClickAudio = "ramenu1.aud";
|
||||
|
||||
|
||||
// For manual powerup/down in ra-ng
|
||||
public readonly string DisablePower = "bleep11.aud";
|
||||
public readonly string EnablePower = "bleep12.aud";
|
||||
|
||||
// Eva speech
|
||||
public readonly string LowPower = "lopower1.aud";
|
||||
public readonly string SilosNeeded = "silond1.aud";
|
||||
public readonly string UnitLost = "unitlst1.aud";
|
||||
public readonly string NavalUnitLost = "navylst1.aud";
|
||||
public readonly string PrimaryBuildingSelected = "pribldg1.aud";
|
||||
public readonly string CreditsStolen = "credit1.aud";
|
||||
}
|
||||
|
||||
class EvaAlerts {}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class EvaAlertsInfo : StatelessTraitInfo<EvaAlerts>
|
||||
{
|
||||
// Sound effects
|
||||
public readonly string TabClick = "ramenu1.aud";
|
||||
|
||||
public readonly string ChatBeep = "rabeep1.aud";
|
||||
public readonly string RadarUp = "radaron2.aud";
|
||||
public readonly string RadarDown = "radardn1.aud";
|
||||
|
||||
public readonly string CashTickUp = "cashup1.aud";
|
||||
public readonly string CashTickDown = "cashdn1.aud";
|
||||
|
||||
// Build Palette
|
||||
public readonly string BuildPaletteOpen = "bleep13.aud";
|
||||
public readonly string BuildPaletteClose = "bleep13.aud";
|
||||
public readonly string BuildingSelectAudio = "abldgin1.aud";
|
||||
public readonly string BuildingReadyAudio = "conscmp1.aud";
|
||||
public readonly string BuildingCannotPlaceAudio = "nodeply1.aud";
|
||||
public readonly string UnitSelectAudio = "train1.aud";
|
||||
public readonly string UnitReadyAudio = "unitrdy1.aud";
|
||||
public readonly string OnHoldAudio = "onhold1.aud";
|
||||
public readonly string CancelledAudio = "cancld1.aud";
|
||||
public readonly string ClickAudio = "ramenu1.aud";
|
||||
|
||||
|
||||
// For manual powerup/down in ra-ng
|
||||
public readonly string DisablePower = "bleep11.aud";
|
||||
public readonly string EnablePower = "bleep12.aud";
|
||||
|
||||
// Eva speech
|
||||
public readonly string LowPower = "lopower1.aud";
|
||||
public readonly string SilosNeeded = "silond1.aud";
|
||||
public readonly string UnitLost = "unitlst1.aud";
|
||||
public readonly string NavalUnitLost = "navylst1.aud";
|
||||
public readonly string PrimaryBuildingSelected = "pribldg1.aud";
|
||||
public readonly string CreditsStolen = "credit1.aud";
|
||||
}
|
||||
|
||||
class EvaAlerts {}
|
||||
}
|
||||
|
||||
@@ -1,103 +1,103 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class RenderBuildingWallInfo : RenderBuildingInfo
|
||||
{
|
||||
public readonly int DamageStates = 2;
|
||||
public override object Create(Actor self) { return new RenderBuildingWall(self); }
|
||||
}
|
||||
|
||||
class RenderBuildingWall : RenderBuilding
|
||||
{
|
||||
string seqName;
|
||||
int damageStates;
|
||||
Actor self;
|
||||
|
||||
public RenderBuildingWall(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
seqName = "idle";
|
||||
this.self = self;
|
||||
this.damageStates = self.Info.Traits.Get<RenderBuildingWallInfo>().DamageStates;
|
||||
}
|
||||
|
||||
public override void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!e.DamageStateChanged) return;
|
||||
|
||||
switch (e.DamageState)
|
||||
{
|
||||
case DamageState.Normal:
|
||||
seqName = "idle";
|
||||
break;
|
||||
case DamageState.ThreeQuarter:
|
||||
if (damageStates >= 4)
|
||||
seqName = "minor-damaged-idle";
|
||||
break;
|
||||
case DamageState.Half:
|
||||
seqName = "damaged-idle";
|
||||
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound);
|
||||
break;
|
||||
case DamageState.Quarter:
|
||||
if (damageStates >= 3)
|
||||
{
|
||||
seqName = "critical-idle";
|
||||
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
|
||||
// TODO: This only needs updating when a wall is built or destroyed
|
||||
int index = NearbyWalls( self.Location );
|
||||
|
||||
anim.PlayFetchIndex(seqName, () => index);
|
||||
|
||||
}
|
||||
bool IsWall( int x, int y)
|
||||
{
|
||||
return self.World.Queries.WithTrait<Wall>().Any(a => (a.Actor.Info.Name == self.Info.Name && a.Actor.Location.X == x && a.Actor.Location.Y == y));
|
||||
}
|
||||
|
||||
int NearbyWalls( int2 xy )
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if( IsWall( xy.X, xy.Y - 1 ) )
|
||||
ret |= 1;
|
||||
if( IsWall( xy.X + 1, xy.Y ) )
|
||||
ret |= 2;
|
||||
if( IsWall( xy.X, xy.Y + 1 ) )
|
||||
ret |= 4;
|
||||
if( IsWall( xy.X - 1, xy.Y ) )
|
||||
ret |= 8;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class RenderBuildingWallInfo : RenderBuildingInfo
|
||||
{
|
||||
public readonly int DamageStates = 2;
|
||||
public override object Create(Actor self) { return new RenderBuildingWall(self); }
|
||||
}
|
||||
|
||||
class RenderBuildingWall : RenderBuilding
|
||||
{
|
||||
string seqName;
|
||||
int damageStates;
|
||||
Actor self;
|
||||
|
||||
public RenderBuildingWall(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
seqName = "idle";
|
||||
this.self = self;
|
||||
this.damageStates = self.Info.Traits.Get<RenderBuildingWallInfo>().DamageStates;
|
||||
}
|
||||
|
||||
public override void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!e.DamageStateChanged) return;
|
||||
|
||||
switch (e.DamageState)
|
||||
{
|
||||
case DamageState.Normal:
|
||||
seqName = "idle";
|
||||
break;
|
||||
case DamageState.ThreeQuarter:
|
||||
if (damageStates >= 4)
|
||||
seqName = "minor-damaged-idle";
|
||||
break;
|
||||
case DamageState.Half:
|
||||
seqName = "damaged-idle";
|
||||
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound);
|
||||
break;
|
||||
case DamageState.Quarter:
|
||||
if (damageStates >= 3)
|
||||
{
|
||||
seqName = "critical-idle";
|
||||
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
|
||||
// TODO: This only needs updating when a wall is built or destroyed
|
||||
int index = NearbyWalls( self.Location );
|
||||
|
||||
anim.PlayFetchIndex(seqName, () => index);
|
||||
|
||||
}
|
||||
bool IsWall( int x, int y)
|
||||
{
|
||||
return self.World.Queries.WithTrait<Wall>().Any(a => (a.Actor.Info.Name == self.Info.Name && a.Actor.Location.X == x && a.Actor.Location.Y == y));
|
||||
}
|
||||
|
||||
int NearbyWalls( int2 xy )
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if( IsWall( xy.X, xy.Y - 1 ) )
|
||||
ret |= 1;
|
||||
if( IsWall( xy.X + 1, xy.Y ) )
|
||||
ret |= 2;
|
||||
if( IsWall( xy.X, xy.Y + 1 ) )
|
||||
ret |= 4;
|
||||
if( IsWall( xy.X - 1, xy.Y ) )
|
||||
ret |= 8;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (isOpen && !self.World.WorldActor.traits.Get<UnitInfluence>()
|
||||
if (isOpen && !self.World.WorldActor.traits.Get<UnitInfluence>()
|
||||
.GetUnitsAt(((1f/Game.CellSize) * self.CenterLocation).ToInt2()).Any())
|
||||
{
|
||||
isOpen = false;
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class WallInfo : StatelessTraitInfo<Wall> {}
|
||||
public class Wall {}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class WallInfo : StatelessTraitInfo<Wall> {}
|
||||
public class Wall {}
|
||||
}
|
||||
|
||||
@@ -21,52 +21,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ScreenShakerInfo : ITraitInfo
|
||||
{
|
||||
public object Create( Actor self ) { return new ScreenShaker(); }
|
||||
}
|
||||
|
||||
public class ScreenShaker : ITick
|
||||
{
|
||||
int ticks = 0;
|
||||
List<Tuple<int, float2, int>> shakeEffects = new List<Tuple<int, float2, int>>();
|
||||
|
||||
public void Tick (Actor self)
|
||||
{
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ScreenShakerInfo : ITraitInfo
|
||||
{
|
||||
public object Create( Actor self ) { return new ScreenShaker(); }
|
||||
}
|
||||
|
||||
public class ScreenShaker : ITick
|
||||
{
|
||||
int ticks = 0;
|
||||
List<Tuple<int, float2, int>> shakeEffects = new List<Tuple<int, float2, int>>();
|
||||
|
||||
public void Tick (Actor self)
|
||||
{
|
||||
Game.viewport.Scroll(getScrollOffset());
|
||||
shakeEffects.RemoveAll(t => t.a == ticks);
|
||||
ticks++;
|
||||
}
|
||||
|
||||
public void AddEffect(int time, float2 position, int intensity)
|
||||
{
|
||||
shakeEffects.Add(Tuple.New(ticks + time, position, intensity));
|
||||
}
|
||||
|
||||
public float2 getScrollOffset()
|
||||
{
|
||||
int xFreq = 4;
|
||||
int yFreq = 5;
|
||||
|
||||
return GetIntensity() * new float2(
|
||||
(float) Math.Sin((ticks*2*Math.PI)/xFreq) ,
|
||||
(float) Math.Cos((ticks*2*Math.PI)/yFreq));
|
||||
}
|
||||
|
||||
public float GetIntensity()
|
||||
shakeEffects.RemoveAll(t => t.a == ticks);
|
||||
ticks++;
|
||||
}
|
||||
|
||||
public void AddEffect(int time, float2 position, int intensity)
|
||||
{
|
||||
shakeEffects.Add(Tuple.New(ticks + time, position, intensity));
|
||||
}
|
||||
|
||||
public float2 getScrollOffset()
|
||||
{
|
||||
int xFreq = 4;
|
||||
int yFreq = 5;
|
||||
|
||||
return GetIntensity() * new float2(
|
||||
(float) Math.Sin((ticks*2*Math.PI)/xFreq) ,
|
||||
(float) Math.Cos((ticks*2*Math.PI)/yFreq));
|
||||
}
|
||||
|
||||
public float GetIntensity()
|
||||
{
|
||||
var cp = Game.viewport.Location
|
||||
+ .5f * new float2(Game.viewport.Width, Game.viewport.Height);
|
||||
|
||||
var intensity = 24 * 24 * 100 * shakeEffects.Sum(
|
||||
e => e.c / (e.b - cp).LengthSquared);
|
||||
|
||||
return Math.Min(intensity, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
var intensity = 24 * 24 * 100 * shakeEffects.Sum(
|
||||
e => e.c / (e.b - cp).LengthSquared);
|
||||
|
||||
return Math.Min(intensity, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class TheaterInfo : StatelessTraitInfo<Theater>
|
||||
{
|
||||
public readonly string Name = null;
|
||||
public readonly string Theater = null;
|
||||
public readonly string Suffix = null;
|
||||
public readonly string Tileset = null;
|
||||
public readonly string Templates = null;
|
||||
public readonly string MapColors = null;
|
||||
}
|
||||
class Theater {}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class TheaterInfo : StatelessTraitInfo<Theater>
|
||||
{
|
||||
public readonly string Name = null;
|
||||
public readonly string Theater = null;
|
||||
public readonly string Suffix = null;
|
||||
public readonly string Tileset = null;
|
||||
public readonly string Templates = null;
|
||||
public readonly string MapColors = null;
|
||||
}
|
||||
class Theater {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user