Exemplo n.º 1
0
    public void OnLMB(InputAction.CallbackContext context)
    {
        LMB = context.ReadValue <float>() == 1;
        if (snapped && LMB && context.started && placingObject && !(world.GridSpaceExists(placingObjPos)))
        {
            if (currPlacingObject.GetComponents <IActivatable>().Length != 0)
            {
                currPlacingObject.GetComponents <IActivatable>()[0].Activate();
            }

            placingObject                      = false;
            currPlacingObject.layer            = 7;
            currPlacingObject.transform.parent = blockContainer.transform;

            CommonProperties common = currPlacingObject.GetComponent <CommonProperties>();

            foreach (Vector3 relPos in AdjustFootprint(common.GetFootprint(), common.GetFacing())) //get adjusted footprint of placing object and add world positions to worldGrid
            {
                world.AddSpace(new GridSpace(placingObjPos + 10 * relPos, currPlacingObject));
            }

            common.SetTransparency(1f, BlendMode.Opaque);
            common.ResetTintColor();
            common.SetColliderEnabled(true);

            if (streakPlaceName == "")
            {
                currPlacingObject = null;
            }
            else
            {
                Direction dir = common.GetFacing();
                currPlacingObject = null;
                BuildObject(streakPlaceName, true, dir);
            }
        }
    }