예제 #1
0
        private AmlInputModel CreateAmlInput(BuildingParameters buildingParameters)
        {
            var amlInput = new AmlInputModel
            {
                Inputs = new Inputs
                {
                    Input1 = new InputParameters
                    {
                        Values = new List <List <string> >
                        {
                            // Order and number of your Web Service inputs might be different, change accordingly
                            new List <string>
                            {
                                "0",
                                buildingParameters.SurfaceArea.ToString(),
                                buildingParameters.WallArea.ToString(),
                                buildingParameters.RoofArea.ToString(),
                                buildingParameters.OverallHeight.ToString(),
                                "0",
                                buildingParameters.GlazingArea.ToString(),
                                "0",
                                "0",
                                "0"
                            }
                        }
                    }
                }
            };

            return(amlInput);
        }
예제 #2
0
        /// <summary>
        /// Rebuilds and writes the assembly to a destination, using the specified building parameters.
        /// </summary>
        /// <param name="parameters">The parameters to use for building the assembly image.</param>
        public void Write(BuildingParameters parameters)
        {
            var builder = new NetAssemblyBuilder(this, parameters);
            var context = new NetBuildingContext(builder);

            builder.Build(context);
            builder.UpdateOffsets(context);
            builder.UpdateReferences(context);
            builder.Write(new WritingContext(this, parameters.Writer, context));
        }
 public override void ProcessPacket(PasteBuildingSettingUpdate packet, NebulaConnection conn)
 {
     if (GameMain.galaxy.PlanetById(packet.PlanetId)?.factory != null)
     {
         BuildingParameters backup = BuildingParameters.clipboard;
         BuildingParameters.clipboard = packet.GetBuildingSettings();
         using (FactoryManager.IsIncomingRequest.On())
         {
             GameMain.galaxy.PlanetById(packet.PlanetId).factory.PasteBuildingSetting(packet.ObjectId);
         }
         BuildingParameters.clipboard = backup;
     }
 }
 public override void ProcessPacket(PasteBuildingSettingUpdate packet, NebulaConnection conn)
 {
     if (GameMain.galaxy.PlanetById(packet.PlanetId)?.factory != null)
     {
         BuildingParameters backup = BuildingParameters.clipboard;
         BuildingParameters.clipboard = packet.GetBuildingSettings();
         using (Multiplayer.Session.Factories.IsIncomingRequest.On())
         {
             // skip audio and realtimetip update
             BuildingParameters.clipboard.PasteToFactoryObject(packet.ObjectId, GameMain.galaxy.PlanetById(packet.PlanetId).factory);
         }
         BuildingParameters.clipboard = backup;
     }
 }
예제 #5
0
 public PasteBuildingSettingUpdate(int objectId, BuildingParameters clipboard, int planetId)
 {
     ObjectId        = objectId;
     Type            = clipboard.type;
     ItemId          = clipboard.itemId;
     ModelIndex      = clipboard.modelIndex;
     Yaw             = clipboard.yaw;
     RecipeType      = clipboard.recipeType;
     RecipeId        = clipboard.recipeId;
     FilterId        = clipboard.filterId;
     Mode0           = clipboard.mode0;
     Mode1           = clipboard.mode1;
     Mode2           = clipboard.mode2;
     Mode3           = clipboard.mode3;
     Parameters      = clipboard.parameters;
     InserterItemIds = clipboard.inserterItemIds;
     InserterLengths = clipboard.inserterLengths;
     InserterFilters = clipboard.inserterFilters;
     PlanetId        = planetId;
 }
        public BuildingParameters GetBuildingSettings()
        {
            BuildingParameters result = new BuildingParameters();

            result.type            = Type;
            result.itemId          = ItemId;
            result.modelIndex      = ModelIndex;
            result.yaw             = Yaw;
            result.recipeType      = RecipeType;
            result.recipeId        = RecipeId;
            result.filterId        = FilterId;
            result.mode0           = Mode0;
            result.mode1           = Mode1;
            result.mode2           = Mode2;
            result.mode3           = Mode3;
            result.parameters      = Parameters;
            result.inserterItemIds = InserterItemIds;
            result.inserterLengths = InserterLengths;
            result.inserterFilters = InserterFilters;
            return(result);
        }
