private void InitReferences()
    {
        builderInWorldBridge = InitialSceneReferences.i.builderInWorldBridge;
        cursorGO             = InitialSceneReferences.i.cursorCanvas;
        inputController      = InitialSceneReferences.i.inputController;

        List <GameObject> grounds = new List <GameObject>();

        for (int i = 0; i < InitialSceneReferences.i.groundVisual.transform.transform.childCount; i++)
        {
            grounds.Add(InitialSceneReferences.i.groundVisual.transform.transform.GetChild(i).gameObject);
        }
        groundVisualsGO = grounds.ToArray();

        context = new BIWContext();
        context.Init(
            outlinerController,
            inputHandler,
            inputWrapper,
            publishController,
            creatorController,
            modeController,
            floorHandler,
            entityHandler,
            actionController,
            saveController,
            raycastController,
            gizmosController,
            InitialSceneReferences.i
            );

        skyBoxMaterial = context.projectReferencesAsset.skyBoxMaterial;
    }
Esempio n. 2
0
    public override void Init(BIWContext context)
    {
        base.Init(context);
        cameraOutlinerMaterial = context.projectReferencesAsset.cameraOutlinerMaterial;

        entityHandler     = context.entityHandler;
        raycastController = context.raycastController;
    }
Esempio n. 3
0
 public virtual void Init(BIWContext context)
 {
     entityHandler                  = context.entityHandler;
     saveController                 = context.saveController;
     actionController               = context.actionController;
     raycastController              = context.raycastController;
     entityHandler.OnEntityDeleted += OnDeleteEntity;
 }
Esempio n. 4
0
    public override void Init(BIWContext context)
    {
        base.Init(context);

        lookAtT = new GameObject("BIWGodModeTransform").transform;
        maxDistanceToSelectEntitiesValue = context.godModeDynamicVariablesAsset.maxDistanceToSelectEntities;

        snapFactor = context.godModeDynamicVariablesAsset.snapFactor;
        snapRotationDegresFactor       = context.godModeDynamicVariablesAsset.snapRotationDegresFactor;
        snapScaleFactor                = context.godModeDynamicVariablesAsset.snapScaleFactor;
        snapDistanceToActivateMovement = context.godModeDynamicVariablesAsset.snapDistanceToActivateMovement;

        initialEagleCameraHeight       = context.godModeDynamicVariablesAsset.initialEagleCameraHeight;
        initialEagleCameraDistance     = context.godModeDynamicVariablesAsset.initialEagleCameraDistance;
        initialEagleCameraLookAtHeight = context.godModeDynamicVariablesAsset.initialEagleCameraLookAtHeight;

        snapDragFactor = context.godModeDynamicVariablesAsset.snapDragFactor;

        outlinerController = context.outlinerController;
        gizmoManager       = context.gizmosController;

        if (HUDController.i.builderInWorldMainHud != null)
        {
            HUDController.i.builderInWorldMainHud.OnTranslateSelectedAction      += TranslateMode;
            HUDController.i.builderInWorldMainHud.OnRotateSelectedAction         += RotateMode;
            HUDController.i.builderInWorldMainHud.OnScaleSelectedAction          += ScaleMode;
            HUDController.i.builderInWorldMainHud.OnSelectedObjectPositionChange += UpdateSelectionPosition;
            HUDController.i.builderInWorldMainHud.OnSelectedObjectRotationChange += UpdateSelectionRotation;
            HUDController.i.builderInWorldMainHud.OnSelectedObjectScaleChange    += UpdateSelectionScale;
            HUDController.i.builderInWorldMainHud.OnResetCameraAction            += ResetCamera;
            HUDController.i.builderInWorldMainHud.OnPublishAction += TakeSceneScreenshotForPublish;
        }

        if (context.sceneReferences.cameraController.TryGetCameraStateByType <FreeCameraMovement>(out CameraStateBase cameraState))
        {
            freeCameraController = (FreeCameraMovement)cameraState;
        }
        mouseCatcher     = context.sceneReferences.mouseCatcher;
        avatarRenderer   = context.sceneReferences.playerAvatarController;
        cameraController = context.sceneReferences.cameraController;

        BIWInputWrapper.OnMouseDown   += OnInputMouseDown;
        BIWInputWrapper.OnMouseUp     += OnInputMouseUp;
        BIWInputWrapper.OnMouseUpOnUI += OnInputMouseUpOnUi;
        BIWInputWrapper.OnMouseDrag   += OnInputMouseDrag;

        focusOnSelectedEntitiesInputAction = context.inputsReferencesAsset.focusOnSelectedEntitiesInputAction;
        multiSelectionInputAction          = context.inputsReferencesAsset.multiSelectionInputAction;

        focusOnSelectedEntitiesInputAction.OnTriggered += (o) => FocusOnSelectedEntitiesInput();

        multiSelectionInputAction.OnStarted  += (o) => ChangeSnapTemporaryActivated();
        multiSelectionInputAction.OnFinished += (o) => ChangeSnapTemporaryDeactivated();

        gizmoManager.OnChangeTransformValue      += EntitiesTransfromByGizmos;
        gizmoManager.OnGizmoTransformObjectEnd   += OnGizmosTransformEnd;
        gizmoManager.OnGizmoTransformObjectStart += OnGizmosTransformStart;
    }
