Only sync projectiles and future synced effects.
This commit is contained in:
@@ -31,7 +31,8 @@ namespace OpenRA.GameRules
|
|||||||
public Target GuidedTarget;
|
public Target GuidedTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IProjectileInfo { IEffect Create(ProjectileArgs args); }
|
public interface IProjectile : IEffect { }
|
||||||
|
public interface IProjectileInfo { IProjectile Create(ProjectileArgs args); }
|
||||||
|
|
||||||
public sealed class WeaponInfo
|
public sealed class WeaponInfo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,20 +77,16 @@ namespace OpenRA.Network
|
|||||||
NamesValues = DumpSyncTrait(syncHash.Trait)
|
NamesValues = DumpSyncTrait(syncHash.Trait)
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var e in orderManager.World.Effects)
|
foreach (var sync in orderManager.World.SyncedEffects)
|
||||||
{
|
{
|
||||||
var sync = e as ISync;
|
var hash = Sync.Hash(sync);
|
||||||
if (sync != null)
|
if (hash != 0)
|
||||||
{
|
report.Effects.Add(new EffectReport()
|
||||||
var hash = Sync.Hash(sync);
|
{
|
||||||
if (hash != 0)
|
Name = sync.GetType().Name,
|
||||||
report.Effects.Add(new EffectReport()
|
Hash = hash,
|
||||||
{
|
NamesValues = DumpSyncTrait(sync)
|
||||||
Name = sync.GetType().Name,
|
});
|
||||||
Hash = hash,
|
|
||||||
NamesValues = DumpSyncTrait(sync)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Effects;
|
using OpenRA.Effects;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Orders;
|
using OpenRA.Orders;
|
||||||
@@ -30,6 +31,8 @@ namespace OpenRA
|
|||||||
internal readonly TraitDictionary TraitDict = new TraitDictionary();
|
internal readonly TraitDictionary TraitDict = new TraitDictionary();
|
||||||
readonly SortedDictionary<uint, Actor> actors = new SortedDictionary<uint, Actor>();
|
readonly SortedDictionary<uint, Actor> actors = new SortedDictionary<uint, Actor>();
|
||||||
readonly List<IEffect> effects = new List<IEffect>();
|
readonly List<IEffect> effects = new List<IEffect>();
|
||||||
|
readonly List<ISync> syncedEffects = new List<ISync>();
|
||||||
|
|
||||||
readonly Queue<Action<World>> frameEndActions = new Queue<Action<World>>();
|
readonly Queue<Action<World>> frameEndActions = new Queue<Action<World>>();
|
||||||
|
|
||||||
public int Timestep;
|
public int Timestep;
|
||||||
@@ -272,9 +275,27 @@ namespace OpenRA
|
|||||||
t.RemovedFromWorld(a);
|
t.RemovedFromWorld(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(IEffect b) { effects.Add(b); }
|
public void Add(IEffect e)
|
||||||
public void Remove(IEffect b) { effects.Remove(b); }
|
{
|
||||||
public void RemoveAll(Predicate<IEffect> predicate) { effects.RemoveAll(predicate); }
|
effects.Add(e);
|
||||||
|
var se = e as ISync;
|
||||||
|
if (se != null)
|
||||||
|
syncedEffects.Add(se);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(IEffect e)
|
||||||
|
{
|
||||||
|
effects.Remove(e);
|
||||||
|
var se = e as ISync;
|
||||||
|
if (se != null)
|
||||||
|
syncedEffects.Remove(se);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAll(Predicate<IEffect> predicate)
|
||||||
|
{
|
||||||
|
effects.RemoveAll(predicate);
|
||||||
|
syncedEffects.RemoveAll(e => predicate((IEffect)e));
|
||||||
|
}
|
||||||
|
|
||||||
public void AddFrameEndTask(Action<World> a) { frameEndActions.Enqueue(a); }
|
public void AddFrameEndTask(Action<World> a) { frameEndActions.Enqueue(a); }
|
||||||
|
|
||||||
@@ -334,6 +355,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public IEnumerable<Actor> Actors { get { return actors.Values; } }
|
public IEnumerable<Actor> Actors { get { return actors.Values; } }
|
||||||
public IEnumerable<IEffect> Effects { get { return effects; } }
|
public IEnumerable<IEffect> Effects { get { return effects; } }
|
||||||
|
public IEnumerable<ISync> SyncedEffects { get { return syncedEffects; } }
|
||||||
|
|
||||||
public Actor GetActorById(uint actorId)
|
public Actor GetActorById(uint actorId)
|
||||||
{
|
{
|
||||||
@@ -356,24 +378,20 @@ namespace OpenRA
|
|||||||
var n = 0;
|
var n = 0;
|
||||||
var ret = 0;
|
var ret = 0;
|
||||||
|
|
||||||
// hash all the actors
|
// Hash all the actors.
|
||||||
foreach (var a in Actors)
|
foreach (var a in Actors)
|
||||||
ret += n++ * (int)(1 + a.ActorID) * Sync.HashActor(a);
|
ret += n++ * (int)(1 + a.ActorID) * Sync.HashActor(a);
|
||||||
|
|
||||||
// hash all the traits that tick
|
// Hash all the traits that tick.
|
||||||
foreach (var actor in ActorsHavingTrait<ISync>())
|
foreach (var actor in ActorsHavingTrait<ISync>())
|
||||||
foreach (var syncHash in actor.SyncHashes)
|
foreach (var syncHash in actor.SyncHashes)
|
||||||
ret += n++ * (int)(1 + actor.ActorID) * syncHash.Hash;
|
ret += n++ * (int)(1 + actor.ActorID) * syncHash.Hash;
|
||||||
|
|
||||||
// TODO: don't go over all effects
|
// Hash game state relevant effects such as projectiles.
|
||||||
foreach (var e in Effects)
|
foreach (var sync in SyncedEffects)
|
||||||
{
|
ret += n++ * Sync.Hash(sync);
|
||||||
var sync = e as ISync;
|
|
||||||
if (sync != null)
|
|
||||||
ret += n++ * Sync.Hash(sync);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hash the shared rng
|
// Hash the shared random number generator.
|
||||||
ret += SharedRandom.Last;
|
ret += SharedRandom.Last;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Effects
|
namespace OpenRA.Mods.Cnc.Effects
|
||||||
{
|
{
|
||||||
public class IonCannon : IEffect
|
public class IonCannon : IProjectile
|
||||||
{
|
{
|
||||||
readonly Target target;
|
readonly Target target;
|
||||||
readonly Animation anim;
|
readonly Animation anim;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Effects
|
namespace OpenRA.Mods.Common.Effects
|
||||||
{
|
{
|
||||||
public class NukeLaunch : IEffect
|
public class NukeLaunch : IProjectile
|
||||||
{
|
{
|
||||||
readonly Player firedBy;
|
readonly Player firedBy;
|
||||||
readonly Animation anim;
|
readonly Animation anim;
|
||||||
|
|||||||
@@ -69,14 +69,14 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
[Desc("Beam color is the player's color.")]
|
[Desc("Beam color is the player's color.")]
|
||||||
public readonly bool UsePlayerColor = false;
|
public readonly bool UsePlayerColor = false;
|
||||||
|
|
||||||
public IEffect Create(ProjectileArgs args)
|
public IProjectile Create(ProjectileArgs args)
|
||||||
{
|
{
|
||||||
var c = UsePlayerColor ? args.SourceActor.Owner.Color.RGB : Color;
|
var c = UsePlayerColor ? args.SourceActor.Owner.Color.RGB : Color;
|
||||||
return new AreaBeam(this, args, c);
|
return new AreaBeam(this, args, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AreaBeam : IEffect, ISync
|
public class AreaBeam : IProjectile, ISync
|
||||||
{
|
{
|
||||||
readonly AreaBeamInfo info;
|
readonly AreaBeamInfo info;
|
||||||
readonly ProjectileArgs args;
|
readonly ProjectileArgs args;
|
||||||
|
|||||||
@@ -82,10 +82,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
public readonly int ContrailDelay = 1;
|
public readonly int ContrailDelay = 1;
|
||||||
public readonly WDist ContrailWidth = new WDist(64);
|
public readonly WDist ContrailWidth = new WDist(64);
|
||||||
|
|
||||||
public IEffect Create(ProjectileArgs args) { return new Bullet(this, args); }
|
public IProjectile Create(ProjectileArgs args) { return new Bullet(this, args); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Bullet : IEffect, ISync
|
public class Bullet : IProjectile, ISync
|
||||||
{
|
{
|
||||||
readonly BulletInfo info;
|
readonly BulletInfo info;
|
||||||
readonly ProjectileArgs args;
|
readonly ProjectileArgs args;
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
[Desc("Value added to speed every tick.")]
|
[Desc("Value added to speed every tick.")]
|
||||||
public readonly WDist Acceleration = new WDist(15);
|
public readonly WDist Acceleration = new WDist(15);
|
||||||
|
|
||||||
public IEffect Create(ProjectileArgs args) { return new GravityBomb(this, args); }
|
public IProjectile Create(ProjectileArgs args) { return new GravityBomb(this, args); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GravityBomb : IEffect, ISync
|
public class GravityBomb : IProjectile, ISync
|
||||||
{
|
{
|
||||||
readonly GravityBombInfo info;
|
readonly GravityBombInfo info;
|
||||||
readonly Animation anim;
|
readonly Animation anim;
|
||||||
|
|||||||
@@ -47,14 +47,14 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
|
|
||||||
[PaletteReference] public readonly string HitAnimPalette = "effect";
|
[PaletteReference] public readonly string HitAnimPalette = "effect";
|
||||||
|
|
||||||
public IEffect Create(ProjectileArgs args)
|
public IProjectile Create(ProjectileArgs args)
|
||||||
{
|
{
|
||||||
var c = UsePlayerColor ? args.SourceActor.Owner.Color.RGB : Color;
|
var c = UsePlayerColor ? args.SourceActor.Owner.Color.RGB : Color;
|
||||||
return new LaserZap(args, this, c);
|
return new LaserZap(args, this, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LaserZap : IEffect
|
public class LaserZap : IProjectile
|
||||||
{
|
{
|
||||||
readonly ProjectileArgs args;
|
readonly ProjectileArgs args;
|
||||||
readonly LaserZapInfo info;
|
readonly LaserZapInfo info;
|
||||||
|
|||||||
@@ -141,11 +141,11 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
"not trigger fast enough, causing the missile to fly past the target.")]
|
"not trigger fast enough, causing the missile to fly past the target.")]
|
||||||
public readonly WDist CloseEnough = new WDist(298);
|
public readonly WDist CloseEnough = new WDist(298);
|
||||||
|
|
||||||
public IEffect Create(ProjectileArgs args) { return new Missile(this, args); }
|
public IProjectile Create(ProjectileArgs args) { return new Missile(this, args); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: double check square roots!!!
|
// TODO: double check square roots!!!
|
||||||
public class Missile : IEffect, ISync
|
public class Missile : IProjectile, ISync
|
||||||
{
|
{
|
||||||
enum States
|
enum States
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ namespace OpenRA.Mods.RA.Projectiles
|
|||||||
|
|
||||||
public readonly int Duration = 2;
|
public readonly int Duration = 2;
|
||||||
|
|
||||||
public IEffect Create(ProjectileArgs args) { return new TeslaZap(this, args); }
|
public IProjectile Create(ProjectileArgs args) { return new TeslaZap(this, args); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TeslaZap : IEffect
|
public class TeslaZap : IProjectile
|
||||||
{
|
{
|
||||||
readonly ProjectileArgs args;
|
readonly ProjectileArgs args;
|
||||||
readonly TeslaZapInfo info;
|
readonly TeslaZapInfo info;
|
||||||
|
|||||||
Reference in New Issue
Block a user