Ejemplo n.º 1
0
    public void DrawActorDebugGUI(VoosActor actor)
    {
        using (new Util.GUILayoutFrobArea(actor.transform.position, 100, 500))
        {
            PhotonView photonView = PhotonView.Get(actor);
            if (photonView == null)
            {
                return;
            }
            PlayerBody playerBody = actor.GetPlayerBody();
            //string pbodyInfo = playerBody == null ? "" : $"Claimed? {playerBody.IsClaimed()} ..play mode? {playerBody.GetIsClaimerPlaying()}";
            string color         = photonView.isMine ? "yellow" : "grey";
            string hash          = actor.GetName().Substring(0, 9);
            bool   locked        = actor.IsLockedByAnother() || actor.IsLockWantedLocally();
            string lockingString = locked ? " LOCKED" : "";
            string lastPos       = actor.unrel == null ? "" : actor.unrel.lastPosition.x.ToFourDecimalPlaces();
            GUILayout.Label($@"<color={color}>{actor.GetDisplayName()}
rot: {actor.GetRotation().ToFourDecimalPlaces()}
last unrel: {actor.lastUnreliableUpdateTime}
lastPX: {lastPos}</color>".Trim());
            GUILayout.Toggle(actor.GetReplicantCatchUpMode(), "Catchup?");
            actor.debug = GUILayout.Toggle(actor.debug, "Debug");
            // owner: {photonView.ownerId}{lockingString}
            // {hash} view {actor.reliablePhotonView.viewID}
            // X: {actor.transform.position.x.ToFourDecimalPlaces()}
            // lastRBMPX: {actor.lastRBMovedPos.x.ToFourDecimalPlaces()}
        }
    }
Ejemplo n.º 2
0
 public UndoState(VoosActor actor)
 {
     position      = actor.GetPosition();
     rotation      = actor.GetRotation();
     spawnPosition = actor.GetSpawnPosition();
     spawnRotation = actor.GetSpawnRotation();
 }
Ejemplo n.º 3
0
 private void ActorUpdate(VoosActor actor)
 {
     assetUI.header.text = $"{actor.GetDisplayName()} : Rotate";
     UpdateVec3Input(actor.GetRotation().eulerAngles, assetUI.currentInputs);
     UpdateVec3Input(actor.GetSpawnRotation().eulerAngles, assetUI.spawnInputs);
     UpdateVec3Input(actor.GetRenderableRotation().eulerAngles, assetUI.offsetInputs);
 }
Ejemplo n.º 4
0
    void SetActorPosition(VoosActor actor, Vector3 newPosition)
    {
        Vector3    currPosition = actor.GetPosition();
        Quaternion currRotation = actor.GetRotation();
        bool       autosetSpawn = AutosetSpawn();

        undoStack.PushUndoForActor(
            actor,
            $"Set actor position",
            (undoActor) =>
        {
            undoActor.SetPosition(newPosition);
            undoActor.SetRotation(currRotation);
            if (autosetSpawn)
            {
                undoActor.SetSpawnPositionRotationOfEntireFamily();
            }
        },
            (undoActor) =>
        {
            undoActor.SetPosition(currPosition);
            undoActor.SetRotation(currRotation);
            if (autosetSpawn)
            {
                undoActor.SetSpawnPositionRotationOfEntireFamily();
            }
        }
            );
    }
Ejemplo n.º 5
0
        internal void Update(Vector3 delta)
        {
            actor.SweepTo(delta + initialPosition);

            // Set both, for placing rolling physics objects.
            actor.SetSpawnPosition(actor.GetPosition());
            actor.SetSpawnRotation(actor.GetRotation());
        }
Ejemplo n.º 6
0
 public UndoState(VoosActor actor)
 {
     position      = actor.GetPosition();
     rotation      = actor.GetRotation();
     spawnPosition = actor.GetSpawnPosition();
     spawnRotation = actor.GetSpawnRotation();
     enablePhysics = actor.GetEnablePhysics();
 }
Ejemplo n.º 7
0
    private Transforms.TransformUndoState GetQuickRotateTransformState(VoosActor actor, Vector3 pivot)
    {
        Rigidbody targetRigidbody = actor.GetComponent <Rigidbody>();

        if (targetRigidbody != null)
        {
            targetRigidbody.angularVelocity = Vector3.zero;
        }

        Quaternion newRotation = actor.GetRotation() * Quaternion.Euler(0, QUICK_ROTATE_AMOUNT, 0);
        Vector3    diff        = actor.GetPosition() - pivot;
        Vector3    newPosition = Quaternion.AngleAxis(QUICK_ROTATE_AMOUNT, Vector3.up) * diff + pivot;

        return(new Transforms.TransformUndoState(newPosition, newRotation, actor.GetTransformParent()));
    }
Ejemplo n.º 8
0
    public void SetToPaste()
    {
        VoosActor focusActor = editMain.GetFocusedTargetActor();

        if (focusActor == null)
        {
            return;
        }

        containerNode.SetPositionAndRotation(focusActor.GetPosition(), focusActor.GetRotation());

        foreach (VoosActor actor in voosEngine.GetActorsAndDescendants(editMain.GetTargetActors()))
        {
            pastePreview[actor] = GetPreviewOfActor(actor);
        }

        mode = Mode.Paste;
    }
Ejemplo n.º 9
0
    void SetActorRotation(VoosActor actor, Vector3 vec)
    {
        Quaternion newRotation  = Quaternion.Euler(vec);
        Vector3    currPosition = actor.GetPosition();
        Quaternion currRotation = actor.GetRotation();

        undoStack.PushUndoForActor(
            actor,
            $"Set actor rotation",
            (undoActor) =>
        {
            undoActor.SetPosition(currPosition);
            undoActor.SetRotation(newRotation);
        },
            (undoActor) =>
        {
            undoActor.SetPosition(currPosition);
            undoActor.SetRotation(currRotation);
        }
            );
    }
Ejemplo n.º 10
0
    private GameObject GetPreviewOfActor(VoosActor actor)
    {
        GameObject actorRep = new GameObject("rep");

        actorRep.transform.parent = containerNode;

        actorRep.transform.position = actor.GetPosition();
        actorRep.transform.rotation = actor.GetRotation();

        Bounds _newbounds = new Bounds(actorRep.transform.position, Vector3.zero);

        foreach (MeshFilter mf in actor.gameObject.GetComponentsInChildren <MeshFilter>())
        {
            // TextMeshPro becomes unhappy when its meshes are assigned to another MeshFilter
            // (it stops updating the text), so skip TextMeshPro meshes...
            if (mf.GetComponent <TMPro.TextMeshPro>())
            {
                continue;
            }

            GameObject _newGameobject = new GameObject("copymesh");

            // Note: using mf.mesh instead of mf.sharedMesh, for reasons I don't understand,
            // causes a native crash in the EXE but not in the Unity Editor when copying
            // actors that have TextMeshPro components on them, even though we have the
            // guard above to prevent us from copying TextMeshPro objects. Using
            // mf.sharedMesh solved the problem.
            _newGameobject.AddComponent <MeshFilter>().mesh       = mf.sharedMesh;
            _newGameobject.AddComponent <MeshRenderer>().material = copyMaterial;

            _newGameobject.transform.SetParent(actorRep.transform);
            _newGameobject.transform.position   = mf.transform.position;
            _newGameobject.transform.rotation   = mf.transform.rotation;
            _newGameobject.transform.localScale = mf.transform.lossyScale;

            _newbounds.Encapsulate(_newGameobject.GetComponent <MeshRenderer>().bounds);
        }

        return(actorRep);
    }
    public override void ControllerLateUpdate()
    {
        mainTransform.position = cameraActor != null?cameraActor.GetPosition() : Vector3.zero;

        mainTransform.rotation = cameraActor != null?cameraActor.GetRotation() : Quaternion.identity;
    }
Ejemplo n.º 12
0
 public Vector3 GetMoveThrottle()
 {
     return(Quaternion.Inverse(actor.GetRotation()) * actor.GetDesiredVelocity());
 }
Ejemplo n.º 13
0
 Vector3 GetActorRotation(VoosActor actor)
 {
     return(actor.GetRotation().eulerAngles);
 }