Esempio n. 5
0
    public void SetReferences(BIWContext context)
    {
        creatorController = context.creatorController;

        entityHandler = context.entityHandler;

        modeController = context.modeController;

        AddListeners();
    }
Esempio n. 6
0
    public override void Init(BIWContext context)
    {
        base.Init(context);

        entityHandler  = context.entityHandler;
        modeController = context.modeController;
        gizmoMask      = BIWSettings.GIZMOS_LAYER;
        BIWInputWrapper.OnMouseDown += OnMouseDown;

        builderCamera = context.sceneReferences.mainCamera;
    }
    public override void Init(BIWContext context)
    {
        base.Init(context);

        entityHandler = context.entityHandler;
        floorHandler  = context.floorHandler;

        if (HUDController.i.builderInWorldMainHud == null)
        {
            return;
        }
        HUDController.i.builderInWorldMainHud.OnUndoAction += TryToUndoAction;
        HUDController.i.builderInWorldMainHud.OnRedoAction += TryToRedoAction;
    }
    public override void Init(BIWContext context)
    {
        base.Init(context);

        bridge = context.sceneReferences.builderInWorldBridge;
        if (bridge != null)
            bridge.OnKernelUpdated += TryToSave;

        if (HUDController.i.builderInWorldMainHud != null)
        {
            HUDController.i.builderInWorldMainHud.OnSaveSceneInfoAction += SaveSceneInfo;
            HUDController.i.builderInWorldMainHud.OnConfirmPublishAction += ConfirmPublishScene;
        }
    }
Esempio n. 9
0
    public override void Init(BIWContext context)
    {
        base.Init(context);
        actionController = context.actionController;

        entityHandler = context.entityHandler;

        creatorController = context.creatorController;
        saveController    = context.saveController;
        mainCamera        = context.sceneReferences.mainCamera;

        floorPrefab = context.projectReferencesAsset.floorPlaceHolderPrefab;

        entityHandler.OnEntityDeleted += OnFloorEntityDeleted;
    }
