This commit is contained in:
CortexCore
2023-11-15 23:54:54 +08:00
parent ee3ecec6cb
commit 3c837a4a33
356 changed files with 73756 additions and 26493 deletions

View File

@@ -1,9 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using BITKit;
using UnityEngine.Events;
using UnityEngine.Pool;
using UnityEngine.UIElements;
namespace BITKit
{
@@ -17,16 +19,29 @@ namespace BITKit
private static VFXService sinleton;
public VFX[] vfxs;
private readonly Dictionary<string, UnityPool<Transform>> pools = new();
[SerializeField] private Optional<int> defaultCapacity;
private void Awake()
{
sinleton = this;
DI.Register(this);
}
public Transform Spawn(RaycastHit hit, params string[] keyWords)
{
return Spawn(new Location()
{
position = hit.point,
rotation = Quaternion.LookRotation(hit.normal),
forward = hit.normal,
}, keyWords);
}
public Transform Spawn(Location location, params string[] keyWords)
{
if (TryMatch(out var prefab, keyWords))
{
var pool = pools.Get(prefab.name);
if (defaultCapacity.Allow)
pool.DefaultCapacity = defaultCapacity.Value;
var instance = pool.Get(prefab, transform);
instance.SetPositionAndRotation(location, location);
if (location.forward.sqrMagnitude is not 0)