ManipulationService2D

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

This page documents the supported public API surface only. Private, internal, benchmark, test, and implementation-detail types are intentionally omitted.

Declaration

1
public class ManipulationService2D : IService, IManipulationService, IDisposable

Summary

Core service for manipulation-related business logic and state management. Follows Enhanced Service Registry pattern with dependency injection. Handles object manipulation operations like move, rotate, scale, and complex transformations.

OBSOLETE: This service is replaced by modern ECS manipulation systems. Use ManipulationSystem and related ECS systems for new development.

Metadata

Namespace: GridPlacement.Core.Services.Manipulation

Source File: cs/Core/Services/Manipulation/ManipulationService2D.cs

Assembly: GridPlacement.Core

Type: class

Implements

  • IDisposable
  • IManipulationService
  • IService

Constructors

ManipulationService2D

1
2
3
public ManipulationService2D(
    IConfigurationProvider<IManipulationConfiguration>? configProvider = null
)

Initializes a new instance of the ManipulationService2D.


Methods

StartManipulation

1
2
3
4
public ManipulationState StartManipulation(
    GridMode mode,
    CoreVector2I origin
)

Starts a new manipulation for the given mode and origin.

Parameters

NameDescription
modeThe manipulation mode to start.
originThe origin cell where the manipulation begins.

Returns

The created manipulation state.

Remarks

This method validates the input parameters and checks for existing manipulations at the same origin. If successful, it creates a new ManipulationState and registers it with the service.


UpdateManipulationTarget

1
2
3
4
public bool UpdateManipulationTarget(
    string manipulationId,
    CoreVector2I target
)

Updates the target cell for an active manipulation.

Parameters

NameDescription
manipulationIdThe ID of the manipulation to update.
targetThe new target cell.

Returns

True if the target was updated and the manipulation is still valid; otherwise false.

Remarks

This method checks if the manipulation is active and not completed, and then updates the target cell. It also validates the manipulation after updating the target.


CancelManipulation

1
public bool CancelManipulation(string manipulationId)

Cancels an active manipulation.

Parameters

NameDescription
manipulationIdThe ID of the manipulation to cancel.

Returns

True if the manipulation was cancelled; otherwise false.

Remarks

This method checks if the manipulation is active and not completed, and then cancels it.


CompleteManipulation

1
public bool CompleteManipulation(string manipulationId)

Completes an active manipulation after final validation.

Parameters

NameDescription
manipulationIdThe ID of the manipulation to complete.

Returns

True if completion succeeded; otherwise false.

Remarks

This method checks if the manipulation is active and not completed, and then completes it. It also validates the manipulation before completing it.


AddConstraint

1
2
3
4
public bool AddConstraint(
    string manipulationId,
    ManipulationConstraint constraint
)

Adds a constraint to an existing manipulation.

Parameters

NameDescription
manipulationIdThe ID of the manipulation.
constraintThe constraint to add.

Returns

True if the constraint was added; otherwise false.

Remarks

This method checks if the manipulation exists and the constraint is not null.


RemoveConstraint

1
2
3
4
public bool RemoveConstraint(
    string manipulationId,
    string constraintId
)

Removes a constraint from an existing manipulation.

Parameters

NameDescription
manipulationIdThe ID of the manipulation.
constraintIdThe ID of the constraint to remove.

Returns

True if the constraint was removed; otherwise false.

Remarks

This method checks if the manipulation exists and the constraint is found.


AddAction

1
2
3
4
public bool AddAction(
    string manipulationId,
    ActionDefinition action
)

Adds an action definition to an existing manipulation.

Parameters

NameDescription
manipulationIdThe ID of the manipulation.
actionThe action definition to add.

Returns

True if the action was added; otherwise false.

Remarks

This method checks if the manipulation exists and the action is not null.


RemoveAction

1
2
3
4
public bool RemoveAction(
    string manipulationId,
    string actionId
)

Removes an action definition from an existing manipulation.

Parameters

NameDescription
manipulationIdThe ID of the manipulation.
actionIdThe action identifier to remove.

Returns

True if the action was removed; otherwise false.

Remarks

This method checks if the manipulation exists and the action is found.


SetContextData

1
2
3
4
5
public bool SetContextData(
    string manipulationId,
    string key,
    object value
)

Sets arbitrary context data on a manipulation state.

Parameters

NameDescription
manipulationIdThe ID of the manipulation.
keyThe context key.
valueThe context value.

Returns

