コード例 #1
0
		private void UpdateSoundPropagation()
		{
			huntingThings.Clear();
			BuilderPlug.Me.BlockingLinedefs.Clear();

			foreach(Linedef ld in General.Map.Map.Linedefs)
			{
				if(ld.IsFlagSet(BlockSoundFlag)) BuilderPlug.Me.BlockingLinedefs.Add(ld);
			}

			//mxd. Create sound propagation for the whole map
			int counter = 0;
			foreach(Sector sector in General.Map.Map.Sectors)
			{
				if(!sector2domain.ContainsKey(sector))
				{
					SoundPropagationDomain spd = new SoundPropagationDomain(sector);
					foreach(Sector s in spd.Sectors) sector2domain[s] = spd;
					spd.Color = BuilderPlug.Me.DistinctColors[counter++ % BuilderPlug.Me.DistinctColors.Count].WithAlpha(255).ToInt();
					propagationdomains.Add(spd);
				}
			}

			if(highlighted == null || highlighted.IsDisposed) return;

			//mxd. Create the list of sectors, which will be affected by noise made in highlighted sector
			SoundPropagationDomain curdomain = sector2domain[highlighted];
			Dictionary<int, Sector> noisysectors = new Dictionary<int, Sector>(curdomain.Sectors.Count);
			foreach(Sector s in curdomain.Sectors)
			{
				noisysectors.Add(s.Index, s);
			}

			foreach(Sector s in curdomain.AdjacentSectors)
			{
				SoundPropagationDomain aspd = sector2domain[s];
				foreach(Sector adjs in aspd.Sectors)
				{
					if(!noisysectors.ContainsKey(adjs.Index)) noisysectors.Add(adjs.Index, adjs);
				}
			}

			// Update the list of things that will actually go for the player when hearing a noise
			foreach(Thing thing in General.Map.Map.Things)
			{
				if(!General.Map.ThingsFilter.VisibleThings.Contains(thing)) continue;
				if(thing.IsFlagSet(General.Map.UDMF ? "ambush" : "8")) continue;
				if(thing.Sector == null) thing.DetermineSector();
				if(thing.Sector != null && noisysectors.ContainsKey(thing.Sector.Index)) huntingThings.Add(thing);
			}
		}
コード例 #2
0
		// This redraws the display
		public override void OnRedrawDisplay()
		{
			List<SoundPropagationDomain> renderedspds = new List<SoundPropagationDomain>();
			if(BuilderPlug.Me.DataIsDirty) UpdateData();

			renderer.RedrawSurface();

			// Render lines and vertices
			if (renderer.StartPlotter(true))
			{

				// Plot lines by hand, so that no coloring (line specials, 3D floors etc.) distracts from
				// the sound propagation. Also don't draw the line's normal. They are not needed here anyway
				// and can make it harder to see the sound environment propagation
				foreach(Linedef ld in General.Map.Map.Linedefs)
				{
					PixelColor c = (ld.IsFlagSet(General.Map.Config.ImpassableFlag) ? 
						General.Colors.Linedefs : General.Colors.Linedefs.WithAlpha(General.Settings.DoubleSidedAlphaByte));
					renderer.PlotLine(ld.Start.Position, ld.End.Position, c, BuilderPlug.LINE_LENGTH_SCALER);
				}

				// Since there will usually be way less blocking linedefs than total linedefs, it's presumably
				// faster to draw them on their own instead of checking if each linedef is in BlockingLinedefs
				foreach(Linedef ld in BuilderPlug.Me.BlockingLinedefs)
					renderer.PlotLine(ld.Start.Position, ld.End.Position, BuilderPlug.Me.BlockSoundColor, BuilderPlug.LINE_LENGTH_SCALER);

				//mxd. Render highlighted line
				if(highlightedline != null)
					renderer.PlotLine(highlightedline.Start.Position, highlightedline.End.Position, General.Colors.Highlight, BuilderPlug.LINE_LENGTH_SCALER);

				renderer.Finish();
			}

			// Render things
			if(renderer.StartThings(true))
			{
				renderer.RenderThingSet(General.Map.ThingsFilter.HiddenThings, General.Settings.HiddenThingsAlpha);
				renderer.RenderThingSet(General.Map.ThingsFilter.VisibleThings, General.Settings.InactiveThingsAlpha);
				foreach(Thing thing in huntingThings)
					renderer.RenderThing(thing, General.Colors.Selection, General.Settings.ActiveThingsAlpha);

				renderer.Finish();
			}

			if(renderer.StartOverlay(true))
			{
				// Render highlighted domain and domains adjacent to it
				if(highlighted != null && !highlighted.IsDisposed)
				{
					renderer.RenderGeometry(overlayGeometry, null, true); //mxd
					
					SoundPropagationDomain spd = sector2domain[highlighted];
					renderer.RenderGeometry(spd.Level1Geometry, null, true);

					foreach(Sector s in spd.AdjacentSectors)
					{
						SoundPropagationDomain aspd = sector2domain[s];
						if(!renderedspds.Contains(aspd))
						{
							renderer.RenderGeometry(aspd.Level2Geometry, null, true);
							renderedspds.Add(aspd);
						}
					}

					renderer.RenderHighlight(highlighted.FlatVertices, BuilderPlug.Me.HighlightColor.WithAlpha(128).ToInt()); //mxd
				}
				else
				{
					//mxd. Render all domains using domain colors
					foreach(SoundPropagationDomain spd in propagationdomains)
						renderer.RenderHighlight(spd.Level1Geometry, spd.Color);
				}

				renderer.Finish();
			}
			
			renderer.Present();
		}