예제 #1
0
 public IActionResult Post([FromBody] FenceModel fence)
 {
     try
     {
         _fenceService.Add(fence.ToDomainModel());
         return(Ok());
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("PostFence", ex.StackTrace);
         return(BadRequest(ModelState));
     }
 }
        private void GenerateFence(LocationInstance location)
        {
            LocationEntranceGenerator locationEnteranceGenerator = new LocationEntranceGenerator(random, location.Shape);

            if (locationEnteranceGenerator.IsFenceGenerated)
            {
                FenceModel fence = rouletteWheelSelector.RouletteWheelSelection(location.Template.Fences);

                foreach (var borderTile in locationEnteranceGenerator.BorderTiles)
                {
                    AwaitingObject awaitingObject = new AwaitingObject()
                    {
                        AbstractObject = fence.GetFancePart(borderTile.NeighboursArray).AbstractObject,
                        Position       = new Vector2Float(borderTile.Position.X, borderTile.Position.Y)
                    };

                    location.Fence.Add(awaitingObject);
                    objectsMap.MarkTiles(borderTile.Position, ObjectsMap.ObjectType.Fance);
                }
            }
        }