True if the data was set; otherwise false.

Remarks

This method checks if the manipulation exists.


GetContextData

1
2
3
4
5
public T GetContextData<T>(
    string manipulationId,
    string key,
    T defaultValue = default!
)

Gets typed context data from a manipulation state.

Type Parameters

NameDescription
TThe expected value type.

Parameters

NameDescription
manipulationIdThe ID of the manipulation.
keyThe context key.
defaultValueThe fallback value when the key is missing or the manipulation does not exist.

Returns

The stored value, or defaultValue.

Remarks

This method checks if the manipulation exists.


ApplyPreviewIntent

1
2
3
4
public bool ApplyPreviewIntent(
    string manipulationId,
    ManipulationAction action
)

GetPreviewTransform

1
public PreviewTransformModel? GetPreviewTransform(string manipulationId)

GetManipulation

1
public ManipulationState? GetManipulation(string manipulationId)

Gets the manipulation state by ID.

Parameters

NameDescription
manipulationIdThe manipulation identifier.

Returns

The manipulation state if found; otherwise null.


GetActiveManipulations

1
public IEnumerable<ManipulationState> GetActiveManipulations()

Gets all manipulations that are currently active and not completed.

Returns

An enumerable of active manipulations.


GetManipulationsByMode

1
public IEnumerable<ManipulationState> GetManipulationsByMode(GridMode mode)

Gets all manipulations currently in the specified mode.

Parameters

NameDescription
modeThe mode to filter by.

Returns

An enumerable of manipulations matching the given mode.


IsManipulationActive

1
public bool IsManipulationActive(string manipulationId)

Determines whether the specified manipulation is active and not completed.

Parameters

NameDescription
manipulationIdThe manipulation identifier.

Returns

True if active; otherwise false.


CanStartManipulation

1
2
3
4
public bool CanStartManipulation(
    GridMode mode,
    CoreVector2I origin
)

Determines whether a new manipulation can be started at the given origin.

Parameters

NameDescription
modeThe requested mode.
originThe requested origin cell.

Returns

True if a manipulation may be started; otherwise false.


ValidateManipulation

1
public bool ValidateManipulation(string manipulationId)

Validates the manipulation state and its constraints/actions.

Parameters

NameDescription
manipulationIdThe manipulation identifier.

Returns

True if the manipulation is valid; otherwise false.


ValidateManipulationState

1
public List<string> ValidateManipulationState(ManipulationState manipulation)

Produces a list of validation errors for the provided manipulation.

Parameters

NameDescription
manipulationThe manipulation to validate.

Returns

A list of validation error messages (empty when valid).


RegisterManipulation

1
public void RegisterManipulation(ManipulationState manipulation)

Registers a manipulation in the service’s internal state store.

Parameters

NameDescription
manipulationThe manipulation state to register.

UnregisterManipulation

1
public void UnregisterManipulation(string manipulationId)

Unregisters a manipulation by ID.

Parameters

NameDescription
manipulationIdThe manipulation identifier.

ClearAllManipulations

1
public void ClearAllManipulations()

Clears all registered manipulations.


Dispose

1
public void Dispose()

Releases all resources used by the ManipulationService2D.


Events

ManipulationStarted

1
public event EventHandler<ManipulationStartedEvent>? ManipulationStarted

Raised when a manipulation is started and the new ManipulationState is registered.

Remarks

Event handlers can inspect the ManipulationStartedEvent to get details about the started manipulation.


ManipulationUpdated

1
public event EventHandler<ManipulationUpdatedEvent>? ManipulationUpdated

Raised when an active manipulation updates its target.

Remarks

Event handlers can inspect the ManipulationUpdatedEvent to get details about the updated manipulation.


ManipulationCompleted

1
public event EventHandler<ManipulationCompletedEvent>? ManipulationCompleted

Raised when a manipulation successfully completes.

Remarks

Event handlers can inspect the ManipulationCompletedEvent to get details about the completed manipulation.


ManipulationCancelled

1
public event EventHandler<ManipulationCancelledEvent>? ManipulationCancelled

Raised when an active manipulation is cancelled.

Remarks

Event handlers can inspect the ManipulationCancelledEvent to get details about the cancelled manipulation.


ManipulationFailed

1
public event EventHandler<ManipulationFailedEvent>? ManipulationFailed

Raised when manipulation validation fails during update or completion.

Remarks

Event handlers can inspect the ManipulationFailedEvent to get details about the failed manipulation.