84 lines
3.1 KiB
C#
84 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using Cal;
|
|
using ET.EventType;
|
|
|
|
namespace ET
|
|
{
|
|
public class SkillOptionFactoryComponentAwakeSystem : AwakeSystem<SkillOptionFactoryComponent>
|
|
{
|
|
public override void Awake(SkillOptionFactoryComponent self)
|
|
{
|
|
self.Awake();
|
|
}
|
|
}
|
|
public class SkillOptionFactoryComponentUpdateSystem : LoadSystem<SkillOptionFactoryComponent>
|
|
{
|
|
public override void Load(SkillOptionFactoryComponent self)
|
|
{
|
|
self.Load();
|
|
}
|
|
}
|
|
public class SkillOptionFactoryComponentDestroySystem : DestroySystem<SkillOptionFactoryComponent>
|
|
{
|
|
public override void Destroy(SkillOptionFactoryComponent self)
|
|
{
|
|
self.allBuffSystemTypes.Clear();
|
|
}
|
|
}
|
|
public static class SkillOptionFactorySystem
|
|
{
|
|
public class SkillOptionAquireInfo : AEvent<ET.EventType.UpdatePer1MinuteOfDay>
|
|
{
|
|
public override async ETTask Run(UpdatePer1MinuteOfDay args)
|
|
{
|
|
foreach (ReferencePoolInfo info in ReferencePool.GetAllReferencePoolInfos())
|
|
{
|
|
Log.Warning($"[{info.Type}] acq:{info.AcquireReferenceCount} release:{info.ReleaseReferenceCount} using:{info.UsingReferenceCount} unuse{info.UnusedReferenceCount}");
|
|
}
|
|
await ETTask.CompletedTask;
|
|
}
|
|
}
|
|
|
|
public static void Awake(this SkillOptionFactoryComponent self)
|
|
{
|
|
SkillOptionFactoryComponent.inatnce = self;
|
|
self.Load();
|
|
}
|
|
public static void Load(this SkillOptionFactoryComponent self)
|
|
{
|
|
self.allBuffSystemTypes.Clear();
|
|
ReferencePool.ClearAll();
|
|
Assembly assembly = typeof(SkillOptionLogic_伤害).Assembly;
|
|
Type[] types = assembly.GetTypes();
|
|
foreach (Type type in types)
|
|
{
|
|
if (type.IsSubclassOf(typeof(SkillOptionLogicBase)))
|
|
{
|
|
SkillOptionLogicBase t = System.Activator.CreateInstance(type) as SkillOptionLogicBase;
|
|
self.allBuffSystemTypes.TryAdd(t.skillOptionType, type);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public static SkillOptionLogicBase AcquireSkillOptionLogic(this SkillOptionFactoryComponent self,SkillOptionBase skillOption)
|
|
{
|
|
SkillOptionLogicBase skillOptionLogic = AcquireSkillOptionLogic(self,skillOption.optionType);
|
|
skillOptionLogic.skillOptionBase = skillOption;
|
|
return skillOptionLogic;
|
|
}
|
|
|
|
|
|
public static SkillOptionLogicBase AcquireSkillOptionLogic(this SkillOptionFactoryComponent self,SkillOptionType skillOptionType)
|
|
{
|
|
if (!self.allBuffSystemTypes.TryGetValue(skillOptionType, out Type type))
|
|
return null;
|
|
SkillOptionLogicBase skillOptionLogic = System.Activator.CreateInstance(type) as SkillOptionLogicBase;
|
|
//SkillOptionLogicBase skillOptionLogic = ReferencePool.Acquire(type) as SkillOptionLogicBase;
|
|
return skillOptionLogic;
|
|
}
|
|
}
|
|
}
|