Esempio n. 10
0
    public override void Init(BIWContext biwContext)
    {
        base.Init(biwContext);

        modeController = biwContext.modeController;
        floorHandler   = biwContext.floorHandler;
        entityHandler  = biwContext.entityHandler;

        loadingObjectPrefab = biwContext.projectReferencesAsset.loadingPrefab;
        errorPrefab         = biwContext.projectReferencesAsset.errorPrefab;

        if (HUDController.i.builderInWorldMainHud != null)
        {
            HUDController.i.builderInWorldMainHud.OnCatalogItemSelected += OnCatalogItemSelected;
            HUDController.i.builderInWorldMainHud.OnCatalogItemDropped  += OnCatalogItemDropped;
        }
    }
    public override void Init(BIWContext context)
    {
        base.Init(context);
        if (HUDController.i.builderInWorldMainHud != null)
        {
            hudController = HUDController.i.builderInWorldMainHud;
            hudController.OnEntityDelete            += DeleteSingleEntity;
            hudController.OnDuplicateSelectedAction += DuplicateSelectedEntitiesInput;
            hudController.OnDeleteSelectedAction    += DeleteSelectedEntitiesInput;
            hudController.OnEntityClick             += ChangeEntitySelectionFromList;
            hudController.OnEntityLock                     += ChangeEntityLockStatus;
            hudController.OnEntityChangeVisibility         += ChangeEntityVisibilityStatus;
            hudController.OnEntityRename                   += SetEntityName;
            hudController.OnEntitySmartItemComponentUpdate += UpdateSmartItemComponentInKernel;
        }


        BIWInputWrapper.OnMouseDown += OnInputMouseDown;
        BIWInputWrapper.OnMouseUp   += OnInputMouseUp;

        DCL.Environment.i.world.sceneBoundsChecker.OnEntityBoundsCheckerStatusChanged += ChangeEntityBoundsCheckerStatus;

        bridge = context.sceneReferences.builderInWorldBridge;

        outlinerController = context.outlinerController;

        modeController    = context.modeController;
        actionController  = context.actionController;
        creatorController = context.creatorController;
        raycastController = context.raycastController;

        editMaterial = context.projectReferencesAsset.editMaterial;

        hideSelectedEntitiesAction = context.inputsReferencesAsset.hideSelectedEntitiesAction;
        showAllEntitiesAction      = context.inputsReferencesAsset.showAllEntitiesAction;

        hideSelectedEntitiesDelegate = (action) => ChangeShowStateSelectedEntities();
        showAllEntitiesDelegate      = (action) => ShowAllEntities();

        hideSelectedEntitiesAction.OnTriggered += hideSelectedEntitiesDelegate;
        showAllEntitiesAction.OnTriggered      += showAllEntitiesDelegate;

        actionController.OnRedo += ReSelectEntities;
        actionController.OnUndo += ReSelectEntities;
    }
    public override void Init(BIWContext context)
    {
        base.Init(context);
        gizmosGO = GameObject.Instantiate(context.projectReferencesAsset.gizmosPrefab, context.projectReferencesAsset.gizmosPrefab.transform.position, context.projectReferencesAsset.gizmosPrefab.transform.rotation);
        gizmos   = gizmosGO.GetComponentsInChildren <IBIWGizmos>(true);

        raycastController = context.raycastController;

        raycastController.OnGizmosAxisPressed += OnGizmosAxisPressed;
        BIWInputWrapper.OnMouseUp             += OnMouseUp;
        BIWInputWrapper.OnMouseDrag           += OnMouseDrag;
        if (context.sceneReferences.cameraController.TryGetCameraStateByType <FreeCameraMovement>(out CameraStateBase cameraState))
        {
            freeCameraMovement = (FreeCameraMovement)cameraState;
        }

        // NOTE(Adrian): Take into account that right now to get the relative scale of the gizmos, we set the gizmos in the player position and the camera
        InitializeGizmos(context.sceneReferences.mainCamera, freeCameraMovement.transform);
        ForceRelativeScaleRatio();
    }
Esempio n. 13
0
    public override void Init(BIWContext context)
    {
        base.Init(context);

        entityHandler     = context.entityHandler;
        creatorController = context.creatorController;

        if (HUDController.i?.builderInWorldMainHud != null)
        {
            HUDController.i.builderInWorldMainHud.OnPublishAction        += StartPublishFlow;
            HUDController.i.builderInWorldMainHud.OnConfirmPublishAction += StartPublishScene;
        }

        builderInWorldBridge = context.sceneReferences.builderInWorldBridge;

        if (builderInWorldBridge != null)
        {
            builderInWorldBridge.OnPublishEnd += PublishEnd;
        }
    }
