This commit is contained in:
CortexCore
2025-03-09 13:38:23 +08:00
parent 8261a458e2
commit 18239a5ae4
67 changed files with 8573 additions and 831 deletions

View File

@@ -0,0 +1,19 @@
{
"name": "Net.Project.B.VFX.Unity",
"rootNamespace": "",
"references": [
"GUID:d525ad6bd40672747bde77962f1c401e",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:24866f14213d2124aa20be037476b521"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 21442fa5e0c49e3408652e96f6565891
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using BITKit;
using BITKit.Entities;
using Net.BITKit.Impact;
using UnityEngine;
namespace Net.BITKit.VFX
{
public class VFXService
{
private readonly IEntitiesService _entitiesService;
private readonly IReadOnlyCollection<ScriptableImpact> _scriptableImpacts;
public VFXService(IEntitiesService entitiesService)
{
_entitiesService = entitiesService;
_scriptableImpacts = _entitiesService.QueryComponents<ScriptableImpact>();
}
public AudioClip GetAudioClip(IReadOnlyCollection<string> tags)
{
var bestMatches = Search(tags);
return bestMatches.AudioClip;
}
public Transform GetPrefab(IReadOnlyCollection<string> tags)
{
var bestMatches = Search(tags);
return bestMatches.Prefab;
}
private ScriptableImpact Search(IReadOnlyCollection<string> tags)
{
var maxPoint = 0;
var max = new HashSet<ScriptableImpact>();
foreach (var impact in _scriptableImpacts)
{
var point = impact.Tags.Intersect(tags).Count();
if (point > maxPoint)
{
maxPoint = point;
max.Clear();
max.Add(impact);
}else if (point == maxPoint)
{
max.Add(impact);
}
}
if (max.Count is 1)
{
return max.First();
}
return max.OrderByDescending(x => x.Priority).First();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0bee817d1b196f842899232c3a28d504
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: