mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Make all game components handle new map / new map loaded.
This commit is contained in:
parent
afe2d05de0
commit
1e3fad5930
@ -16,8 +16,9 @@ namespace ClassicalSharp.Gui {
|
|||||||
Font playerFont;
|
Font playerFont;
|
||||||
|
|
||||||
public void Init( Game game ) { Init(); }
|
public void Init( Game game ) { Init(); }
|
||||||
|
|
||||||
public void Reset( Game game ) { }
|
public void Reset( Game game ) { }
|
||||||
|
public void OnNewMap( Game game ) { }
|
||||||
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
public override void Render( double delta ) {
|
public override void Render( double delta ) {
|
||||||
if( game.HideGui ) return;
|
if( game.HideGui ) return;
|
||||||
|
@ -27,6 +27,8 @@ namespace ClassicalSharp.Audio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Reset( Game game ) { }
|
public void Reset( Game game ) { }
|
||||||
|
public void OnNewMap( Game game ) { }
|
||||||
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
public void SetMusic( bool enabled ) {
|
public void SetMusic( bool enabled ) {
|
||||||
if( enabled )
|
if( enabled )
|
||||||
|
@ -26,6 +26,8 @@ namespace ClassicalSharp.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Reset( Game game ) { }
|
public void Reset( Game game ) { }
|
||||||
|
public void OnNewMap( Game game ) { }
|
||||||
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
public void Register( Command command ) {
|
public void Register( Command command ) {
|
||||||
command.game = game;
|
command.game = game;
|
||||||
|
@ -141,14 +141,10 @@ namespace ClassicalSharp.Commands {
|
|||||||
void SetNewRenderType( bool legacy, bool minimal ) {
|
void SetNewRenderType( bool legacy, bool minimal ) {
|
||||||
game.MapBordersRenderer.UseLegacyMode( legacy );
|
game.MapBordersRenderer.UseLegacyMode( legacy );
|
||||||
if( minimal ) {
|
if( minimal ) {
|
||||||
game.EnvRenderer.Dispose();
|
game.ReplaceComponent( ref game.EnvRenderer, new MinimalEnvRenderer() );
|
||||||
game.EnvRenderer = new MinimalEnvRenderer( game );
|
|
||||||
game.EnvRenderer.Init();
|
|
||||||
} else {
|
} else {
|
||||||
if( !( game.EnvRenderer is StandardEnvRenderer ) ) {
|
if( !(game.EnvRenderer is StandardEnvRenderer) ) {
|
||||||
game.EnvRenderer.Dispose();
|
game.ReplaceComponent( ref game.EnvRenderer, new StandardEnvRenderer() );
|
||||||
game.EnvRenderer = new StandardEnvRenderer( game );
|
|
||||||
game.EnvRenderer.Init();
|
|
||||||
}
|
}
|
||||||
((StandardEnvRenderer)game.EnvRenderer).UseLegacyMode( legacy );
|
((StandardEnvRenderer)game.EnvRenderer).UseLegacyMode( legacy );
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Reset( Game game ) { }
|
public void Reset( Game game ) { }
|
||||||
|
public void OnNewMap( Game game ) { }
|
||||||
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
/// <summary> List of chat messages received from the server and added by client commands. </summary>
|
/// <summary> List of chat messages received from the server and added by client commands. </summary>
|
||||||
/// <remarks> index 0 is the oldest chat message, last index is newest. </remarks>
|
/// <remarks> index 0 is the oldest chat message, last index is newest. </remarks>
|
||||||
|
@ -28,8 +28,14 @@ namespace ClassicalSharp {
|
|||||||
/// <summary> Called when the game has loaded. </summary>
|
/// <summary> Called when the game has loaded. </summary>
|
||||||
void Init( Game game );
|
void Init( Game game );
|
||||||
|
|
||||||
/// <summary> Called to reset the state when the user is reconnecting to a server. </summary>
|
/// <summary> Called to reset the component's state when the user is reconnecting to a server. </summary>
|
||||||
void Reset( Game game );
|
void Reset( Game game );
|
||||||
|
|
||||||
|
/// <summary> Called to update the component's state when the user begins loading a new map. </summary>
|
||||||
|
void OnNewMap( Game game );
|
||||||
|
|
||||||
|
/// <summary> Called to update the component's state when the user has finished loading a new map. </summary>
|
||||||
|
void OnNewMapLoaded( Game game );
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class Game {
|
public partial class Game {
|
||||||
|
@ -62,6 +62,8 @@ namespace ClassicalSharp {
|
|||||||
LoadOptions();
|
LoadOptions();
|
||||||
LoadGuiOptions();
|
LoadGuiOptions();
|
||||||
Chat = AddComponent( new Chat() );
|
Chat = AddComponent( new Chat() );
|
||||||
|
WorldEvents.OnNewMap += OnNewMapCore;
|
||||||
|
WorldEvents.OnNewMapLoaded += OnNewMapLoadedCore;
|
||||||
|
|
||||||
BlockInfo = new BlockInfo();
|
BlockInfo = new BlockInfo();
|
||||||
BlockInfo.Init();
|
BlockInfo.Init();
|
||||||
@ -89,8 +91,8 @@ namespace ClassicalSharp {
|
|||||||
width = Width;
|
width = Width;
|
||||||
height = Height;
|
height = Height;
|
||||||
MapRenderer = new MapRenderer( this );
|
MapRenderer = new MapRenderer( this );
|
||||||
MapBordersRenderer = new MapBordersRenderer( this );
|
MapBordersRenderer = AddComponent( new MapBordersRenderer() );
|
||||||
EnvRenderer = new StandardEnvRenderer( this );
|
EnvRenderer = AddComponent( new StandardEnvRenderer() );
|
||||||
if( IPAddress == null ) {
|
if( IPAddress == null ) {
|
||||||
Network = new Singleplayer.SinglePlayerServer( this );
|
Network = new Singleplayer.SinglePlayerServer( this );
|
||||||
} else {
|
} else {
|
||||||
@ -117,8 +119,6 @@ namespace ClassicalSharp {
|
|||||||
fpsScreen.Init();
|
fpsScreen.Init();
|
||||||
hudScreen = AddComponent( new HudScreen( this ) );
|
hudScreen = AddComponent( new HudScreen( this ) );
|
||||||
Culling = new FrustumCulling();
|
Culling = new FrustumCulling();
|
||||||
EnvRenderer.Init();
|
|
||||||
MapBordersRenderer.Init();
|
|
||||||
Picking = AddComponent( new PickedPosRenderer() );
|
Picking = AddComponent( new PickedPosRenderer() );
|
||||||
AudioPlayer = AddComponent( new AudioPlayer() );
|
AudioPlayer = AddComponent( new AudioPlayer() );
|
||||||
AxisLinesRenderer = AddComponent( new AxisLinesRenderer() );
|
AxisLinesRenderer = AddComponent( new AxisLinesRenderer() );
|
||||||
@ -136,11 +136,6 @@ namespace ClassicalSharp {
|
|||||||
Network.Connect( IPAddress, Port );
|
Network.Connect( IPAddress, Port );
|
||||||
}
|
}
|
||||||
|
|
||||||
public T AddComponent<T>( T obj ) {
|
|
||||||
Components.Add( (IGameComponent)obj );
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadOptions() {
|
void LoadOptions() {
|
||||||
ClassicMode = Options.GetBool( "mode-classic", false );
|
ClassicMode = Options.GetBool( "mode-classic", false );
|
||||||
ClassicHacks = Options.GetBool( OptionsKey.AllowClassicHacks, false );
|
ClassicHacks = Options.GetBool( OptionsKey.AllowClassicHacks, false );
|
||||||
@ -200,6 +195,37 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnNewMapCore( object sender, EventArgs e ) {
|
||||||
|
foreach( IGameComponent comp in Components )
|
||||||
|
comp.OnNewMap( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnNewMapLoadedCore( object sender, EventArgs e ) {
|
||||||
|
foreach( IGameComponent comp in Components )
|
||||||
|
comp.OnNewMapLoaded( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public T AddComponent<T>( T obj ) where T : IGameComponent {
|
||||||
|
Components.Add( obj );
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ReplaceComponent<T>( ref T old, T obj ) where T : IGameComponent {
|
||||||
|
for( int i = 0; i < Components.Count; i++ ) {
|
||||||
|
if( !object.ReferenceEquals( Components[i], old ) ) continue;
|
||||||
|
old.Dispose();
|
||||||
|
|
||||||
|
Components[i] = obj;
|
||||||
|
old = obj;
|
||||||
|
obj.Init( this );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Components.Add( obj );
|
||||||
|
obj.Init( this );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetViewDistance( int distance, bool save ) {
|
public void SetViewDistance( int distance, bool save ) {
|
||||||
ViewDistance = distance;
|
ViewDistance = distance;
|
||||||
if( ViewDistance > MaxViewDistance )
|
if( ViewDistance > MaxViewDistance )
|
||||||
@ -485,6 +511,8 @@ namespace ClassicalSharp {
|
|||||||
ModelCache.Dispose();
|
ModelCache.Dispose();
|
||||||
ParticleManager.Dispose();
|
ParticleManager.Dispose();
|
||||||
Players.Dispose();
|
Players.Dispose();
|
||||||
|
WorldEvents.OnNewMap -= OnNewMapCore;
|
||||||
|
WorldEvents.OnNewMapLoaded -= OnNewMapLoadedCore;
|
||||||
|
|
||||||
foreach( IGameComponent comp in Components )
|
foreach( IGameComponent comp in Components )
|
||||||
comp.Dispose();
|
comp.Dispose();
|
||||||
|
@ -23,6 +23,8 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Reset( Game game ) { }
|
public void Reset( Game game ) { }
|
||||||
|
public void OnNewMap( Game game ) { }
|
||||||
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Dispose() { }
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ namespace ClassicalSharp.Network {
|
|||||||
requests.Clear();
|
requests.Clear();
|
||||||
handle.Set();
|
handle.Set();
|
||||||
}
|
}
|
||||||
|
public void OnNewMap( Game game ) { }
|
||||||
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
/// <summary> Asynchronously downloads a skin. If 'skinName' points to the url then the skin is
|
/// <summary> Asynchronously downloads a skin. If 'skinName' points to the url then the skin is
|
||||||
/// downloaded from that url, otherwise it is downloaded from the url 'defaultSkinServer'/'skinName'.png </summary>
|
/// downloaded from that url, otherwise it is downloaded from the url 'defaultSkinServer'/'skinName'.png </summary>
|
||||||
|
@ -31,6 +31,8 @@ namespace ClassicalSharp.Renderers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Reset( Game game ) { }
|
public void Reset( Game game ) { }
|
||||||
|
public void OnNewMap( Game game ) { }
|
||||||
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
public void Render( double delta, float t ) {
|
public void Render( double delta, float t ) {
|
||||||
if( game.Camera.IsThirdPerson || !game.ShowBlockInHand ) return;
|
if( game.Camera.IsThirdPerson || !game.ShowBlockInHand ) return;
|
||||||
|
@ -6,28 +6,26 @@ using ClassicalSharp.Map;
|
|||||||
|
|
||||||
namespace ClassicalSharp.Renderers {
|
namespace ClassicalSharp.Renderers {
|
||||||
|
|
||||||
public abstract class EnvRenderer : IDisposable {
|
public abstract class EnvRenderer : IGameComponent {
|
||||||
|
|
||||||
protected World map;
|
protected World map;
|
||||||
protected Game game;
|
protected Game game;
|
||||||
protected IGraphicsApi graphics;
|
protected IGraphicsApi graphics;
|
||||||
|
|
||||||
public virtual void Init() {
|
public virtual void Init( Game game ) {
|
||||||
|
this.game = game;
|
||||||
|
map = game.World;
|
||||||
graphics = game.Graphics;
|
graphics = game.Graphics;
|
||||||
game.WorldEvents.OnNewMap += OnNewMap;
|
|
||||||
game.WorldEvents.OnNewMapLoaded += OnNewMapLoaded;
|
|
||||||
game.WorldEvents.EnvVariableChanged += EnvVariableChanged;
|
game.WorldEvents.EnvVariableChanged += EnvVariableChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnNewMap( object sender, EventArgs e ) {
|
public virtual void Reset( Game game ) { OnNewMap( game ); }
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnNewMapLoaded( object sender, EventArgs e ) {
|
public abstract void OnNewMap( Game game );
|
||||||
}
|
|
||||||
|
public abstract void OnNewMapLoaded( Game game );
|
||||||
|
|
||||||
public virtual void Dispose() {
|
public virtual void Dispose() {
|
||||||
game.WorldEvents.OnNewMap -= OnNewMap;
|
|
||||||
game.WorldEvents.OnNewMapLoaded -= OnNewMapLoaded;
|
|
||||||
game.WorldEvents.EnvVariableChanged -= EnvVariableChanged;
|
game.WorldEvents.EnvVariableChanged -= EnvVariableChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,18 +9,12 @@ using OpenTK;
|
|||||||
|
|
||||||
namespace ClassicalSharp.Renderers {
|
namespace ClassicalSharp.Renderers {
|
||||||
|
|
||||||
public unsafe sealed class MapBordersRenderer : IDisposable {
|
public unsafe sealed class MapBordersRenderer : IGameComponent {
|
||||||
|
|
||||||
World map;
|
World map;
|
||||||
Game game;
|
Game game;
|
||||||
IGraphicsApi graphics;
|
IGraphicsApi graphics;
|
||||||
|
|
||||||
public MapBordersRenderer( Game game ) {
|
|
||||||
this.game = game;
|
|
||||||
map = game.World;
|
|
||||||
graphics = game.Graphics;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sidesVb = -1, edgesVb = -1;
|
int sidesVb = -1, edgesVb = -1;
|
||||||
int edgeTexId, sideTexId;
|
int edgeTexId, sideTexId;
|
||||||
int sidesVertices, edgesVertices;
|
int sidesVertices, edgesVertices;
|
||||||
@ -31,9 +25,11 @@ namespace ClassicalSharp.Renderers {
|
|||||||
ResetSidesAndEdges( null, null );
|
ResetSidesAndEdges( null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init() {
|
public void Init( Game game ) {
|
||||||
game.WorldEvents.OnNewMap += OnNewMap;
|
this.game = game;
|
||||||
game.WorldEvents.OnNewMapLoaded += OnNewMapLoaded;
|
map = game.World;
|
||||||
|
graphics = game.Graphics;
|
||||||
|
|
||||||
game.WorldEvents.EnvVariableChanged += EnvVariableChanged;
|
game.WorldEvents.EnvVariableChanged += EnvVariableChanged;
|
||||||
game.Events.ViewDistanceChanged += ResetSidesAndEdges;
|
game.Events.ViewDistanceChanged += ResetSidesAndEdges;
|
||||||
game.Events.TerrainAtlasChanged += ResetTextures;
|
game.Events.TerrainAtlasChanged += ResetTextures;
|
||||||
@ -74,8 +70,6 @@ namespace ClassicalSharp.Renderers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
game.WorldEvents.OnNewMap -= OnNewMap;
|
|
||||||
game.WorldEvents.OnNewMapLoaded -= OnNewMapLoaded;
|
|
||||||
game.WorldEvents.EnvVariableChanged -= EnvVariableChanged;
|
game.WorldEvents.EnvVariableChanged -= EnvVariableChanged;
|
||||||
game.Events.ViewDistanceChanged -= ResetSidesAndEdges;
|
game.Events.ViewDistanceChanged -= ResetSidesAndEdges;
|
||||||
game.Events.TerrainAtlasChanged -= ResetTextures;
|
game.Events.TerrainAtlasChanged -= ResetTextures;
|
||||||
@ -87,7 +81,9 @@ namespace ClassicalSharp.Renderers {
|
|||||||
sidesVb = edgesVb = -1;
|
sidesVb = edgesVb = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnNewMap( object sender, EventArgs e ) {
|
public void Reset( Game game ) { OnNewMap( game ); }
|
||||||
|
|
||||||
|
public void OnNewMap( Game game ) {
|
||||||
graphics.DeleteVb( sidesVb );
|
graphics.DeleteVb( sidesVb );
|
||||||
graphics.DeleteVb( edgesVb );
|
graphics.DeleteVb( edgesVb );
|
||||||
sidesVb = edgesVb = -1;
|
sidesVb = edgesVb = -1;
|
||||||
@ -96,7 +92,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
MakeTexture( ref sideTexId, ref lastSideTexLoc, map.SidesBlock );
|
MakeTexture( ref sideTexId, ref lastSideTexLoc, map.SidesBlock );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnNewMapLoaded( object sender, EventArgs e ) {
|
public void OnNewMapLoaded( Game game ) {
|
||||||
CalculateRects( game.ViewDistance );
|
CalculateRects( game.ViewDistance );
|
||||||
RebuildSides( map.SidesHeight, legacy ? 128 : 65536 );
|
RebuildSides( map.SidesHeight, legacy ? 128 : 65536 );
|
||||||
RebuildEdges( map.EdgeHeight, legacy ? 128 : 65536 );
|
RebuildEdges( map.EdgeHeight, legacy ? 128 : 65536 );
|
||||||
|
@ -8,25 +8,19 @@ namespace ClassicalSharp.Renderers {
|
|||||||
/// (no fog, clouds, or proper overhead sky) </summary>
|
/// (no fog, clouds, or proper overhead sky) </summary>
|
||||||
public class MinimalEnvRenderer : EnvRenderer {
|
public class MinimalEnvRenderer : EnvRenderer {
|
||||||
|
|
||||||
public MinimalEnvRenderer( Game game ) {
|
public override void Init( Game game ) {
|
||||||
this.game = game;
|
base.Init( game );
|
||||||
map = game.World;
|
graphics.Fog = false;
|
||||||
|
graphics.ClearColour( map.SkyCol );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render( double deltaTime ) {
|
public override void Render( double deltaTime ) {
|
||||||
graphics.ClearColour( map.SkyCol );
|
graphics.ClearColour( map.SkyCol );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Init() {
|
public override void OnNewMap( Game game ) { }
|
||||||
base.Init();
|
|
||||||
graphics.Fog = false;
|
|
||||||
graphics.ClearColour( map.SkyCol );
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnNewMap( object sender, EventArgs e ) {
|
public override void OnNewMapLoaded( Game game ) {
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnNewMapLoaded( object sender, EventArgs e ) {
|
|
||||||
graphics.ClearColour( map.SkyCol );
|
graphics.ClearColour( map.SkyCol );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,11 +8,6 @@ namespace ClassicalSharp.Renderers {
|
|||||||
|
|
||||||
public unsafe class StandardEnvRenderer : EnvRenderer {
|
public unsafe class StandardEnvRenderer : EnvRenderer {
|
||||||
|
|
||||||
public StandardEnvRenderer( Game game ) {
|
|
||||||
this.game = game;
|
|
||||||
map = game.World;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cloudsVb = -1, cloudVertices, skyVb = -1, skyVertices;
|
int cloudsVb = -1, cloudVertices, skyVb = -1, skyVertices;
|
||||||
bool legacy;
|
bool legacy;
|
||||||
|
|
||||||
@ -58,25 +53,25 @@ namespace ClassicalSharp.Renderers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnNewMap( object sender, EventArgs e ) {
|
public override void Init( Game game ) {
|
||||||
|
base.Init( game );
|
||||||
|
graphics.Fog = true;
|
||||||
|
ResetAllEnv( null, null );
|
||||||
|
game.Events.ViewDistanceChanged += ResetAllEnv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnNewMap( Game game ) {
|
||||||
graphics.Fog = false;
|
graphics.Fog = false;
|
||||||
graphics.DeleteVb( skyVb );
|
graphics.DeleteVb( skyVb );
|
||||||
graphics.DeleteVb( cloudsVb );
|
graphics.DeleteVb( cloudsVb );
|
||||||
skyVb = cloudsVb = -1;
|
skyVb = cloudsVb = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnNewMapLoaded( object sender, EventArgs e ) {
|
public override void OnNewMapLoaded( Game game ) {
|
||||||
graphics.Fog = true;
|
graphics.Fog = true;
|
||||||
ResetAllEnv( null, null );
|
ResetAllEnv( null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Init() {
|
|
||||||
base.Init();
|
|
||||||
graphics.Fog = true;
|
|
||||||
ResetAllEnv( null, null );
|
|
||||||
game.Events.ViewDistanceChanged += ResetAllEnv;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResetAllEnv( object sender, EventArgs e ) {
|
void ResetAllEnv( object sender, EventArgs e ) {
|
||||||
ResetFog();
|
ResetFog();
|
||||||
ResetSky();
|
ResetSky();
|
||||||
|
@ -19,12 +19,8 @@ namespace ClassicalSharp.Renderers {
|
|||||||
graphics = game.Graphics;
|
graphics = game.Graphics;
|
||||||
info = game.BlockInfo;
|
info = game.BlockInfo;
|
||||||
weatherVb = graphics.CreateDynamicVb( VertexFormat.P3fT2fC4b, vertices.Length );
|
weatherVb = graphics.CreateDynamicVb( VertexFormat.P3fT2fC4b, vertices.Length );
|
||||||
game.WorldEvents.OnNewMap += OnNewMap;
|
|
||||||
game.WorldEvents.OnNewMapLoaded += OnNewMapLoaded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset( Game game ) { }
|
|
||||||
|
|
||||||
int weatherVb;
|
int weatherVb;
|
||||||
short[] heightmap;
|
short[] heightmap;
|
||||||
float vOffset;
|
float vOffset;
|
||||||
@ -98,12 +94,14 @@ namespace ClassicalSharp.Renderers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int length, width, maxY, oneY;
|
int length, width, maxY, oneY;
|
||||||
void OnNewMap( object sender, EventArgs e ) {
|
public void Reset( Game game ) { OnNewMap( game ); }
|
||||||
|
|
||||||
|
public void OnNewMap( Game game ) {
|
||||||
heightmap = null;
|
heightmap = null;
|
||||||
lastPos = new Vector3I( Int32.MaxValue );
|
lastPos = new Vector3I( Int32.MaxValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnNewMapLoaded( object sender, EventArgs e ) {
|
public void OnNewMapLoaded( Game game ) {
|
||||||
length = map.Length;
|
length = map.Length;
|
||||||
width = map.Width;
|
width = map.Width;
|
||||||
maxY = map.Height - 1;
|
maxY = map.Height - 1;
|
||||||
@ -118,8 +116,6 @@ namespace ClassicalSharp.Renderers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
game.WorldEvents.OnNewMap -= OnNewMap;
|
|
||||||
game.WorldEvents.OnNewMapLoaded -= OnNewMapLoaded;
|
|
||||||
graphics.DeleteDynamicVb( weatherVb );
|
graphics.DeleteDynamicVb( weatherVb );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ namespace ClassicalSharp.Selections {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Reset( Game game ) { }
|
public void Reset( Game game ) { }
|
||||||
|
public void OnNewMap( Game game ) { }
|
||||||
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
game.Graphics.DeleteDynamicVb( vb );
|
game.Graphics.DeleteDynamicVb( vb );
|
||||||
|
@ -18,6 +18,8 @@ namespace ClassicalSharp.Renderers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Reset( Game game ) { }
|
public void Reset( Game game ) { }
|
||||||
|
public void OnNewMap( Game game ) { }
|
||||||
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
FastColour col = FastColour.Black;
|
FastColour col = FastColour.Black;
|
||||||
int index;
|
int index;
|
||||||
|
@ -16,12 +16,11 @@ namespace ClassicalSharp.Selections {
|
|||||||
public void Init( Game game ) {
|
public void Init( Game game ) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
Graphics = game.Graphics;
|
Graphics = game.Graphics;
|
||||||
game.WorldEvents.OnNewMap += OnNewMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset( Game game ) {
|
public void Reset( Game game ) { selections.Clear(); }
|
||||||
selections.Clear();
|
public void OnNewMap( Game game ) { selections.Clear(); }
|
||||||
}
|
public void OnNewMapLoaded( Game game ) { }
|
||||||
|
|
||||||
List<SelectionBox> selections = new List<SelectionBox>( 256 );
|
List<SelectionBox> selections = new List<SelectionBox>( 256 );
|
||||||
public void AddSelection( byte id, Vector3I p1, Vector3I p2, FastColour col ) {
|
public void AddSelection( byte id, Vector3I p1, Vector3I p2, FastColour col ) {
|
||||||
@ -72,9 +71,6 @@ namespace ClassicalSharp.Selections {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
OnNewMap( null, null );
|
|
||||||
game.WorldEvents.OnNewMap -= OnNewMap;
|
|
||||||
|
|
||||||
if( lineVb <= 0 ) return;
|
if( lineVb <= 0 ) return;
|
||||||
Graphics.DeleteDynamicVb( vb );
|
Graphics.DeleteDynamicVb( vb );
|
||||||
Graphics.DeleteDynamicVb( lineVb );
|
Graphics.DeleteDynamicVb( lineVb );
|
||||||
@ -87,9 +83,5 @@ namespace ClassicalSharp.Selections {
|
|||||||
vb = Graphics.CreateDynamicVb( VertexFormat.P3fC4b, vertices.Length );
|
vb = Graphics.CreateDynamicVb( VertexFormat.P3fC4b, vertices.Length );
|
||||||
lineVb = Graphics.CreateDynamicVb( VertexFormat.P3fC4b, lineVertices.Length );
|
lineVb = Graphics.CreateDynamicVb( VertexFormat.P3fC4b, lineVertices.Length );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnNewMap( object sender, EventArgs e ) {
|
|
||||||
selections.Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user