Esempio n. 14
0
    public static BIWContext CreateMockUpReferenceController()
    {
        BIWContext context = new BIWContext();

        context.Init(
            Substitute.For <IBIWOutlinerController>(),
            Substitute.For <IBIWInputHandler>(),
            Substitute.For <IBIWInputWrapper>(),
            Substitute.For <IBIWPublishController>(),
            Substitute.For <IBIWCreatorController>(),
            Substitute.For <IBIWModeController>(),
            Substitute.For <IBIWFloorHandler>(),
            Substitute.For <IBIWEntityHandler>(),
            Substitute.For <IBIWActionController>(),
            Substitute.For <IBIWSaveController>(),
            Substitute.For <IBIWRaycastController>(),
            Substitute.For <IBIWGizmosController>(),
            new InitialSceneReferences()
            );
        return(context);
    }
    public override void Init(BIWContext biwContext)
    {
        base.Init(biwContext);

        actionController   = biwContext.actionController;
        modeController     = biwContext.modeController;
        inputWrapper       = biwContext.inputWrapper;
        outlinerController = biwContext.outlinerController;
        entityHandler      = biwContext.entityHandler;

        toggleRedoActionInputAction = biwContext.inputsReferencesAsset.toggleRedoActionInputAction;
        toggleUndoActionInputAction = biwContext.inputsReferencesAsset.toggleUndoActionInputAction;
        multiSelectionInputAction   = biwContext.inputsReferencesAsset.multiSelectionInputAction;

        if (HUDController.i.builderInWorldMainHud != null)
        {
            HUDController.i.builderInWorldMainHud.OnStopInput   += StopInput;
            HUDController.i.builderInWorldMainHud.OnResumeInput += ResumeInput;
        }

        redoDelegate = (action) => RedoAction();
        undoDelegate = (action) => UndoAction();

        toggleRedoActionInputAction.OnTriggered += redoDelegate;
        toggleUndoActionInputAction.OnTriggered += undoDelegate;

        multiSelectionStartDelegate    = (action) => StartMultiSelection();
        multiSelectionFinishedDelegate = (action) => EndMultiSelection();

        BIWInputWrapper.OnMouseClick     += MouseClick;
        BIWInputWrapper.OnMouseClickOnUI += MouseClickOnUI;
        modeController.OnInputDone       += InputDone;

        multiSelectionInputAction.OnStarted  += multiSelectionStartDelegate;
        multiSelectionInputAction.OnFinished += multiSelectionFinishedDelegate;
    }
    public override void Init(BIWContext context)
    {
        base.Init(context);
        maxDistanceToSelectEntitiesValue = context.firstPersonDynamicVariablesAsset.maxDistanceToSelectEntities;

        snapFactor = context.firstPersonDynamicVariablesAsset.snapFactor;
        snapRotationDegresFactor       = context.firstPersonDynamicVariablesAsset.snapRotationDegresFactor;
        snapScaleFactor                = context.firstPersonDynamicVariablesAsset.snapScaleFactor;
        snapDistanceToActivateMovement = context.firstPersonDynamicVariablesAsset.snapDistanceToActivateMovement;

        scaleSpeed    = context.firstPersonDynamicVariablesAsset.scaleSpeed;
        rotationSpeed = context.firstPersonDynamicVariablesAsset.rotationSpeed;
        distanceFromCameraForNewEntitties = context.firstPersonDynamicVariablesAsset.distanceFromCameraForNewEntitties;

        rotationHold = context.inputsReferencesAsset.firstPersonRotationHold;

        rotationHoldStartDelegate    = (action) => { shouldRotate = true; };
        rotationHoldFinishedDelegate = (action) => { shouldRotate = false; };

        rotationHold.OnStarted  += rotationHoldStartDelegate;
        rotationHold.OnFinished += rotationHoldFinishedDelegate;

        BIWInputWrapper.OnMouseClick += OnMouseClick;
    }
    public override void Init(BIWContext context)
    {
        base.Init(context);

        cursorGO = context.sceneReferences.cursorCanvas;
        cameraParentGO = context.sceneReferences.cameraParent;
        InitGameObjects();

        firstPersonMode = new BiwFirstPersonMode();
        godMode = new BiwGodMode();

        firstPersonMode.Init(context);
        godMode.Init(context);

        firstPersonMode.OnInputDone += InputDone;
        godMode.OnInputDone += InputDone;

        if (HUDController.i.builderInWorldMainHud != null)
        {
            HUDController.i.builderInWorldMainHud.OnChangeModeAction += ChangeAdvanceMode;
            HUDController.i.builderInWorldMainHud.OnResetAction += ResetScaleAndRotation;
            HUDController.i.builderInWorldMainHud.OnChangeSnapModeAction += ChangeSnapMode;
        }

        actionController = context.actionController;
        entityHandler = context.entityHandler;
        toggleSnapModeInputAction = context.inputsReferencesAsset.toggleSnapModeInputAction;

        snapModeDelegate = (action) => ChangeSnapMode();
        toggleSnapModeInputAction.OnTriggered += snapModeDelegate;

        firstPersonMode.OnActionGenerated += actionController.AddAction;
        godMode.OnActionGenerated += actionController.AddAction;

        SetEditorGameObjects();
    }
