changes facing (and desireFacing) on Mobile and on Turreted. range is now 0..255
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.FileFormats;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.TechTree;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using IrrKlang;
|
||||
using OpenRa.FileFormats;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.TechTree;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using IrrKlang;
|
||||
using IjwFramework.Collections;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
class Game
|
||||
{
|
||||
{
|
||||
public static readonly int CellSize = 24;
|
||||
|
||||
public readonly World world;
|
||||
public readonly Map map;
|
||||
public readonly Map map;
|
||||
readonly TreeCache treeCache;
|
||||
public readonly TerrainRenderer terrain;
|
||||
public readonly Viewport viewport;
|
||||
@@ -27,9 +27,9 @@ namespace OpenRa.Game
|
||||
|
||||
public readonly Dictionary<int, Player> players = new Dictionary<int, Player>();
|
||||
|
||||
public Player LocalPlayer { get { return players[localPlayerIndex]; } }
|
||||
public BuildingInfluenceMap LocalPlayerBuildings;
|
||||
|
||||
public Player LocalPlayer { get { return players[localPlayerIndex]; } }
|
||||
public BuildingInfluenceMap LocalPlayerBuildings;
|
||||
|
||||
ISoundEngine soundEngine;
|
||||
|
||||
public Game(string mapName, Renderer renderer, int2 clientSize)
|
||||
@@ -49,8 +49,8 @@ namespace OpenRa.Game
|
||||
treeCache = new TreeCache(map);
|
||||
|
||||
foreach( TreeReference treeReference in map.Trees )
|
||||
world.Add( new Actor( treeReference, treeCache, map.Offset ) );
|
||||
|
||||
world.Add( new Actor( treeReference, treeCache, map.Offset ) );
|
||||
|
||||
LocalPlayerBuildings = new BuildingInfluenceMap(world, LocalPlayer);
|
||||
|
||||
pathFinder = new PathFinder(map, terrain.tileSet, LocalPlayerBuildings);
|
||||
@@ -58,34 +58,34 @@ namespace OpenRa.Game
|
||||
network = new Network();
|
||||
|
||||
controller = new Controller(this); // CAREFUL THERES AN UGLY HIDDEN DEPENDENCY HERE STILL
|
||||
worldRenderer = new WorldRenderer(renderer, this);
|
||||
|
||||
soundEngine = new ISoundEngine();
|
||||
sounds = new Cache<string, ISoundSource>(LoadSound);
|
||||
|
||||
worldRenderer = new WorldRenderer(renderer, this);
|
||||
|
||||
soundEngine = new ISoundEngine();
|
||||
sounds = new Cache<string, ISoundSource>(LoadSound);
|
||||
|
||||
PlaySound("intro.aud", false);
|
||||
}
|
||||
|
||||
readonly Cache<string, ISoundSource> sounds;
|
||||
|
||||
ISoundSource LoadSound(string filename)
|
||||
{
|
||||
var data = AudLoader.LoadSound(FileSystem.Open(filename));
|
||||
return soundEngine.AddSoundSourceFromPCMData(data, filename,
|
||||
new AudioFormat()
|
||||
{
|
||||
ChannelCount = 1,
|
||||
FrameCount = data.Length / 2,
|
||||
Format = SampleFormat.Signed16Bit,
|
||||
SampleRate = 22050
|
||||
});
|
||||
}
|
||||
|
||||
public void PlaySound(string name, bool loop)
|
||||
{
|
||||
var sound = sounds[name];
|
||||
// todo: positioning
|
||||
soundEngine.Play2D(sound, loop, false, false);
|
||||
}
|
||||
|
||||
readonly Cache<string, ISoundSource> sounds;
|
||||
|
||||
ISoundSource LoadSound(string filename)
|
||||
{
|
||||
var data = AudLoader.LoadSound(FileSystem.Open(filename));
|
||||
return soundEngine.AddSoundSourceFromPCMData(data, filename,
|
||||
new AudioFormat()
|
||||
{
|
||||
ChannelCount = 1,
|
||||
FrameCount = data.Length / 2,
|
||||
Format = SampleFormat.Signed16Bit,
|
||||
SampleRate = 22050
|
||||
});
|
||||
}
|
||||
|
||||
public void PlaySound(string name, bool loop)
|
||||
{
|
||||
var sound = sounds[name];
|
||||
// todo: positioning
|
||||
soundEngine.Play2D(sound, loop, false, false);
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
@@ -94,28 +94,28 @@ namespace OpenRa.Game
|
||||
world.Update();
|
||||
|
||||
viewport.DrawRegions();
|
||||
}
|
||||
|
||||
public bool IsCellBuildable(int2 a)
|
||||
{
|
||||
if (LocalPlayerBuildings[a] != null) return false;
|
||||
|
||||
a += map.Offset;
|
||||
|
||||
return map.IsInMap(a.X, a.Y) &&
|
||||
TerrainCosts.Cost(UnitMovementType.Wheel,
|
||||
terrain.tileSet.GetWalkability(map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
||||
}
|
||||
|
||||
public IEnumerable<Actor> FindUnits(float2 a, float2 b)
|
||||
{
|
||||
var min = float2.Min(a, b);
|
||||
var max = float2.Max(a, b);
|
||||
|
||||
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
||||
|
||||
return world.Actors
|
||||
.Where(x => (x.Owner == LocalPlayer) && (x.Bounds.IntersectsWith(rect)));
|
||||
}
|
||||
|
||||
public bool IsCellBuildable(int2 a)
|
||||
{
|
||||
if (LocalPlayerBuildings[a] != null) return false;
|
||||
|
||||
a += map.Offset;
|
||||
|
||||
return map.IsInMap(a.X, a.Y) &&
|
||||
TerrainCosts.Cost(UnitMovementType.Wheel,
|
||||
terrain.tileSet.GetWalkability(map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
||||
}
|
||||
|
||||
public IEnumerable<Actor> FindUnits(float2 a, float2 b)
|
||||
{
|
||||
var min = float2.Min(a, b);
|
||||
var max = float2.Max(a, b);
|
||||
|
||||
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
||||
|
||||
return world.Actors
|
||||
.Where(x => (x.Owner == LocalPlayer) && (x.Bounds.IntersectsWith(rect)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user