示例#1
0
    private static void PlaceAndMoveAllInOneGo()
    {
        MakeSureThingBeingPlacedIsCorrect();
        if (StuffPlacer.GetThingBeingPlaced != null)
        {
            StuffPlacer.GetThingBeingPlaced.AddComponent <ObjectInfo>().ComponentType = SelectionMenu.SelectedComponentType;
        }
        StuffPlacer.RunStuffPlacing();
        //StuffPlacer.PlaceThingBeingPlaced(); // already called by RunStuffPlacing

        StuffPlacer.DeleteThingBeingPlaced();
    }
示例#2
0
    public static bool ShowPlacingGhost = true; // = Settings.Get("ShowPlacingGhost", true);

    public static void RunComponentPlacing()
    {
        if (Input.GetButtonDown("TogglePlacingGhost") && !Input.GetButton("Mod")) // holding mod is for toggling initial placing outline
        {
            ShowPlacingGhost = !ShowPlacingGhost;
            // Settings.Save("ShowPlacingGhost", ShowPlacingGhost);

            if (!ShowPlacingGhost)
            {
                StuffPlacer.DeleteThingBeingPlaced();
                StuffPlacer.RotationAboutUpVector = 0;
            }
        }

        if (Input.GetButtonDown("Place") && StuffPlacer.OkayToPlace) // run BEFORE RunStuffPlacing so we can actually get ThingBeingPlaced
        {
            StuffPlacer.GetThingBeingPlaced.AddComponent <ObjectInfo>().ComponentType = SelectionMenu.SelectedComponentType;
        }

        if (ShowPlacingGhost)
        {
            MakeSureThingBeingPlacedIsCorrect();
            StuffPlacer.RunStuffPlacing(true, true); // the booleans are AllowFineRotation and HideWhenInvalidPlacement
        }
        else
        {
            if (Input.GetButtonDown("Place"))
            {
                PlaceAndMoveAllInOneGo();
            }
        }

        // I have absolutely no idea why this is necessary. Sometimes when you rotate a mount it f***s up component placing by enabling the colliders. This fixes that.
        if (StuffPlacer.MostRecentNonNullHit.collider == null)
        {
            return;
        }
        if (FullComponent(StuffPlacer.MostRecentNonNullHit.collider) == StuffPlacer.GetThingBeingPlaced)
        {
            Debug.Log("did a terrible shitty hack");
            StuffPlacer.DeleteThingBeingPlaced();
        }
    }
    // handles the first person placing of boards. Run every frame while there is a board to be placed
    public static void RunBoardPlacing()
    {
        if (BoardBeingPlaced == null)
        {
            return;
        }

        if (Input.GetButtonDown("Delete") || Input.GetButtonDown("Cancel"))
        {
            CancelPlacement();
        }

        PollForInput();

        SetRotationState();
        ApplyPlacingOffset();

        if (Input.GetButtonDown("Place"))
        {
            PlaceBoard(); return;
        }
        StuffPlacer.RunStuffPlacing(false, false, true); // those bools are AllowFineRotation, HideWhenInvalidPlacement, and AllowEdgePlacement, respectively
    }