[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 組み立て式の建物について


柵・塀については、とりあえずこんな感じで
コアのコードを変更していただきたいのですがいかがでしょう?
プラグイン読み込み&設置用のコードは外部モジュールで作成中。

Index: World.cs
===================================================================
RCS file: /cvsroot/freetrain/FreeTrain/core/world/World.cs,v
retrieving revision 1.57
diff -u -r1.57 World.cs
--- World.cs	10 May 2003 17:17:21 -0000	1.57
+++ World.cs	30 Jun 2003 12:01:59 -0000
@@ -312,6 +312,15 @@
 			#endregion
 
 			public override void draw( DrawContext dc, Point pt, int heightCutDiff ) {}
+
+			protected override void drawFrontFence(DrawContext display, Point pt) {}
+
+			protected override void drawBehindFence(DrawContext display, Point pt) {}
+
+			public override void setFence( Direction d, Fence f ) {}
+
+			public override Fence getFence( Direction d ) { return null; }	
+
 		}
 
 		/// <summary>

*****CVS はコード 1 で終了しました*****

cvs diff World.cs Voxel.cs (ディレクトリ C:\Project\FreeTrain\FreeTrain\core\world\ 内)
Index: World.cs
===================================================================
RCS file: /cvsroot/freetrain/FreeTrain/core/world/World.cs,v
retrieving revision 1.57
diff -u -r1.57 World.cs
--- World.cs	10 May 2003 17:17:21 -0000	1.57
+++ World.cs	30 Jun 2003 14:51:09 -0000
@@ -312,6 +312,15 @@
 			#endregion
 
 			public override void draw( DrawContext dc, Point pt, int heightCutDiff ) {}
+
+			protected override void drawFrontFence(DrawContext display, Point pt) {}
+
+			protected override void drawBehindFence(DrawContext display, Point pt) {}
+
+			public override void setFence( Direction d, Fence f ) {}
+
+			public override Fence getFence( Direction d ) { return null; }	
+
 		}
 
 		/// <summary>
Index: Voxel.cs
===================================================================
RCS file: /cvsroot/freetrain/FreeTrain/core/world/Voxel.cs,v
retrieving revision 1.12
diff -u -r1.12 Voxel.cs
--- Voxel.cs	4 May 2003 17:57:35 -0000	1.12
+++ Voxel.cs	30 Jun 2003 14:51:09 -0000
@@ -2,6 +2,7 @@
 using System.Diagnostics;
 using System.Drawing;
 using org.kohsuke.directdraw;
+using freetrain.framework.graphics;
 
 namespace freetrain.world
 {
@@ -15,6 +16,7 @@
 	public abstract class Voxel
 	{
 		public abstract Location location { get; }
+		protected bool showFence = true;
 
 		/// <summary>
 		/// Draws this voxel
@@ -29,6 +31,28 @@
 		/// </param>
 		public abstract void draw( DrawContext display, Point pt, int heightCutDiff );
 
+		public void drawVoxel( DrawContext display, Point pt, int heightCutDiff ) 
+		{
+			if( showFence )
+			{
+				// draw behind fence 
+				drawBehindFence(display, pt);
+				draw( display, pt, heightCutDiff );
+				drawFrontFence(display, pt);
+				//draw front fence 
+			}
+			else
+				draw( display, pt, heightCutDiff );
+		}
+
+		public abstract void setFence( Direction d, Fence f );
+
+		public abstract Fence getFence( Direction d );
+
+		protected abstract void drawFrontFence(DrawContext display, Point pt);
+
+		protected abstract void drawBehindFence(DrawContext display, Point pt);
+
 		/// <summary>
 		/// Processes a mouse click.
 		/// </summary>
@@ -76,7 +100,10 @@
 	[Serializable]
 	public abstract class AbstractVoxelImpl : Voxel
 	{
-		protected AbstractVoxelImpl( int x, int y, int z ) : this(new Location(x,y,z)) {
+		protected Fence[] fence = new Fence[4];
+
+		protected AbstractVoxelImpl( int x, int y, int z ) : this(new Location(x,y,z)) 
+		{
 		}
 
 		protected AbstractVoxelImpl( Location _loc) {
@@ -87,6 +114,40 @@
 		private readonly Location loc;
 
 		public override Location location { get { return loc; } }
+
+		protected override void drawFrontFence(DrawContext display, Point pt) 
+		{
+			Fence f;
+			f =fence[(Direction.SOUTH).index/2];
+			if(f!=null)
+				f.drawFence( display.surface,pt,Direction.SOUTH );
+			f =fence[(Direction.WEST).index/2];
+			if(f!=null)
+				f.drawFence( display.surface,pt,Direction.WEST );
+		}
+
+		protected override void drawBehindFence(DrawContext display, Point pt) 
+		{
+			Fence f;
+			f =fence[(Direction.NORTH).index/2];
+			if(f!=null)
+				f.drawFence( display.surface,pt,Direction.NORTH );
+			f =fence[(Direction.EAST).index/2];
+			if(f!=null)
+				f.drawFence( display.surface,pt,Direction.EAST );
+		}
+
+		public override void setFence( Direction d, Fence f )
+		{
+			fence[d.index/2] = f;
+		}
+
+		public override Fence getFence( Direction d )
+		{
+			return fence[d.index/2];
+		
+		}
+	
 	}
 
 
@@ -107,5 +168,19 @@
 		/// false if directly below the ground.
 		/// </param>
 		bool drawGround( bool above );
+	}
+
+	/// <summary>
+	/// The interface called when the fence should be drawn.
+	/// </summary>
+	public interface Fence
+	{
+		/// <summary>
+		/// called when the fehce should be drawn.
+		/// </summary>
+		/// <param name="d">one of the 4 directions (N,E,W,S)</param>
+		void drawFence( Surface surface, Point pt, Direction d );
+
+		string fence_id { get; }
 	}
 }

Index: QuarterViewDrawer.cs
===================================================================
RCS file: /cvsroot/freetrain/FreeTrain/core/views/QuarterViewDrawer.cs,v
retrieving revision 1.7
diff -u -r1.7 QuarterViewDrawer.cs
--- QuarterViewDrawer.cs	26 Jan 2003 17:26:19 -0000	1.7
+++ QuarterViewDrawer.cs	30 Jun 2003 14:52:28 -0000
@@ -337,7 +337,7 @@
 						}
 
 						if(voxel!=null)
-							voxel.draw( drawContext, pt, noHeightCut?-1:(Z-z) );
+							voxel.drawVoxel( drawContext, pt, noHeightCut?-1:(Z-z) );
 						if(overlay!=null)
 							overlay.drawVoxel( this, drawContext, world.toXYZ(h,v,z),  pt );
 					}

_______________________________________________
FreeTrain-general mailing list
FreeTrain-general@lists.sourceforge.jp
http://lists.sourceforge.jp/mailman/listinfo/freetrain-general

題名

名前

メッセージ