refactor: Update Unity to 2022.3.62

This commit is contained in:
2025-06-21 01:22:02 +08:00
parent d71bf7d4a5
commit 283783954f
112 changed files with 778 additions and 907 deletions

View File

@@ -19,11 +19,11 @@ namespace Cryville.Crtr.Event {
public ushort Depth;
public Dictionary<EventContainer, ContainerState> Children
= new Dictionary<EventContainer, ContainerState>();
= new();
HashSet<EventContainer> ActiveChildren
= new HashSet<EventContainer>();
= new();
public Dictionary<Type, List<ContainerState>> TypedChildren
= new Dictionary<Type, List<ContainerState>>();
= new();
public ContainerState GetChild(int index, Type handlerType) {
var list = TypedChildren[handlerType];
@@ -110,8 +110,7 @@ namespace Cryville.Crtr.Event {
void AddChild(EventContainer c, ContainerState parent) {
parent.Children.Add(c, this);
Type t = c.GetType();
List<ContainerState> tc;
if (!parent.TypedChildren.TryGetValue(t, out tc))
if (!parent.TypedChildren.TryGetValue(t, out List<ContainerState> tc))
parent.TypedChildren.Add(t, tc = new List<ContainerState>());
tc.Add(this);
}
@@ -159,15 +158,13 @@ namespace Cryville.Crtr.Event {
if (dest.m_active) dest.Bus.NotifyActiveChanged(dest);
foreach (var mv in Values) {
RealtimeMotionValue dv;
if (dest.Values.TryGetValue(mv.Key, out dv)) mv.Value.CopyTo(dv, false);
if (dest.Values.TryGetValue(mv.Key, out RealtimeMotionValue dv)) mv.Value.CopyTo(dv, false);
else dest.Values.Add(mv.Key, mv.Value.Clone());
}
foreach (var cv in dest.CachedValues) cv.Value.Valid = false;
foreach (var cv in CachedValues) {
MotionCache dv;
if (!dest.CachedValues.TryGetValue(cv.Key, out dv)) {
if (!dest.CachedValues.TryGetValue(cv.Key, out MotionCache dv)) {
dest.CachedValues.Add(cv.Key, dv = dest._mcpa.Rent(cv.Key));
}
cv.Value.CopyTo(dv);
@@ -229,13 +226,12 @@ namespace Cryville.Crtr.Event {
#region Motion
readonly CategorizedPoolAccessor<int, RealtimeMotionValue> _rmvpa;
readonly CategorizedPoolAccessor<int, MotionCache> _mcpa;
Dictionary<StampedEvent, RealtimeMotionValue> PlayingMotions = new Dictionary<StampedEvent, RealtimeMotionValue>(4);
Dictionary<StampedEvent, RealtimeMotionValue> PlayingMotions = new(4);
IntKeyedDictionary<RealtimeMotionValue> Values;
IntKeyedDictionary<MotionCache> CachedValues;
void InvalidateMotion(int name) {
MotionCache cache;
if (!CachedValues.TryGetValue(name, out cache))
if (!CachedValues.TryGetValue(name, out MotionCache cache))
CachedValues.Add(name, cache = _mcpa.Rent(name));
cache.Valid = false;
foreach (var c in ActiveChildren)
@@ -243,8 +239,7 @@ namespace Cryville.Crtr.Event {
}
public Vector GetComputedValue(int key) {
MotionCache tr;
if (!CachedValues.TryGetValue(key, out tr))
if (!CachedValues.TryGetValue(key, out MotionCache tr))
CachedValues.Add(key, tr = _mcpa.Rent(key));
Vector r = tr.Value;
if (tr.Valid) return r;
@@ -322,8 +317,8 @@ namespace Cryville.Crtr.Event {
public void Discard(StampedEvent ev) {
Handler.Discard(this, ev);
if (ev is StampedEvent.RelativeMotion) {
ReturnRelativeMotionEvent((StampedEvent.RelativeMotion)ev);
if (ev is StampedEvent.RelativeMotion motion) {
ReturnRelativeMotionEvent(motion);
}
else if (ev.Origin is StampedEvent.RelativeMotion) {
ReturnEndRelativeMotionEvent((StampedEvent.Temporary)ev);
@@ -345,8 +340,7 @@ namespace Cryville.Crtr.Event {
_rmvpa.Return(mv);
}
}
else if (ev is StampedEvent.RelativeMotion) {
var tev = (StampedEvent.RelativeMotion)ev;
else if (ev is StampedEvent.RelativeMotion tev) {
var mv = _rmvpa.Rent(tev.Name);
mv.CloneTypeFlag = CloneType;
Values[tev.Name].CopyTo(mv, true);
@@ -369,13 +363,13 @@ namespace Cryville.Crtr.Event {
}
else if (ev.Origin != null) {
var oev = ev.Origin;
if (oev is StampedEvent.RelativeMotion) {
if (oev is StampedEvent.RelativeMotion motion) {
Update(ev);
var mv = PlayingMotions[oev];
if (mv.CloneTypeFlag == CloneType) _rmvpa.Return(mv);
PlayingMotions.Remove(oev);
ReturnEndRelativeMotionEvent((StampedEvent.Temporary)ev);
ReturnRelativeMotionEvent((StampedEvent.RelativeMotion)oev);
ReturnRelativeMotionEvent(motion);
}
else {
var nev = oev.Unstamped;
@@ -385,8 +379,7 @@ namespace Cryville.Crtr.Event {
if (mv.CloneTypeFlag == CloneType) _rmvpa.Return(mv);
PlayingMotions.Remove(oev);
}
else if (nev is EventContainer) {
var cev = (EventContainer)nev;
else if (nev is EventContainer cev) {
var ccs = Children[cev];
UpdateMotions();
ccs.LogicalActive = false;
@@ -455,8 +448,8 @@ namespace Cryville.Crtr.Event {
}
}
}
static readonly PropStores.Float _ttimest = new PropStores.Float();
static readonly PropStores.Vector4 _transst = new PropStores.Vector4();
static readonly PropStores.Float _ttimest = new();
static readonly PropStores.Vector4 _transst = new();
Vector4 GetTransition(float time, PdtExpression transition) {
if (time >= 1) return Vector4.one;
if (transition == null) return new Vector4(time, time, time, time);
@@ -495,9 +488,9 @@ namespace Cryville.Crtr.Event {
}
static readonly SimpleObjectPool<StampedEvent.RelativeMotion> relmEvPool
= new SimpleObjectPool<StampedEvent.RelativeMotion>(1024);
= new(1024);
static readonly SimpleObjectPool<StampedEvent.Temporary> erelmEvPool
= new SimpleObjectPool<StampedEvent.Temporary>(1024);
= new(1024);
public void PreAnchor() {
PushRelativeMotions(Handler.ns.Bus);
Handler.PreAnchor();