Exemplo n.º 1
0
        protected override GameAction PrepareNextActionOverride(out JobStatus progress)
        {
            var action = new ConstructAction(m_mode, m_location, m_items);

            progress = JobStatus.Ok;
            return(action);
        }
Exemplo n.º 2
0
        private void OnDrawingPlaneDone(ConstructAction ca, bool success)
        {
            if (!success)
            {
                return;
            }
            frame.ShowPropertyDisplay("View");
            if (propertyTreeView != null)
            {
                propertyTreeView.SelectEntry(this);
            }
            Plane          pln = Plane.XYPlane;
            ConstructPlane cp  = ca as ConstructPlane;

            if (ca is ConstructPlane)
            {
                pln = (ca as ConstructPlane).ConstructedPlane;
            }
            else if (ca is ConstructTangentialPlane)
            {
                pln = (ca as ConstructTangentialPlane).ConstructedPlane;
            }
            else
            {
                return;
            }
            try
            {
                if (!Precision.IsPerpendicular(projection.Direction, pln.Normal, false))
                {
                    projection.DrawingPlane = pln;
                }
                else
                {
                    Frame.UIService.ShowMessageBox(StringTable.GetString("Error.DrawingPlane.Impossible"), StringTable.GetString("Errormessage.Title.InvalidInput"), MessageBoxButtons.OK);
                }
            }
            catch (ConstructPlane.ConstructPlaneException)
            {   // hat aus irgend einem Grund nicht geklappt
                Frame.UIService.ShowMessageBox(StringTable.GetString("Error.DrawingPlane.Impossible"), StringTable.GetString("Errormessage.Title.InvalidInput"), MessageBoxButtons.OK);
            }
            planeOrigin.Refresh();
            planeDirectionX.Refresh();
            planeDirectionY.Refresh();
            frame.ActiveView.InvalidateAll();
            frame.SetControlCenterFocus("View", null, false, false);
        }
Exemplo n.º 3
0
        ActionState ProcessAction(ConstructAction action)
        {
            if (this.ActionTicksUsed == 1)
            {
                this.ActionTotalTicks = 6;
            }

            if (this.ActionTicksUsed < this.ActionTotalTicks)
            {
                return(ActionState.Ok);
            }

            var obs = action.ItemObjectIDs.Select(oid => this.World.FindObject <ItemObject>(oid)).ToArray();

            var report = new ConstructActionReport(this, action.Mode);

            if (obs.Any(ob => ob == null))
            {
                SendFailReport(report, "object not found");
                return(ActionState.Fail);
            }

            if (obs.Length == 0)
            {
                SendFailReport(report, "no objects given");
                return(ActionState.Fail);
            }

            if (obs.Length != 1)
            {
                SendFailReport(report, "too many objects given");
                return(ActionState.Fail);
            }

            if (obs.Any(ob => ob.Location != this.Location))
            {
                SendFailReport(report, "objects somewhere else");
                return(ActionState.Fail);
            }

            var item = obs[0];

            var env = this.Environment;

            var td = env.GetTileData(action.Location);

            DirectionSet positioning;

            switch (action.Mode)
            {
            case ConstructMode.Floor:
                if (WorkHelpers.ConstructFloorTerrainFilter.Match(td) == false)
                {
                    SendFailReport(report, "unsuitable terrain");
                    return(ActionState.Fail);
                }

                if (WorkHelpers.ConstructFloorItemFilter.Match(item) == false)
                {
                    SendFailReport(report, "bad materials");
                    return(ActionState.Fail);
                }

                positioning = DirectionSet.Planar;

                break;

            case ConstructMode.Pavement:
                if (WorkHelpers.ConstructPavementTerrainFilter.Match(td) == false)
                {
                    SendFailReport(report, "unsuitable terrain");
                    return(ActionState.Fail);
                }

                if (WorkHelpers.ConstructPavementItemFilter.Match(item) == false)
                {
                    SendFailReport(report, "bad materials");
                    return(ActionState.Fail);
                }

                positioning = DirectionSet.Exact;

                break;

            case ConstructMode.Wall:
                if (WorkHelpers.ConstructWallTerrainFilter.Match(td) == false)
                {
                    SendFailReport(report, "unsuitable terrain");
                    return(ActionState.Fail);
                }

                if (WorkHelpers.ConstructWallItemFilter.Match(item) == false)
                {
                    SendFailReport(report, "bad materials");
                    return(ActionState.Fail);
                }

                if (env.GetContents(action.Location).Any())
                {
                    SendFailReport(report, "location not empty");
                    return(ActionState.Fail);
                }

                positioning = DirectionSet.Planar;

                break;

            default:
                throw new Exception();
            }

            if (this.Location.IsAdjacentTo(action.Location, positioning) == false)
            {
                SendFailReport(report, "bad location");
                return(ActionState.Fail);
            }



            foreach (var ob in obs)
            {
                ob.Destruct();
            }

            // ZZZ: TODO
            throw new Exception();

/*
 *                      switch (action.Mode)
 *                      {
 *                              case ConstructMode.Floor:
 *                                      td.TerrainID = TerrainID.BuiltFloor;
 *                                      td.TerrainMaterialID = item.MaterialID;
 *                                      break;
 *
 *                              case ConstructMode.Pavement:
 *                                      td.InteriorID = InteriorID.Pavement;
 *                                      td.InteriorMaterialID = item.MaterialID;
 *                                      break;
 *
 *                              case ConstructMode.Wall:
 *                                      td.InteriorID = InteriorID.BuiltWall;
 *                                      td.InteriorMaterialID = item.MaterialID;
 *                                      break;
 *
 *                              default:
 *                                      throw new Exception();
 *                      }
 *
 *                      env.SetTileData(action.Location, td);
 *
 *                      return ActionState.Done;
 */
        }
