Description
The `RecreateMapObjects` field is a public instance field of type `System.Action` within the `MapObjectComponent` class. This field is intended to hold a delegate or lambda expression that can be invoked to recreate map objects within the scene. It is part of the `Sandbox` namespace and is used in the context of managing map-related components in a game environment.
Usage
To use the `RecreateMapObjects` field, you need to assign a method or lambda expression to it that defines the logic for recreating map objects. This can be useful in scenarios where you need to refresh or reset the map objects due to changes in the game state or environment.
### Example Usage
1. **Assigning a Method:**
```csharp
MapObjectComponent mapComponent = new MapObjectComponent();
mapComponent.RecreateMapObjects = MyRecreateMethod;
void MyRecreateMethod()
{
// Logic to recreate map objects
}
```
2. **Using a Lambda Expression:**
```csharp
MapObjectComponent mapComponent = new MapObjectComponent();
mapComponent.RecreateMapObjects = () => {
// Logic to recreate map objects
};
```
After assigning, you can invoke `RecreateMapObjects` to execute the assigned logic:
```csharp
mapComponent.RecreateMapObjects?.Invoke();
```
Example
MapObjectComponent mapComponent = new MapObjectComponent();
// Assign a method to the RecreateMapObjects action
mapComponent.RecreateMapObjects = () => {
// Logic to recreate map objects
// For example, clearing existing objects and generating new ones
};
// Invoke the action to recreate map objects
mapComponent.RecreateMapObjects?.Invoke();