Skip to content

Commit

Permalink
#479 fixed and augmented documentation of this feature's functions
Browse files Browse the repository at this point in the history
  • Loading branch information
m4xxed committed Oct 27, 2022
1 parent 5174f50 commit 8f9bb4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 7 additions & 5 deletions Assets/SEE/Controls/Actions/MarkAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
namespace SEE.Controls.Actions
{
/// <summary>
/// Action to visually mark/unmark a node as selected via a floating sphere above it.
/// Action to visually mark/unmark a node as selected via a sphere floating above it.
/// </summary>
internal class MarkAction : AbstractPlayerAction
{
/// <summary>
/// If the user clicks with the mouse hitting a game object representing a graph node,
/// the graphs selection status is toggled. Being selected means a sphere is floating above the node.
/// the node's marking status is toggled. Being marked means a sphere is floating above the node.
/// <see cref="ReversibleAction.Update"/>.
/// </summary>
/// <returns>true if completed</returns>
public override bool Update()
{
bool result = false;

// FIXME: Needs adaptation for VR where no mouse is available. (applies here too)
// FIXME: Needs adaptation for VR where no mouse is available.
if (Input.GetMouseButtonDown(0)
&& Raycasting.RaycastGraphElement(out RaycastHit raycastHit, out GraphElementRef _) == HitGraphElement.Node)
{
Expand All @@ -33,18 +33,20 @@ public override bool Update()

memento = new Memento(targetNode);

// propagate the MarkAction to other clients
new MarkNetAction(markerSphere).Execute();

// propagate (MarkNetAction)
// MarkAction completed successfully
result = true;

currentState = ReversibleAction.Progress.Completed;

}
return result;
}

/// <summary>
/// Memento capturing the data necessary to re-do this action.
/// Memento capturing the data necessary to re-do this marking action.
/// </summary>
private Memento memento;

Expand Down
11 changes: 6 additions & 5 deletions Assets/SEE/Game/GameNodeMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ public static GameObject TryMarking(GameObject targetNode)
// the position of the marker sphere is above the marked node
newMarkerSphere.transform.position = CalculateMarkerPosition(targetNode);

// ()FIXME?) ensure markers are not blocking us from unmarking or marking other nodes
// FIXME: check back with lead devs whether this consitutes desired behaviour
// ensure markers are not blocking us from unmarking or marking other nodes
newMarkerSphere.GetComponent<SphereCollider>().radius = 0;

newMarkerSphere.SetColor(Color.magenta);
// FIXME: marker color could be a configuration option
newMarkerSphere.SetColor(Color.green);

// marker spheres can be recognized by their name-prefix "MarkerSphere"
newMarkerSphere.name = "MarkerSphere" + targetNode.name;

// assign the marker sphere to the node it marks
// assign the marker sphere to the node it is marking
newMarkerSphere.transform.SetParent(targetNode.transform);

return newMarkerSphere;
Expand All @@ -73,12 +75,11 @@ public static GameObject TryMarking(GameObject targetNode)
/// <returns>The scale of the marker sphere.</returns>
private static Vector3 CalculateMarkerSize(GameObject targetNode)
{
// FUTURE REMINDER: base the size on lossyScale, not localScale -.-
// calculate the maximum ground area
float verticalLength = Math.Min(targetNode.transform.lossyScale.x,
targetNode.transform.lossyScale.z);

// return as a cube
// return the marker size as a cube
return Vector3.one * verticalLength;
}

Expand Down

0 comments on commit 8f9bb4c

Please sign in to comment.