Esempio n. 1
0
        private static void PlaceAt(DesertDescription description, Point position)
        {
            ShapeData shapeData = new ShapeData();
            Point     origin    = new Point(position.X, position.Y + 2);

            WorldUtils.Gen(origin, new Shapes.Circle(24, 12), Actions.Chain(new Modifiers.Blotches(), new Actions.SetTile(53).Output(shapeData)));
            UnifiedRandom         genRand = WorldGen.genRand;
            ShapeData             data    = new ShapeData();
            int                   num     = description.Hive.Top - position.Y;
            int                   num2    = (genRand.Next(2) != 0) ? 1 : (-1);
            List <PathConnection> list    = new List <PathConnection>
            {
                new PathConnection(new Point(position.X + -num2 * 26, position.Y - 8), num2)
            };
            int num3 = genRand.Next(2, 4);

            for (int i = 0; i < num3; i++)
            {
                int num4 = (int)((float)(i + 1) / (float)num3 * (float)num) + genRand.Next(-8, 9);
                int num5 = num2 * genRand.Next(20, 41);
                int num6 = genRand.Next(18, 29);
                WorldUtils.Gen(position, new Shapes.Circle(num6 / 2, 3), Actions.Chain(new Modifiers.Offset(num5, num4), new Modifiers.Blotches(), new Actions.Clear().Output(data), new Actions.PlaceWall(187)));
                list.Add(new PathConnection(new Point(num5 + num6 / 2 * -num2 + position.X, num4 + position.Y), -num2));
                num2 *= -1;
            }
            WorldUtils.Gen(position, new ModShapes.OuterOutline(data), Actions.Chain(new Modifiers.Expand(1), new Modifiers.OnlyTiles(53), new Actions.SetTile(397), new Actions.PlaceWall(187)));
            GenShapeActionPair pair = new GenShapeActionPair(new Shapes.Rectangle(2, 4), Actions.Chain(new Modifiers.IsSolid(), new Modifiers.Blotches(), new Actions.Clear(), new Modifiers.Expand(1), new Actions.PlaceWall(187), new Modifiers.OnlyTiles(53), new Actions.SetTile(397)));

            for (int j = 1; j < list.Count; j++)
            {
                PathConnection pathConnection  = list[j - 1];
                PathConnection pathConnection2 = list[j];
                float          num7            = Math.Abs(pathConnection2.Position.X - pathConnection.Position.X) * 1.5f;
                for (float num8 = 0f; num8 <= 1f; num8 += 0.02f)
                {
                    Vector2 value  = new Vector2(pathConnection.Position.X + pathConnection.Direction * num7 * num8, pathConnection.Position.Y);
                    Vector2 value2 = new Vector2(pathConnection2.Position.X + pathConnection2.Direction * num7 * (1f - num8), pathConnection2.Position.Y);
                    Vector2 vector = Vector2.Lerp(pathConnection.Position, pathConnection2.Position, num8);
                    Vector2 value3 = Vector2.Lerp(value, vector, num8);
                    Vector2 value4 = Vector2.Lerp(vector, value2, num8);
                    WorldUtils.Gen(Vector2.Lerp(value3, value4, num8).ToPoint(), pair);
                }
            }
            WorldUtils.Gen(origin, new Shapes.Rectangle(new Rectangle(-29, -12, 58, 12)), Actions.Chain(new Modifiers.NotInShape(shapeData), new Modifiers.Expand(1), new Actions.PlaceWall(0)));
        }
Esempio n. 2
0
        private DataAddress PerformCommit(PathInfo pathInfo, DataAddress proposal)
        {
            IServiceAddress[] manSrvs = managerServers;

            // Fetch the path access object for the given name.
            PathAccess pathFile = GetPathAccess(pathInfo.PathName);

            IPath pathFunction;
            try {
                pathFunction = pathFile.Path;
            } catch (TypeLoadException e) {
                throw new CommitFaultException(String.Format("Type not found: {0}", e.Message));
            } catch (TypeInitializationException e) {
                throw new CommitFaultException(String.Format("Type instantiation exception: {0}", e.Message));
            } catch (AccessViolationException e) {
                throw new CommitFaultException(String.Format("Illegal Access exception: {0}", e.Message));
            }

            // Create the connection object (should be fairly lightweight)
            INetworkCache localNetCache = MachineState.GetCacheForManager(manSrvs);
            IPathConnection connection = new PathConnection(this, pathInfo, connector, manSrvs, localNetCache, serviceTracker);

            // Perform the commit,
            return pathFunction.Commit(connection, proposal);
        }
Esempio n. 3
0
        private void InitPath(PathInfo pathInfo)
        {
            IServiceAddress[] manSrvs = managerServers;

            // Fetch the path access object for the given name.
            PathAccess pathFile = GetPathAccess(pathInfo.PathName);

            IPath pathFunction;
            try {
                pathFunction = pathFile.Path;
            } catch (TypeLoadException e) {
                throw new CommitFaultException(String.Format("Type not found: {0}", e.Message));
            } catch (TypeInitializationException e) {
                throw new CommitFaultException(String.Format("Type instantiation exception: {0}", e.Message));
            } catch (AccessViolationException e) {
                throw new CommitFaultException(String.Format("Illegal Access exception: {0}", e.Message));
            }

            // Create the connection object (should be fairly lightweight)
            INetworkCache localNetCache = MachineState.GetCacheForManager(manSrvs);
            IPathConnection connection = new PathConnection(this, pathInfo, connector, manSrvs, localNetCache, serviceTracker);

            // Make an initial empty database for the path,
            // PENDING: We could keep a cached version of this image, but it's
            //   miniscule in size.
            NetworkTreeSystem treeSystem = new NetworkTreeSystem(connector, manSrvs, localNetCache, serviceTracker);
            treeSystem.NodeHeapMaxSize = 1*1024*1024;
            DataAddress emptyDbAddr = treeSystem.CreateDatabase();
            // Publish the empty state to the path,
            connection.Publish(emptyDbAddr);
            // Call the initialize function,
            pathFunction.Init(connection);
        }
Esempio n. 4
0
        private void InitPath(string pathName)
        {
            // Check the name given is valid,
            CheckPathNameValid(pathName);

            // Fetch the path access object for the given name. This will generate an
            // exception if the path doesn't exist or there is an error input the
            // configuration of the path.
            PathAccess pathAccess = GetPathAccess(pathName);

            IPath path;
            lock (pathAccess) {
                try {
                    path = pathAccess.Path;
                } catch (TypeLoadException e) {
                    throw new ApplicationException("Type not found: " + e.Message);
                } catch (TypeInitializationException e) {
                    throw new ApplicationException("Type instantiation exception: " + e.Message);
                } catch (UnauthorizedAccessException e) {
                    throw new ApplicationException("Unauthorized Access exception: " + e.Message);
                }
            }

            // Create the connection object (should be fairly lightweight)
            INetworkCache networkCache = ManagerCacheState.GetCache(managerAddress);
            IPathConnection connection = new PathConnection(this, pathName, connector, managerAddress, networkCache);

            // Call the initialize function,
            path.Init(connection);
        }