Esempio n. 18
0
 public virtual void Init(BIWContext context)
 {
     isEditModeActive = false;
 }
Esempio n. 19
0
    public static BIWContext CreateReferencesControllerWithGenericMocks(params object[] mocks)
    {
        IBIWOutlinerController outliner          = Substitute.For <IBIWOutlinerController>();
        IBIWInputHandler       inputHandler      = Substitute.For <IBIWInputHandler>();
        IBIWInputWrapper       inputWrapper      = Substitute.For <IBIWInputWrapper>();
        IBIWPublishController  publishController = Substitute.For <IBIWPublishController>();
        IBIWCreatorController  creatorController = Substitute.For <IBIWCreatorController>();
        IBIWModeController     modeController    = Substitute.For <IBIWModeController>();
        IBIWFloorHandler       floorHandler      = Substitute.For <IBIWFloorHandler>();
        IBIWEntityHandler      entityHandler     = Substitute.For <IBIWEntityHandler>();
        IBIWActionController   actionController  = Substitute.For <IBIWActionController>();
        IBIWSaveController     saveController    = Substitute.For <IBIWSaveController>();
        IBIWRaycastController  raycastController = Substitute.For <IBIWRaycastController>();
        IBIWGizmosController   gizmosController  = Substitute.For <IBIWGizmosController>();
        InitialSceneReferences sceneReferences   = new InitialSceneReferences();

        foreach (var mock in mocks)
        {
            switch (mock)
            {
            case IBIWOutlinerController oc:
                outliner = oc;
                break;

            case IBIWInputHandler ih:
                inputHandler = ih;
                break;

            case IBIWInputWrapper iw:
                inputWrapper = iw;
                break;

            case IBIWPublishController pc:
                publishController = pc;
                break;

            case IBIWCreatorController cc:
                creatorController = cc;
                break;

            case IBIWModeController mc:
                modeController = mc;
                break;

            case IBIWFloorHandler fh:
                floorHandler = fh;
                break;

            case IBIWEntityHandler eh:
                entityHandler = eh;
                break;

            case IBIWActionController ac:
                actionController = ac;
                break;

            case IBIWSaveController sc:
                saveController = sc;
                break;

            case IBIWRaycastController rc:
                raycastController = rc;
                break;

            case IBIWGizmosController gc:
                gizmosController = gc;
                break;

            case InitialSceneReferences isr:
                sceneReferences = isr;
                break;
            }
        }

        BIWContext context = new BIWContext();

        context.Init(
            outliner,
            inputHandler,
            inputWrapper,
            publishController,
            creatorController,
            modeController,
            floorHandler,
            entityHandler,
            actionController,
            saveController,
            raycastController,
            gizmosController,
            sceneReferences
            );
        return(context);
    }