Exemplo n.º 4
0
 protected override GameAction PrepareNextActionOverride(out JobStatus progress)
 {
     var action = new ConstructAction(m_mode, m_location, m_items);
     progress = JobStatus.Ok;
     return action;
 }
Exemplo n.º 5
0
        ActionState ProcessAction(ConstructAction action)
        {
            if (this.ActionTicksUsed == 1)
                this.ActionTotalTicks = 6;

            if (this.ActionTicksUsed < this.ActionTotalTicks)
                return ActionState.Ok;

            var obs = action.ItemObjectIDs.Select(oid => this.World.FindObject<ItemObject>(oid)).ToArray();

            var report = new ConstructActionReport(this, action.Mode);

            if (obs.Any(ob => ob == null))
            {
                SendFailReport(report, "object not found");
                return ActionState.Fail;
            }

            if (obs.Length == 0)
            {
                SendFailReport(report, "no objects given");
                return ActionState.Fail;
            }

            if (obs.Length != 1)
            {
                SendFailReport(report, "too many objects given");
                return ActionState.Fail;
            }

            if (obs.Any(ob => ob.Location != this.Location))
            {
                SendFailReport(report, "objects somewhere else");
                return ActionState.Fail;
            }

            var item = obs[0];

            var env = this.Environment;

            var td = env.GetTileData(action.Location);

            DirectionSet positioning;

            switch (action.Mode)
            {
                case ConstructMode.Floor:
                    if (WorkHelpers.ConstructFloorTerrainFilter.Match(td) == false)
                    {
                        SendFailReport(report, "unsuitable terrain");
                        return ActionState.Fail;
                    }

                    if (WorkHelpers.ConstructFloorItemFilter.Match(item) == false)
                    {
                        SendFailReport(report, "bad materials");
                        return ActionState.Fail;
                    }

                    positioning = DirectionSet.Planar;

                    break;

                case ConstructMode.Pavement:
                    if (WorkHelpers.ConstructPavementTerrainFilter.Match(td) == false)
                    {
                        SendFailReport(report, "unsuitable terrain");
                        return ActionState.Fail;
                    }

                    if (WorkHelpers.ConstructPavementItemFilter.Match(item) == false)
                    {
                        SendFailReport(report, "bad materials");
                        return ActionState.Fail;
                    }

                    positioning = DirectionSet.Exact;

                    break;

                case ConstructMode.Wall:
                    if (WorkHelpers.ConstructWallTerrainFilter.Match(td) == false)
                    {
                        SendFailReport(report, "unsuitable terrain");
                        return ActionState.Fail;
                    }

                    if (WorkHelpers.ConstructWallItemFilter.Match(item) == false)
                    {
                        SendFailReport(report, "bad materials");
                        return ActionState.Fail;
                    }

                    if (env.GetContents(action.Location).Any())
                    {
                        SendFailReport(report, "location not empty");
                        return ActionState.Fail;
                    }

                    positioning = DirectionSet.Planar;

                    break;

                default:
                    throw new Exception();
            }

            if (this.Location.IsAdjacentTo(action.Location, positioning) == false)
            {
                SendFailReport(report, "bad location");
                return ActionState.Fail;
            }

            foreach (var ob in obs)
                ob.Destruct();

            // ZZZ: TODO
            throw new Exception();
            /*
            switch (action.Mode)
            {
                case ConstructMode.Floor:
                    td.TerrainID = TerrainID.BuiltFloor;
                    td.TerrainMaterialID = item.MaterialID;
                    break;

                case ConstructMode.Pavement:
                    td.InteriorID = InteriorID.Pavement;
                    td.InteriorMaterialID = item.MaterialID;
                    break;

                case ConstructMode.Wall:
                    td.InteriorID = InteriorID.BuiltWall;
                    td.InteriorMaterialID = item.MaterialID;
                    break;

                default:
                    throw new Exception();
            }

            env.SetTileData(action.Location, td);

            return ActionState.Done;
            */
        }