public static float Random(Vec2i vec) { var n = vec.X + (vec.Y * 57); n = (n << 13) ^ n; n = (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff; return 1f - (n / 1073741824f); }
// protected override void OnCreateTexture( string definitionName, ref Vec2i size ) { base.OnCreateTexture( definitionName, ref size ); if( definitionName == "scene" || definitionName == "temp" ) size = Owner.DimensionsInPixels.Size / 2; }
public static float Smooth(Vec2i vec) { var corners = _corners.Aggregate (0f, (res, c) => res + Random (c + vec)) / (_corners.Length * 4f); var sides = _sides.Aggregate (0f, (res, s) => res + Random (s + vec)) / (_corners.Length * 2f); var center = Random (vec) / 4f; return corners + sides + center; }
public override bool PlaceBlock(BlockType type, Vec2i location) { if (type == BlockType.Spawner) { spawnerLocation = location; } return base.PlaceBlock(type, location); }
public static float Interpolated(Vec2 vec, float amplitude) { var intVec = new Vec2i ((int)vec.X, (int)vec.Y); var fracVec = vec.Fraction (); var vs = _nexts.Map (next => Smooth (intVec + next) * amplitude); var i1 = GLMath.CosMix (vs[0], vs[1], fracVec.X); var i2 = GLMath.CosMix (vs[2], vs[3], fracVec.X); return GLMath.CosMix (i1, i2, fracVec.Y); }
public void FitWhole(Vec2i point) { if (point.x < bl.x){ bl.x = point.x; } if (point.y < bl.y){ bl.y = point.y; } if (point.x >= tr.x){ tr.x = point.x + 1; } if (point.y >= tr.y){ tr.y = point.y + 1; } }
public void Reset(Vec2i pos) { this.pos = pos; l2Tile = vessel.TryGetTile(new Vec2i(pos.x-2,pos.y)); lTile = vessel.TryGetTile(new Vec2i(pos.x-1,pos.y)); blTile = vessel.TryGetTile(new Vec2i(pos.x-1,pos.y-1)); bTile = vessel.TryGetTile(new Vec2i(pos.x,pos.y-1)); b2Tile = vessel.TryGetTile(new Vec2i(pos.x,pos.y-2)); brTile = vessel.TryGetTile(new Vec2i(pos.x+1,pos.y-1)); b2rTile = vessel.TryGetTile(new Vec2i(pos.x+1,pos.y-2)); br2Tile = vessel.TryGetTile(new Vec2i(pos.x+2,pos.y-1)); tile = vessel.TryGetTile(new Vec2i(pos.x, pos.y)); rTile = vessel.TryGetTile(new Vec2i(pos.x+1, pos.y)); r2Tile = vessel.TryGetTile(new Vec2i(pos.x+2, pos.y)); }
public void Fit(Vec2i point) { if (point.x < bl.x){ bl.x = point.x; } if (point.y < bl.y){ bl.y = point.y; } if (point.x > tr.x){ tr.x = point.x; } if (point.y > tr.y){ tr.y = point.y; } }
protected override void OnCreateTexture( string definitionName, ref Vec2i size ) { base.OnCreateTexture( definitionName, ref size ); if( definitionName == "rt_brightPass" ) { size = Owner.DimensionsInPixels.Size / 2; brightPassTextureSize = size; } else if( definitionName == "rt_bloomBlur" || definitionName == "rt_bloomHorizontal" || definitionName == "rt_bloomVertical" ) { size = Owner.DimensionsInPixels.Size / 4; bloomTextureSize = size; } }
public void ReinstantiateChunks() { for (int i = 0; i < chunks.dim.y; i++) { for (int j = 0; j < chunks.dim.x; j++) { Vec2i chunkI = new Vec2i(j, i) + chunks.origin; ClientVC chunk; if ((chunk = (ClientVC)chunks.TryGet(chunkI)) != null) { if (chunk.Modified) { foreach (var c in chunks.WithinRange(chunk.Index, 1)) { if (c != null) { if (c.Instantiated) { c.Destroy(); } Debug.Log ("Instantiating chunk: " + c.Index.ToString()); InstantiateChunk(c); } } chunk.Modified = false; } } } } }
public void SetWorldEntrance(Vec2i ent) { InternalEntrancePos = ent; }
public TerrainMesh(SceneGraph graph, Vec2i start, Vec2i size, float amplitude, float frequency, int octaves, float amplitudeDamping, float frequencyMultiplier) : base(graph) { Patch = new TerrainPatch <V> (start, size, amplitude, frequency, octaves, amplitudeDamping, frequencyMultiplier); }
public Texture(Vec2i size) : this(size.X, size.Y) { }
public static Vec2 GetPosition(Vec2i Coords) { return(new Vec2(Coords.X * Tile.Size.X * 2, Coords.Y * Tile.Size.Y * 2)); }
public Cursor(Vec2i pos) : this(pos.X, pos.Y) { }
private bool FindSlot(IAtlasDescriptor descriptor, byte[] scan, GlyphDescriptor gi, ref Vec2i minsize) { long reqWidth = gi.Width; long reqHeight = gi.Height; long big = (long)descriptor.MaxSize; if (reqHeight == 0 || reqWidth == 0) { gi.X = (int)0; gi.Y = (int)0; return true; } // try to find an empty space within the current used box for (long y = 0; y <= (minsize.Y - reqHeight); y++) { for (long x = 0; x <= (minsize.X - reqWidth); x++) { long cx, cy; long incr = y * big; for (cy = y; cy < y + reqHeight; cy++) { for (cx = x; cx < x + reqWidth; cx++) { if (scan[incr + cx] != 0) { cy = 9999; break; } } incr += big; } // put it here if (cy < 9999) { gi.X = (int)x; gi.Y = (int)y; return true; } } } // if no space was found, expand the smallest edge of the used box, // which will keep the texture close to square if (minsize.X < minsize.Y) { if (minsize.X == descriptor.MaxSize - 1) { return false; } minsize.X += (int)reqWidth; if (minsize.X >= descriptor.MaxSize) { minsize.X = descriptor.MaxSize - 1; } } else { if (minsize.Y == descriptor.MaxSize - 1) { return false; } minsize.Y += (int)reqHeight; if (minsize.Y >= descriptor.MaxSize) { minsize.Y = descriptor.MaxSize - 1; } } return FindSlot(descriptor, scan, gi, ref minsize); }
public void SetCompartmentFloor(FloorType type, Compartment c) { Vec2i start = ChunkIToTileI(aabb.bl); Vec2i end = ChunkIToTileI(aabb.tr); for (int i = start.y; i < end.y; i++) { for (int j = start.x; j < end.x; j++) { Vec2i tileI = new Vec2i(j, i); VesselTile tile; if ((tile = TryGetTile(tileI)) != null) { bool modified = false; if (tile.c0 != null && tile.c0.Instance == c) { tile.floor0 = type; modified = true; } if (tile.c1 != null && tile.c1.Instance == c) { tile.floor1 = type; modified |= true; } if (modified) { AddModifiedChunk((ServerVC)chunks.Get(TileToChunkI(tileI))); } } } } }
public static void SampleToBuffer <T> (this Signal <Vec2i, T> signal, T[] buffer, Vec2i bufferSize) { var length = bufferSize.Producti(); Parallel.For(0, bufferSize.Y, y => { for (var x = 0; x < bufferSize.X; x++) { buffer[y * bufferSize.Y + x] = signal(new Vec2i(x, bufferSize.Y - y - 1)); } }); }
public static Func <Vec2i, Vec2> BitmapCoordTo0_1(Vec2i bitmapSize, float scale) { return(vec => new Vec2( vec.X * scale / bitmapSize.X, vec.Y * scale / bitmapSize.Y)); }
public bool InBounds(Vec2i p) { return(p.x >= 0 && p.y >= 00 && p.x < grid.GetLength(0) && p.y < grid.GetLength(1)); }
private void tryBfsRemove(int x, int z) { Queue <Vec2i> nodesToVisit = new Queue <Vec2i>(); HashSet <Vec2i> nodesVisited = new HashSet <Vec2i>(); nodesToVisit.Enqueue(new Vec2i(x, z)); List <Vec2i> foundPieces = new List <Vec2i>(); while (nodesToVisit.Count > 0) { Vec2i node = nodesToVisit.Dequeue(); for (int i = 0; i < BlockFacing.HORIZONTALS.Length; i++) { BlockFacing face = BlockFacing.HORIZONTALS[i]; Vec2i nnode = node.Copy().Add(face.Normali.X, face.Normali.Z); if (nnode.X < 0 || nnode.X >= 16 || nnode.Y < 0 || nnode.Y >= 16) { continue; } if (!Voxels[nnode.X, nnode.Y]) { continue; } if (nodesVisited.Contains(nnode)) { continue; } nodesVisited.Add(nnode); foundPieces.Add(nnode); if (SelectedRecipe.Voxels[nnode.X, 0, nnode.Y]) { return; } nodesToVisit.Enqueue(nnode); } } // Single voxel with no neighbours if (nodesVisited.Count == 0 && foundPieces.Count == 0) { foundPieces.Add(new Vec2i(x, z)); } Vec3d tmp = new Vec3d(); foreach (var val in foundPieces) { Voxels[val.X, val.Y] = false; if (Api.Side == EnumAppSide.Client) { tmp.Set(Pos.X + val.X / 16f, Pos.Y, Pos.Z + val.Y / 16f); spawnParticles(tmp); } } }
public FramePattern(byte[,] pattern, Vec2i angle) { this.pattern = pattern; this.angle = angle; }
public BrickWall(Vec2i worldPosition, int height = 1, WorldObjectMetaData meta = null, Vec2i size = null) : base(worldPosition, meta, size) { }
public CharaView snapToGridPos(Vec2i gridPos) { this.chip.snapToGridPos(gridPos); return(this); }
/// <summary>Converts a point in a <c>Pattern</c> to one in the <c>source</c></summary> public static Vec2i localPosToSourcePos(this Pattern self, Vec2i localPosition, int N) { return(self.offset + self.variant.apply(localPosition, N)); }
public static Func <Vec2i, float> BitmapYToFloat(Vec2i bitmapSize, float scale) { return(vec => vec.X * scale / bitmapSize.X); }
public Grass(Vec2i worldPosition) : base(worldPosition, null, null) { }
public BuildingEntrance(Vec2i a, Vec2i b) { A = a; B = b; }
public void SetTile(Vec2i index, VesselTile val) { Vec2i index2 = index; Vec2i chunkI = TileToChunkI(index); ServerVC vc = (ServerVC)chunks.TryGet(chunkI); if (vc == null) { vc = CreateChunk(chunkI); } try { index -= vc.OriginTileIndex(); vc.SetTile(index, val); AddModifiedChunk(vc); } catch (System.Exception ex) { Debug.Log("Failed to set tile at " + index2.ToString() + "/" + index.ToString() + " at chunk " + chunkI.ToString()); } }
public LevelWrapZone(Vec2i pos, int ident) : base(pos) { target_world = (ident & MASK_WORLD) >> 4; target_level = (ident & MASK_LEVEL); }
public Tile GetByID(int id) { Vec2i coords = GetCoords(id); return(GetTile(coords.X, coords.Y)); }
private void OnDrawGizmos() { return; if (TestSettle != null && !hasBuilt) { for (int x = 0; x < TestSettle.PathNodes.GetLength(0); x++) { for (int z = 0; z < TestSettle.PathNodes.GetLength(0); z++) { if (TestSettle.SettlementPathFinder.PathNodes[x, z] > 0) { Vector3 pos = Vec2i.ToVector3(new Vec2i(x, z) * World.ChunkSize + TestSettle.BaseCoord); GameObject obj = Instantiate(TEST_PREF); obj.transform.position = pos; PathFindingNodeTest pnt = obj.GetComponent <PathFindingNodeTest>(); pnt.map = TestSettle.SettlementPathFinder.PathNodes; pnt.x = x; pnt.z = z; } else if (TestSettle.SettlementPathFinder.PathNodes[x, z] == -1) { Vector3 pos = Vec2i.ToVector3(new Vec2i(x, z) * World.ChunkSize + TestSettle.BaseCoord); GameObject obj = Instantiate(TEST_PREF); obj.transform.position = pos; obj.transform.localScale = Vector3.one * 5; PathFindingNodeTest pnt = obj.GetComponent <PathFindingNodeTest>(); pnt.map = TestSettle.SettlementPathFinder.PathNodes; pnt.x = x; pnt.z = z; } } }/* * foreach (SettlementPathNode spn in TestSettle.tNodes) * { * if (spn == null) * continue; * Vector3 pos = Vec2i.ToVector3(spn.Position + TestSettle.BaseCoord); * GameObject obj = Instantiate(TEST_PREF); * obj.transform.position = pos; * obj.GetComponent<PathFindingNodeTest>().spn = spn; * }*/ hasBuilt = true; } return; if (TestSettle != null) { foreach (SettlementPathNode spn in TestSettle.tNodes) { if (spn == null) { continue; } Vector3 pos = Vec2i.ToVector3(spn.Position + TestSettle.BaseCoord); Gizmos.DrawSphere(pos, 0.5f); foreach (SettlementPathNode con in spn.Connected) { if (con != null) { //Debug.Log("not null"); Gizmos.DrawLine(pos, Vec2i.ToVector3(con.Position + TestSettle.BaseCoord)); } } } } }
public void AddTile(Vec2i v, Tile t) { AddTile(v.X, v.Y, t); }
protected virtual Vec2i GetNextPos(Vec2i current) { return(Vec2i.Zero); }
public Cursor(String tex, Vec2i pos, Vec2i size, Texture parent, bool isSingleUser, int singleUserID) : base(tex, pos, size, parent, isSingleUser, singleUserID, GUIEvents.None, false) { create(-1); }
public Connection(Vec2i a, Vec2i b, bool xAxis) { this.a = a; this.b = b; this.xAxis = xAxis; }
public void FitTile(Vec2i index) { aabb.FitWhole(index); }
public BeanStalkSpawnZone(Vec2i pos) : base(pos) { }
public void SetExternalEntrancePos(Vec2i v) { ExternalEntrancePos = v; SetSubworldID(v.GetHashCode()); }
static void CalculateDownScale4x4SampleOffsets( Vec2i sourceTextureSize, Vec2[] sampleOffsets ) { // Sample from the 16 surrounding points. Since the center point will be in // the exact center of 16 texels, a 0.5f offset is needed to specify a texel // center. Vec2 invSize = 1.0f / sourceTextureSize.ToVec2(); int index = 0; for( int y = 0; y < 4; y++ ) { for( int x = 0; x < 4; x++ ) { sampleOffsets[ index ] = new Vec2( ( (float)x - 1.5f ), ( (float)y - 1.5f ) ) * invSize; index++; } } }
public static Vec2i apply(this PatternVariation self, Vec2i v, int N) { return(applyInt((int)self, v, N)); }
private void SlotGlyphPosition(GlyphDescriptorCollection glyphs, IAtlasDescriptor descriptor, List<Vec2i> sizes, Action<float> progress, CancellationTokenSource cts) { long big = (long)descriptor.MaxSize; byte[] scan = new byte[big * big]; Vec2i minsize = Vec2i.Zero; int count = glyphs.Count; int current = 0; int page = 0; foreach (var gi in glyphs) { if (!FindSlot(descriptor, scan, gi, ref minsize)) { if (descriptor.MultiTexture) { sizes.Add(minsize); // inc to next texture page++; // clear Array.Clear(scan, 0, scan.Length); minsize = Vec2i.Zero; // find again and place on new texture FindSlot(descriptor, scan, gi, ref minsize); } else { throw new Exception("Unable to fit glyphs on a single texture"); } } gi.Page = page; // mark glyph area used long incr0 = (gi.Y) * big; for (long y = 0; y < gi.Height; y++) { long incrx1 = incr0 + gi.X; for (long x = 0; x < gi.Width; x++) { scan[incrx1 + x] = 0xff; } incr0 += big; } if (progress != null) { progress((float)(++current) / count); } if (cts != null) { cts.Token.ThrowIfCancellationRequested(); } } // add the last page (or first page if single texture) if (sizes.Count <= page) { sizes.Add(minsize); } if (descriptor.PowerTwo) { for (int i = 0; i < sizes.Count; i++) { int mm = MathEx.HighPow2(Math.Max(sizes[i].X, sizes[i].Y)); sizes[i] = new Vec2i(mm, mm); } } else { // calc tightest box foreach (var gi in glyphs) { Vec2i sz = sizes[gi.Page]; sz.X = Math.Max(sz.X, gi.X + gi.Width); sz.Y = Math.Max(sz.Y, gi.Y + gi.Height); sizes[gi.Page] = sz; } } }
private static extern void GetIdealLayerDimensions(int layerId, ref Vec2i dims);
public void ServerOrSingle_SetIndex( Vec2i index ) { this.index = index; //send Index to clients if( EntitySystemWorld.Instance.IsServer() ) Server_SendIndexToClients( EntitySystemWorld.Instance.RemoteEntityWorlds ); }
public Image CropImage(Image image, out Vec2i offset) { // find crop area Vec2i min = new Vec2i(int.MaxValue, int.MaxValue); Vec2i max = new Vec2i(int.MinValue, int.MinValue); Vec2i maxVal = min; var img = (Bitmap)image.Clone(); try { var bmp = img.LockBits(new Rectangle(0, 0, img.Width, img.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); unsafe { byte* scan0 = (byte*)bmp.Scan0.ToPointer(); int incx, incy = 0; for (int y = 0; y < img.Height; ++y) { incx = incy; for (int x = 0; x < img.Width; ++x, incx += 4) { if (*(scan0 + incx + 3) != 0) { if (x < min.X) min.X = x; if (y < min.Y) min.Y = y; if (x > max.X) max.X = x; if (y > max.Y) max.Y = y; } } incy += bmp.Stride; } } img.UnlockBits(bmp); // crop it if (min == maxVal) { offset = Vec2i.Zero; return (Image)img.Clone(); } else { offset = min; Rectangle cropArea = new Rectangle(min.X, min.Y, max.X - min.X + 1, max.Y - min.Y + 1); return img.Clone(cropArea, img.PixelFormat); } } finally { img.Dispose(); } }
public AdjacentTiles(ServerVessel vessel, Vec2i start) { this.vessel = vessel; Reset(start); }
private void GridGlyphPosition(GlyphDescriptorCollection glyphs, IAtlasDescriptor descriptor, out Vec2i texSize, Action<float> progress, CancellationTokenSource cts) { texSize = Vec2i.Zero; int mx = 0; int my = 0; // calc max sizes foreach (var gi in glyphs) { mx = Math.Max(mx, gi.Width); my = Math.Max(my, gi.Height); } // calc smallest size block int count = glyphs.Count; int sz = Math.Max(mx, my); int dim = sz; int cx = 0; while (dim <= descriptor.MaxSize) { cx = dim / sz; int cnt = cx * cx; if (count <= cnt) { break; } // increase dim += sz; } if (dim > descriptor.MaxSize) { throw new Exception("Unable to fit glyphs on a single image"); } dim = descriptor.PowerTwo ? MathEx.HighPow2(dim + 1) : dim; // position int current = 0; foreach (var gi in glyphs) { gi.X = (current % cx) * sz; gi.Y = (current / cx) * sz; ++current; if (progress != null) { progress((float)(current) / count); } if (cts != null) { cts.Token.ThrowIfCancellationRequested(); } } Vec2i size = Vec2i.Zero; size.X = cx; size.Y = ((count - 1) / cx) + 1; descriptor.GridCells = size; size.X = sz; size.Y = sz; descriptor.GridSize = size; if (descriptor.PowerTwo) { texSize = new Vec2i(dim, dim); } else { // calc tightest box foreach (var gi in glyphs) { texSize.X = Math.Max(texSize.X, gi.X + gi.Width); texSize.Y = Math.Max(texSize.Y, gi.Y + gi.Height); } } }
private ServerVC CreateChunk(Vec2i index) { ServerVC temp = new ServerVC(index); chunks.Set(index.x, index.y, temp); aabb.FitWhole(index); return temp; }
void ServerOrSingle_CreatePiece( Vec2i index ) { JigsawPuzzlePiece piece = (JigsawPuzzlePiece)Entities.Instance.Create( "JigsawPuzzlePiece", Map.Instance ); piece.ServerOrSingle_SetIndex( index ); //calculate position { Rect area = GetGameArea(); area.Expand( -.5f ); Rect exceptArea = GetDestinationArea(); exceptArea.Expand( 1 ); float x = 0; float y = 0; bool free = false; do { free = true; EngineRandom random = World.Instance.Random; x = area.Minimum.X + random.NextFloat() * area.Size.X; y = area.Minimum.Y + random.NextFloat() * area.Size.Y; if( exceptArea.IsContainsPoint( new Vec2( x, y ) ) ) free = false; Bounds checkBounds = new Bounds( new Vec3( x - .5f, y - .5f, -100 ), new Vec3( x + .5f, y + .5f, 100 ) ); Map.Instance.GetObjects( checkBounds, delegate( MapObject mapObject ) { JigsawPuzzlePiece p = mapObject as JigsawPuzzlePiece; if( p != null ) free = false; } ); } while( !free ); piece.Position = new Vec3( x, y, .1f ); } piece.PostCreate(); }
void ServerOrSingle_SetPieceCount( Vec2i pieceCount ) { this.pieceCount = pieceCount; //send pieceCount to clients if( EntitySystemWorld.Instance.IsServer() ) Server_SendPieceCountToClients( EntitySystemWorld.Instance.RemoteEntityWorlds ); }
void Client_ReceiveIndex( RemoteEntityWorld sender, ReceiveDataReader reader ) { Vec2i value = reader.ReadVec2i(); if( !reader.Complete() ) return; index = value; }
public virtual bool PlaceBlock(BlockType type, Vec2i location) { VesselTile tile; if ((tile = TryGetTile(location)) != null) { tile.blockT = type; } return false; }
static void CalculateGaussianBlur5x5SampleOffsets( Vec2i textureSize, Vec2[] sampleOffsets, Vec4[] sampleWeights, float multiplier ) { float tu = 1.0f / (float)textureSize.X; float tv = 1.0f / (float)textureSize.Y; Vec4 white = new Vec4( 1, 1, 1, 1 ); float totalWeight = 0.0f; int index = 0; for( int x = -2; x <= 2; x++ ) { for( int y = -2; y <= 2; y++ ) { // Exclude pixels with a block distance greater than 2. This will // create a kernel which approximates a 5x5 kernel using only 13 // sample points instead of 25; this is necessary since 2.0 shaders // only support 16 texture grabs. if( Math.Abs( x ) + Math.Abs( y ) > 2 ) continue; // Get the unscaled Gaussian intensity for this offset sampleOffsets[ index ] = new Vec2( x * tu, y * tv ); sampleWeights[ index ] = white * GaussianDistribution( (float)x, (float)y, 1 ); totalWeight += sampleWeights[ index ].X; index++; } } // Divide the current weight by the total weight of all the samples; Gaussian // blur kernels add to 1.0f to ensure that the intensity of the image isn't // changed when the blur occurs. An optional multiplier variable is used to // add or remove image intensity during the blur. for( int i = 0; i < index; i++ ) { sampleWeights[ i ] /= totalWeight; sampleWeights[ i ] *= multiplier; } }
private void Initialize() { BuildFoundation(new Vec2i(-50,-50), new Vec2i(100, 100)); //tip // BuildWall(new Vec2i(4,13), 1, WallType.OneByZero); // //outer left // // // BuildWall(new Vec2i(1,1), 1, WallType.ZeroByOne); // BuildWall(new Vec2i(1,2), 1, WallType.OneByTwo); // BuildWall(new Vec2i(2,4), 5, WallType.ZeroByOne); // BuildWall(new Vec2i(2,9), 1, WallType.OneByTwo); // BuildWall(new Vec2i(3,11), 1, WallType.ZeroByOne); // BuildWall(new Vec2i(3,12), 1, WallType.OneByOne); // //outer right // // // BuildWall(new Vec2i(8,1), 1, WallType.ZeroByOne); // BuildWall(new Vec2i(8,2), 1, WallType.OneByTwoFlipped); // BuildWall(new Vec2i(7,4), 5, WallType.ZeroByOne); // BuildWall(new Vec2i(7,9), 1, WallType.OneByTwoFlipped); // BuildWall(new Vec2i(6,11), 1, WallType.ZeroByOne); // BuildWall(new Vec2i(6,12), 1, WallType.OneByOneFlipped); // // BuildWall(new Vec2i(1,1), 7, WallType.OneByZero); // // //inner vertical walls // BuildWall(new Vec2i(4,4), 7, WallType.ZeroByOne); // BuildWall(new Vec2i(5,4), 7, WallType.ZeroByOne); // //left horizontal walls // BuildWall(new Vec2i(3,11), 1, WallType.OneByZero); // BuildWall(new Vec2i(2,7), 2, WallType.OneByZero); // BuildWall(new Vec2i(2,4), 2, WallType.OneByZero); // //right horizontal walls // BuildWall(new Vec2i(5,11), 1, WallType.OneByZero); // BuildWall(new Vec2i(5,7), 2, WallType.OneByZero); // BuildWall(new Vec2i(5,4), 2, WallType.OneByZero); Vec2i loc0 = new Vec2i(0,-1); BuildWall(ref loc0, 1, WallType.OneByOneFlipped, false); BuildWall(ref loc0, 1, WallType.ZeroByOne, false); BuildWall(ref loc0, 1, WallType.OneByOne, false); loc0 += new Vec2i(1, 0); //BuildWall(ref loc0, 1, WallType.OneByZero, false); BuildWall(ref loc0, 1, WallType.OneByOneFlipped, true); BuildWall(ref loc0, 1, WallType.ZeroByOne, true); BuildWall(ref loc0, 1, WallType.OneByOne, true); BuildWall(ref loc0, 1, WallType.OneByZero, true); loc0 = new Vec2i(0,2); BuildWall(ref loc0, 4, WallType.ZeroByOne, false); BuildWall(ref loc0, 1, WallType.OneByOneFlipped, false); BuildWall(ref loc0, 1, WallType.ZeroByOne, false); Vec2i circleInner = loc0; BuildWall(ref loc0, 3, WallType.ZeroByOne, false); Vec2i circleOuter = loc0; BuildWall(ref loc0, 1, WallType.ZeroByOne, false); BuildWall(ref loc0, 3, WallType.OneByZero, false); BuildWall(ref loc0, 5, WallType.ZeroByOne, true); BuildWall(ref loc0, 1, WallType.OneByOne, true); BuildWall(ref loc0, 4, WallType.ZeroByOne, true); BuildWall(ref circleInner, 4, WallType.OneByZero, true); BuildWall(ref circleInner, 2, WallType.OneByOne, true); BuildWall(ref circleInner, 11, WallType.ZeroByOne, true); BuildWall(ref circleInner, 2, WallType.OneByOneFlipped, true); BuildWall(ref circleInner, 11, WallType.OneByZero, false); BuildWall(ref circleInner, 2, WallType.OneByOne, false); BuildWall(ref circleInner, 11, WallType.ZeroByOne, false); BuildWall(ref circleInner, 2, WallType.OneByOneFlipped, false); BuildWall(ref circleInner, 4, WallType.OneByZero, true); BuildWall(ref circleOuter, 5, WallType.OneByZero, true); BuildWall(ref circleOuter, 4, WallType.OneByOne, true); BuildWall(ref circleOuter, 13, WallType.ZeroByOne, true); BuildWall(ref circleOuter, 4, WallType.OneByOneFlipped, true); BuildWall(ref circleOuter, 13, WallType.OneByZero, false); BuildWall(ref circleOuter, 4, WallType.OneByOne, false); BuildWall(ref circleOuter, 13, WallType.ZeroByOne, false); BuildWall(ref circleOuter, 4, WallType.OneByOneFlipped, false); BuildWall(ref circleOuter, 5, WallType.OneByZero, true); //place spawner for noobs PlaceBlock(BlockType.Spawner, new Vec2i(0, 0)); RebuildCompartments(); }
void Client_ReceivePieceCount( RemoteEntityWorld sender, ReceiveDataReader reader ) { Vec2i value = reader.ReadVec2i(); if( !reader.Complete() ) return; pieceCount = value; }
public void Maze_Quality_Test_1() { Random rand = new Random(); PM_Maze maze = new PM_Maze(2, 2); Assert.IsTrue(maze.NumCells__All() == 4); Assert.IsTrue(maze.NumCells__OfSpecificDirections(Directions_Ortho_2D.None) == 4); Assert.IsTrue(maze.IsFullyExpanded() == false); Assert.IsTrue(maze.IsFullyConnected() == false); Assert.IsTrue(maze.IsCyclic() == false); Assert.IsTrue(maze.Islands(rand).Count == 4); Assert.IsTrue(maze.All_ActiveEdges_List().Count == 0); Assert.IsTrue(maze.All_ActiveEdges_Set().Count == 0); Assert.IsTrue(maze.All_InactiveEdges_InBounds_List().Count == 4); Assert.IsTrue(maze.All_InactiveEdges_InBounds_Set().Count == 4); //Assert.IsTrue(maze.All_ExpansionEdges_List().Count == 0); Vec2i bottom_left = new Vec2i(0, 0); Vec2i bottom_right = new Vec2i(1, 0); Vec2i top_left = new Vec2i(0, 1); Vec2i top_right = new Vec2i(1, 1); maze.OP_AddEdge(new UEdge2i(bottom_left, bottom_right)); Assert.IsTrue(maze.IsFullyExpanded() == false); Assert.IsTrue(maze.IsFullyConnected() == false); Assert.IsTrue(maze.IsCyclic() == false); Assert.IsTrue(maze.Islands(rand).Count == 3); Assert.IsTrue(maze.All_ActiveEdges_List().Count == 1); Assert.IsTrue(maze.All_ActiveEdges_Set().Count == 1); Assert.IsTrue(maze.All_InactiveEdges_InBounds_List().Count == 3); Assert.IsTrue(maze.All_InactiveEdges_InBounds_Set().Count == 3); maze.OP_AddEdge(new UEdge2i(top_left, top_right)); Assert.IsTrue(maze.IsFullyExpanded() == true); Assert.IsTrue(maze.IsFullyConnected() == false); Assert.IsTrue(maze.IsCyclic() == false); Assert.IsTrue(maze.Islands(rand).Count == 2); Assert.IsTrue(maze.All_ActiveEdges_List().Count == 2); Assert.IsTrue(maze.All_ActiveEdges_Set().Count == 2); Assert.IsTrue(maze.All_InactiveEdges_InBounds_List().Count == 2); Assert.IsTrue(maze.All_InactiveEdges_InBounds_Set().Count == 2); maze.OP_AddEdge(new UEdge2i(bottom_left, top_left)); Assert.IsTrue(maze.IsFullyExpanded() == true); Assert.IsTrue(maze.IsFullyConnected() == true); Assert.IsTrue(maze.IsCyclic() == false); Assert.IsTrue(maze.Islands(rand).Count == 1); Assert.IsTrue(maze.All_ActiveEdges_List().Count == 3); Assert.IsTrue(maze.All_ActiveEdges_Set().Count == 3); Assert.IsTrue(maze.All_InactiveEdges_InBounds_List().Count == 1); Assert.IsTrue(maze.All_InactiveEdges_InBounds_Set().Count == 1); maze.OP_AddEdge(new UEdge2i(bottom_right, top_right)); Assert.IsTrue(maze.IsFullyExpanded() == true); Assert.IsTrue(maze.IsFullyConnected() == true); Assert.IsTrue(maze.IsCyclic() == true); Assert.IsTrue(maze.Islands(rand).Count == 1); Assert.IsTrue(maze.All_ActiveEdges_List().Count == 4); Assert.IsTrue(maze.All_ActiveEdges_Set().Count == 4); Assert.IsTrue(maze.All_InactiveEdges_InBounds_List().Count == 0); Assert.IsTrue(maze.All_InactiveEdges_InBounds_Set().Count == 0); }
void ServerOrSingle_GeneratePuzzles( Vec2i pieceCount ) { ServerOrSingle_DestroyPuzzles(); ServerOrSingle_SetPieceCount( pieceCount ); for( int y = 0; y < pieceCount.Y; y++ ) for( int x = 0; x < pieceCount.X; x++ ) ServerOrSingle_CreatePiece( new Vec2i( x, y ) ); }
public MoveAnyPipeZone(Vec2i pos) : base(pos) { //-- }
public Vec2 GetPieceDestinationPosition( Vec2i index ) { //piece size is always 1,1 return new Vec2( .5f, .5f ) + index.ToVec2(); }
public Tile GetTile(Vec2i v) { return(GetTile(v.X, v.Y)); }