예제 #7
0
        public BuildingParameters GetBuildingSettings()
        {
            BuildingParameters result = new BuildingParameters
            {
                type            = Type,
                itemId          = ItemId,
                modelIndex      = ModelIndex,
                yaw             = Yaw,
                recipeType      = RecipeType,
                recipeId        = RecipeId,
                filterId        = FilterId,
                mode0           = Mode0,
                mode1           = Mode1,
                mode2           = Mode2,
                mode3           = Mode3,
                parameters      = Parameters,
                inserterItemIds = InserterItemIds,
                inserterLengths = InserterLengths,
                inserterFilters = InserterFilters
            };

            return(result);
        }
예제 #8
0
        // POST api/heatingload
        public async Task <IHttpActionResult> Post([FromBody] BuildingParameters buildingParameters)
        {
            // TODO: add DI and extract all code, which gets the assessed heating load from controller to a service
            var url    = ConfigurationManager.AppSettings["aml.url"];
            var apiKey = ConfigurationManager.AppSettings["aml.apiKey"];

            // wraping payload with proper web service input model
            var amlInput = CreateAmlInput(buildingParameters);

            var content = JsonConvert.SerializeObject(amlInput,
                                                      new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            // composing request
            var amlRequest = CreateRequestMessage(url, apiKey, content);

            var result = await _client.SendAsync(amlRequest);

            if (result.StatusCode != HttpStatusCode.OK)
            {
                return(InternalServerError());
            }

            string resultContent = await result.Content.ReadAsStringAsync();

            JObject resultObject = JObject.Parse(resultContent);

            // TODO: ouch!
            // Schema of your Web Service output object might be different, change accordingly
            double heatingLoadValue = resultObject.SelectToken("Results.output1.value.Values[0][6]").Value <double>();

            HeatingLoad heatingLoadModel = CreateHeatingLoadResponse(heatingLoadValue, buildingParameters.SurfaceArea);

            return(Ok(heatingLoadModel));
        }
예제 #9
0
        /// <summary>
        /// Parse raw string data from the .yaml into a collection of Buildings
        /// </summary>
        /// <param name="unparsedBuildingData"></param>
        /// <returns></returns>
        private List <Building> ParseBuildingData(List <string> unparsedBuildingData)
        {
            List <Building> parsedBuildings = new List <Building>();

            BuildingParameters buildingInformation = CreateNewDataHolder();

            foreach (string buildingData in unparsedBuildingData)
            {
                string[] data = buildingData.Split(':');

                switch (data[0].TrimStart(new char[] { ' ', '-' }))
                {
                case "id":
                    if (data[1].TrimStart(new char[] { ' ' }).Equals("joulesAvailable"))
                    {
                        break;
                    }
                    EntityID id = (EntityID)Enum.Parse(typeof(EntityID), data[1]);
                    if (id != EntityID.FieldRation)
                    {
                        buildingInformation.ID = id;
                    }
                    break;

                case "temperature":
                    break;

                case "location_x":
                    buildingInformation.Location.X = int.Parse(data[1]);
                    break;

                case "location_y":
                    buildingInformation.Location.Y = int.Parse(data[1]);
                    break;

                case "rotationOrientation":
                    string rotation = data[1].Substring(2);
                    buildingInformation.Rotation = int.Parse(rotation);
                    break;

                case "storage":
                case "rottable":
                case "amounts":
                    break;

                case "connections":
                    buildingInformation.Connection = (Connection)int.Parse(data[1]);
                    break;

                case "other_values":
                    if (buildingInformation.ID != EntityID.None)
                    {
                        //assume complete object, add and create new holder
                        parsedBuildings.Add(BuildingFactory.CreateNew(buildingInformation));
                        buildingInformation = CreateNewDataHolder();
                    }
                    break;

                default:
                    break;
                }
            }

            return(parsedBuildings);
        }
예제 #10
0
 public NetAssemblyBuilder(WindowsAssembly assembly, BuildingParameters parameters)
     : base(assembly, parameters)
 {
     _sectionsTableBuilder = new SectionsTableBuilder(this);
     InitializeBluePrint();
 }
예제 #11
0
    protected override void Execute()
    {
        if (parameters == null)
        {
            parameters = GetComponent <BuildingParameters>();
        }

        if (m_ShapeBuilder == null)
        {
            m_ShapeBuilder = GetComponent <ShapeBuilder>();
        }

//        m_ShapeBuilder.ShapePreset = ShapeParameters.ShapePreset;
//        m_ShapeBuilder.RectangleWidth = ShapeParameters.RectangleWidth;
//        m_ShapeBuilder.RectangleDepth = ShapeParameters.RectangleDepth;
//        m_ShapeBuilder.CircleRadius = ShapeParameters.CircleRadius;
//        m_ShapeBuilder.CirclePoints = ShapeParameters.CirclePoints;
//        m_ShapeBuilder.RoundCoordinates = ShapeParameters.RoundCoordinates;
//        m_ShapeBuilder.HandleRadius = ShapeParameters.HandleRadius;
//        m_ShapeBuilder.HandleColor = ShapeParameters.HandleColor;
//        m_ShapeBuilder.HoveredHandleColor = ShapeParameters.HoveredHandleColor;
//        m_ShapeBuilder.SelectedHandleColor = ShapeParameters.SelectedHandleColor;
//        m_ShapeBuilder.LineDensity = ShapeParameters.LineDensity;
//        m_ShapeBuilder.LineColor = ShapeParameters.LineColor;
//        m_ShapeBuilder.HoveredLineColor = ShapeParameters.HoveredLineColor;
//        m_ShapeBuilder.Points = ShapeParameters.Points;

        if (m_ShapeBuilder.Points.Count < 3)
        {
            Debug.LogWarning("Stock polygon should have at least 3 points.");
            return;
        }

        BuildingParameters param = (BuildingParameters)parameters;

        int wallsCount = m_ShapeBuilder.Points.Count;

        for (int i = 0; i < wallsCount; i++)
        {
            Vector3 startPoint = m_ShapeBuilder.Points[i];
            Vector3 endPoint   = m_ShapeBuilder.Points[(i + 1) % wallsCount];

            Vector3    localPosition = new Vector3((startPoint.x + endPoint.x) / 2, 0f, (startPoint.z + endPoint.z) / 2);
            Quaternion localRotation = Quaternion.LookRotation(endPoint - startPoint, Vector3.up);
            Row        newRow        = CreateSymbol <Row>("wall", localPosition, localRotation, transform);
            newRow.Initialize(
                Mathf.RoundToInt(Vector3.Distance(startPoint, endPoint)),
                param.wallStyle,
                param.wallPattern
                );
            newRow.Generate();
        }

        double randomValue = param.Rand.NextDouble();

        if (HeightRemaining > 0)
        {
            PolygonStock nextStock = CreateSymbol <PolygonStock>("polygonBuilding", new Vector3(0, 1, 0), Quaternion.identity, transform);
            nextStock.Initialize(m_ShapeBuilder, HeightRemaining - 1);
            nextStock.Generate(param.buildDelay);
        }
        else
        {
//            Roof nextRoof = CreateSymbol<Roof>("roof", new Vector3(0, 1, 0), Quaternion.identity, transform);
//            nextRoof.Initialize(4, 4, HeightRemaining-1);
//            nextRoof.Generate(param.buildDelay);
        }
    }