Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Merge patch-atomic-unity-flow-01-11-2025-1736629176 into dev #3737

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/kbve.com/src/content/journal/01-11.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ tags:

Then we can work around exactly how we want to handle some of the routes and concepts.

- **Unity**

04:01PM

I believe we are finishing up the abilities from where we last left off.

## 2024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,43 @@ public class DelayedObjectSpawner : MonoBehaviour
{
public MMObjectPooler objectPool;
public int millisToWait;
private CancellationTokenSource cancellationTokenSource;

// Start is called once before the first execution of Update after the MonoBehaviour is created
void OnEnable()
{
DoAfterSeconds(millisToWait, () => SetupPooledObject(objectPool.GetPooledGameObject()));
cancellationTokenSource = new CancellationTokenSource();
DoAfterSeconds(
millisToWait,
() => SetupPooledObject(objectPool.GetPooledGameObject()),
cancellationTokenSource.Token
);
}

private async UniTask DoAfterSeconds(int millisDelay, Action action)
void OnDisable()
{
Debug.Log("a");
await UniTask.Delay(millisDelay);
Debug.Log("b");
cancellationTokenSource?.Cancel();
cancellationTokenSource?.Dispose();
}

action.Invoke();
private async UniTask DoAfterSeconds(
int millisDelay,
Action action,
CancellationToken cancellationToken
)
{
try
{
await UniTask.Delay(millisDelay, cancellationToken: cancellationToken);
if (!cancellationToken.IsCancellationRequested)
{
action.Invoke();
}
}
catch (OperationCanceledException e)
{
Debug.Log("operation canceled exception: " + e.Message);
}
}

private void SetupPooledObject(GameObject pooledGameObject)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using UnityEngine;
using MoreMountains.TopDownEngine;
using UnityEngine;

namespace KBVE.MMExtensions.ObjectPool
{
public class ObjectWithHealthSpawner : ObjectSpawner
public class ObjectWithHealthSpawner : ObjectSpawner
{
protected override void SetupPooledObject(GameObject gameObject)
{
protected override void SetupPooledObject(GameObject gameObject)
{
base.SetupPooledObject(gameObject);
gameObject.GetComponent<Health>().Revive();
}
base.SetupPooledObject(gameObject);
gameObject.GetComponent<Health>().Revive();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using MoreMountains.Tools;
using MoreMountains.TopDownEngine;
using UnityEngine;

namespace KBVE.MMExtensions.ObjectPool
{
public class OnDeathObjectSpawner : MonoBehaviour
{
public Health health;
public MMObjectPooler objectPool;

// Start is called once before the first execution of Update after the MonoBehaviour is created
void OnEnable()
{
health.OnDeath += Health_OnDeath;
}

void OnDisable()
{
health.OnDeath -= Health_OnDeath;
}

private void Health_OnDeath()
{
SetupPooledObject(objectPool.GetPooledGameObject());
}

private void SetupPooledObject(GameObject pooledGameObject)
{
pooledGameObject.SetActive(true);
pooledGameObject.transform.position = gameObject.transform.position;
pooledGameObject.transform.rotation = Quaternion.identity;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions packages/mmextensions/mmextensions/Weapons/DyingProjectile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using MoreMountains.TopDownEngine;

namespace KBVE.MMExtensions.Weapons
{
public class DyingProjectile : Projectile
{
public Health health;

public override void Destroy()
{
if (health.CurrentHealth > 0)
{
health.Kill();
}
base.Destroy();
}
}
}
11 changes: 11 additions & 0 deletions packages/mmextensions/mmextensions/Weapons/DyingProjectile.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading