|
TopDown Engine v4.5
|
A class meant to spawn objects (usually item pickers, but not necessarily) The spawn can be triggered by any script, at any time, and comes with automatic hooks to trigger loot on damage or death. More...
Public Types | |
| enum | LootModes { Unique , LootTable , LootTableScriptableObject } |
| the possible modes by which loot can be defined More... | |
| enum | DimensionModes { TwoD , ThreeD } |
| the possible modes collision detection can operate on More... | |
Public Member Functions | |
| virtual void | ResetRemainingQuantity () |
| Resets the remaining quantity to the maximum quantity. | |
| virtual void | InitializeLootTable () |
| Computes the associated loot table's weights. | |
| virtual void | SpawnLoot () |
| This method spawns the specified loot after applying a delay (if there's one) | |
| virtual void | SpawnOneLoot () |
| Spawns a single loot object, without delay, and regardless of the defined quantities. | |
Public Attributes | |
| LootModes | LootMode = LootModes.Unique |
| GameObject | GameObjectToLoot |
| the object to loot, when in LootMode | |
| MMLootTableGameObject | LootTable |
| a loot table defining what objects to spawn | |
| MMLootTableGameObjectSO | LootTableSO |
| a loot table scriptable object defining what objects to spawn | |
| bool | SpawnLootOnDeath = true |
| if this is true, loot will happen when this object dies | |
| bool | SpawnLootOnDamage = false |
| if this is true, loot will happen when this object takes damage | |
| bool | PoolLoot = false |
| if this is true, lootables will be pooled | |
| int | PoolSize = 20 |
| determines the size of the pool for each object in the loot table | |
| string | MutualizedPoolName = "" |
| a unique name for this pool, has to be common between all Loot objects sharing the same loot table if you want to mutualize their pools | |
| bool | CanSpawn = true |
| if this is false, spawn won't happen | |
| float | Delay = 0f |
| a delay (in seconds) to wait for before spawning loot | |
| Vector2 | Quantity = Vector2.one |
| the minimum and maximum quantity of objects to spawn | |
| MMSpawnAroundProperties | SpawnProperties |
| the position, rotation and scale objects should spawn at | |
| bool | LimitedLootQuantity = true |
| if this is true, loot will be limited to MaximumQuantity, any new loot attempt beyond that will have no outcome. If this is false, loot is unlimited and can happen forever. | |
| int | MaximumQuantity = 100 |
| The maximum quantity of objects that can be looted from this Loot object. | |
| int | RemainingQuantity = 100 |
| The remaining quantity of objects that can be looted from this Loot object, displayed for debug purposes. | |
| bool | AvoidObstacles = false |
| Whether or not spawned objects should try and avoid obstacles. | |
| DimensionModes | DimensionMode = DimensionModes.TwoD |
| whether collision detection should happen in 2D or 3D | |
| LayerMask | AvoidObstaclesLayerMask = LayerManager.ObstaclesLayerMask |
| the layer mask containing layers the spawned objects shouldn't collide with | |
| float | AvoidRadius = 0.25f |
| the radius around the object within which no obstacle should be found | |
| int | MaxAvoidAttempts = 5 |
| the amount of times the script should try finding another position for the loot if the last one was within an obstacle. More attempts : better results, higher cost | |
| MMFeedbacks | LootFeedback |
| A MMFeedbacks to play when spawning loot. Only one feedback will play. If you want one per item, it's best to place it on the item itself, and have it play when the object gets instantiated. | |
| bool | DrawGizmos = false |
| if this is true, gizmos will be drawn to show the shape within which loot will spawn | |
| int | GizmosQuantity = 1000 |
| the amount of gizmos to draw | |
| Color | GizmosColor = MMColors.LightGray |
| the color the gizmos should be drawn with | |
| float | GimosSize = 1f |
| the size at which to draw the gizmos | |
| bool | SpawnLootButton |
| a debug button used to trigger a loot | |
Static Public Attributes | |
| static List< MMSimpleObjectPooler > | SimplePoolers = new List<MMSimpleObjectPooler>() |
| static List< MMMultipleObjectPooler > | MultiplePoolers = new List<MMMultipleObjectPooler>() |
Protected Member Functions | |
| virtual void | Awake () |
| On Awake we grab the health component if there's one, and initialize our loot table. | |
| virtual void | InitializePools () |
| virtual MMSimpleObjectPooler | FindSimplePooler () |
| virtual MMMultipleObjectPooler | FindMultiplePooler () |
| virtual void | SpawnLootDebug () |
| A debug method called by the inspector button. | |
| virtual IEnumerator | SpawnLootCo () |
| A coroutine used to spawn loot after a delay. | |
| virtual void | Spawn (GameObject gameObjectToSpawn) |
| virtual GameObject | GetObject () |
| Gets the object that should be spawned. | |
| virtual void | OnHit () |
| On hit, we spawn loot if needed. | |
| virtual void | OnDeath () |
| On death, we spawn loot if needed. | |
| virtual void | OnEnable () |
| OnEnable we start listening for death and hit if needed. | |
| virtual void | OnDisable () |
| OnDisable we stop listening for death and hit if needed. | |
| virtual void | OnDrawGizmos () |
| OnDrawGizmos, we display the shape at which objects will spawn when looted. | |
Static Protected Member Functions | |
| static void | InitializeStatics () |
Protected Attributes | |
| Health | _health |
| GameObject | _objectToSpawn |
| GameObject | _spawnedObject |
| Vector3 | _raycastOrigin |
| RaycastHit2D | _raycastHit2D |
| Collider[] | _overlapBox |
| MMSimpleObjectPooler | _simplePooler |
| MMMultipleObjectPooler | _multipleObjectPooler |
A class meant to spawn objects (usually item pickers, but not necessarily) The spawn can be triggered by any script, at any time, and comes with automatic hooks to trigger loot on damage or death.
|
protectedvirtual |
On Awake we grab the health component if there's one, and initialize our loot table.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
Gets the object that should be spawned.
|
virtual |
Computes the associated loot table's weights.
|
protectedvirtual |
|
staticprotected |
|
protectedvirtual |
On death, we spawn loot if needed.
|
protectedvirtual |
OnDisable we stop listening for death and hit if needed.
|
protectedvirtual |
OnDrawGizmos, we display the shape at which objects will spawn when looted.
|
protectedvirtual |
OnEnable we start listening for death and hit if needed.
|
protectedvirtual |
On hit, we spawn loot if needed.
|
virtual |
Resets the remaining quantity to the maximum quantity.
|
protectedvirtual |
|
virtual |
This method spawns the specified loot after applying a delay (if there's one)
|
protectedvirtual |
A coroutine used to spawn loot after a delay.
|
protectedvirtual |
A debug method called by the inspector button.
|
virtual |
Spawns a single loot object, without delay, and regardless of the defined quantities.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| bool MoreMountains.TopDownEngine.Loot.AvoidObstacles = false |
Whether or not spawned objects should try and avoid obstacles.
| LayerMask MoreMountains.TopDownEngine.Loot.AvoidObstaclesLayerMask = LayerManager.ObstaclesLayerMask |
the layer mask containing layers the spawned objects shouldn't collide with
| float MoreMountains.TopDownEngine.Loot.AvoidRadius = 0.25f |
the radius around the object within which no obstacle should be found
| bool MoreMountains.TopDownEngine.Loot.CanSpawn = true |
if this is false, spawn won't happen
| float MoreMountains.TopDownEngine.Loot.Delay = 0f |
a delay (in seconds) to wait for before spawning loot
| DimensionModes MoreMountains.TopDownEngine.Loot.DimensionMode = DimensionModes.TwoD |
whether collision detection should happen in 2D or 3D
| bool MoreMountains.TopDownEngine.Loot.DrawGizmos = false |
if this is true, gizmos will be drawn to show the shape within which loot will spawn
| GameObject MoreMountains.TopDownEngine.Loot.GameObjectToLoot |
the object to loot, when in LootMode
| float MoreMountains.TopDownEngine.Loot.GimosSize = 1f |
the size at which to draw the gizmos
| Color MoreMountains.TopDownEngine.Loot.GizmosColor = MMColors.LightGray |
the color the gizmos should be drawn with
| int MoreMountains.TopDownEngine.Loot.GizmosQuantity = 1000 |
the amount of gizmos to draw
| bool MoreMountains.TopDownEngine.Loot.LimitedLootQuantity = true |
if this is true, loot will be limited to MaximumQuantity, any new loot attempt beyond that will have no outcome. If this is false, loot is unlimited and can happen forever.
| MMFeedbacks MoreMountains.TopDownEngine.Loot.LootFeedback |
A MMFeedbacks to play when spawning loot. Only one feedback will play. If you want one per item, it's best to place it on the item itself, and have it play when the object gets instantiated.
| LootModes MoreMountains.TopDownEngine.Loot.LootMode = LootModes.Unique |
the selected loot mode :
| MMLootTableGameObject MoreMountains.TopDownEngine.Loot.LootTable |
a loot table defining what objects to spawn
| MMLootTableGameObjectSO MoreMountains.TopDownEngine.Loot.LootTableSO |
a loot table scriptable object defining what objects to spawn
| int MoreMountains.TopDownEngine.Loot.MaxAvoidAttempts = 5 |
the amount of times the script should try finding another position for the loot if the last one was within an obstacle. More attempts : better results, higher cost
| int MoreMountains.TopDownEngine.Loot.MaximumQuantity = 100 |
The maximum quantity of objects that can be looted from this Loot object.
|
static |
| string MoreMountains.TopDownEngine.Loot.MutualizedPoolName = "" |
a unique name for this pool, has to be common between all Loot objects sharing the same loot table if you want to mutualize their pools
| bool MoreMountains.TopDownEngine.Loot.PoolLoot = false |
if this is true, lootables will be pooled
| int MoreMountains.TopDownEngine.Loot.PoolSize = 20 |
determines the size of the pool for each object in the loot table
| Vector2 MoreMountains.TopDownEngine.Loot.Quantity = Vector2.one |
the minimum and maximum quantity of objects to spawn
| int MoreMountains.TopDownEngine.Loot.RemainingQuantity = 100 |
The remaining quantity of objects that can be looted from this Loot object, displayed for debug purposes.
|
static |
| bool MoreMountains.TopDownEngine.Loot.SpawnLootButton |
a debug button used to trigger a loot
| bool MoreMountains.TopDownEngine.Loot.SpawnLootOnDamage = false |
if this is true, loot will happen when this object takes damage
| bool MoreMountains.TopDownEngine.Loot.SpawnLootOnDeath = true |
if this is true, loot will happen when this object dies
| MMSpawnAroundProperties MoreMountains.TopDownEngine.Loot.SpawnProperties |
the position, rotation and scale objects should spawn at