void UpdateFeedback(bool updateAll = false) { if (targetActor == null) { SetActor(null); return; } bool updateCurrentPosition = false; bool updateResetPosition = false; if (currentPosition != targetActor.transform.position) { updateCurrentPosition = true; } if (resetPosition != targetActor.GetSpawnPosition()) { updateResetPosition = true; } if (!updateAll && !updateResetPosition && !updateCurrentPosition) { return; } Bounds bounds = targetActor.ComputeWorldRenderBounds(); Vector3 bottomCenter = bounds.center - Vector3.up * bounds.extents.y; Vector3 bottomDelta = bottomCenter - targetActor.transform.position; if (updateCurrentPosition || updateAll) { currentPosition = targetActor.transform.position; Vector3 currentPositionWithBoundsOffset = currentPosition + bottomDelta; if (currentPositionWithBoundsOffset.y < .01f) { currentPositionWithBoundsOffset.y = .01f; } currentPositionTransform.position = currentPositionWithBoundsOffset; } if (updateResetPosition || updateAll) { resetPosition = targetActor.GetSpawnPosition(); Vector3 resetPositionWithBoundsOffset = currentPosition + bottomDelta; if (resetPositionWithBoundsOffset.y < .01f) { resetPositionWithBoundsOffset.y = .01f; } resetPositionTransform.position = resetPositionWithBoundsOffset; } Vector3 circleDelta = (currentPositionTransform.position - resetPositionTransform.position).normalized * CIRCLE_RADIUS; connectingLine.SetPosition(0, currentPositionTransform.position - circleDelta); connectingLine.SetPosition(1, resetPositionTransform.position + circleDelta); }
public UndoState(VoosActor actor) { position = actor.GetPosition(); rotation = actor.GetRotation(); spawnPosition = actor.GetSpawnPosition(); spawnRotation = actor.GetSpawnRotation(); }
void SetActorSpawnPosition(VoosActor actor, Vector3 newPosition, bool setParent = false, string spawnParent = null) { Vector3 currPosition = actor.GetSpawnPosition(); Quaternion currRotation = actor.GetSpawnRotation(); string currParent = actor.GetSpawnTransformParent(); undoStack.PushUndoForActor( actor, $"Set actor spawn position", (undoActor) => { undoActor.SetSpawnPosition(newPosition); undoActor.SetSpawnRotation(currRotation); if (setParent) { VoosActor setSpawnParent = undoActor.GetEngine().GetActor(spawnParent); undoActor.SetSpawnTransformParent(setSpawnParent?.GetName()); } }, (undoActor) => { undoActor.SetSpawnPosition(currPosition); undoActor.SetSpawnRotation(currRotation); if (setParent) { VoosActor setSpawnParent = undoActor.GetEngine().GetActor(currParent); undoActor.SetSpawnTransformParent(setSpawnParent?.GetName()); } } ); }
public UndoState(VoosActor actor) { position = actor.GetPosition(); rotation = actor.GetRotation(); spawnPosition = actor.GetSpawnPosition(); spawnRotation = actor.GetSpawnRotation(); enablePhysics = actor.GetEnablePhysics(); }
private void ActorUpdate(VoosActor actor) { assetUI.header.text = $"{actor.GetDisplayName()} : Move"; UpdateVec3Input(actor.GetPosition(), assetUI.currentInputs); UpdateVec3Input(actor.GetSpawnPosition(), assetUI.spawnInputs); UpdateVec3Input(actor.GetRenderableOffset(), assetUI.offsetInputs); VoosActor parent = actor.GetEngine().GetActor(actor.GetTransformParent()); assetUI.currentParentButtonText.text = parent != null?parent.GetDisplayName() : "<none>"; VoosActor spawnParent = actor.GetEngine().GetActor(actor.GetSpawnTransformParent()); assetUI.restartParentButtonText.text = spawnParent != null?spawnParent.GetDisplayName() : "<none>"; }
void SetActorSpawnRotation(VoosActor actor, Vector3 vec) { Quaternion newRotation = Quaternion.Euler(vec); Vector3 currPosition = actor.GetSpawnPosition(); Quaternion currRotation = actor.GetSpawnRotation(); undoStack.PushUndoForActor( actor, $"Set actor spawn rotation", (undoActor) => { undoActor.SetSpawnPosition(currPosition); undoActor.SetSpawnRotation(newRotation); }, (undoActor) => { undoActor.SetSpawnPosition(currPosition); undoActor.SetSpawnRotation(currRotation); } ); }