/// <summary> /// Generate the fastest possible accessor for the given property. See more details on <see cref="MemberAccessor"/> /// </summary> internal static void DoGeneratePropertyAccessor(ref MemberAccessor accessor, MapItemInfo item, Converter parentItem, PropertyInfo property) { // All property optimizations rely on the parent being a reference-type. if (!parentItem.IsValueItemType) { // Value type property - Just support some basic primitives. if (item.IsValueTypeItem) { // Rationale: Generating an accessor for value types is very difficult, as JIT gen // for value types varies wildly and is too implementation-specific. Since this // is only designed to be a quick and dirty fast accessor anyway, it's easiest if // we only support the very basic primitives (which are very common anyway) // and nothing more. "MakeGenericMethod" is too expensive. bool successful = TryGenerateAccessorPrimitive(ref accessor, parentItem.ItemType, item.GetItemType(), property); if (successful) { return; } } // Reference type property - Simply force cast to "object". else { CreateAllRefTypeAccessor(ref accessor, parentItem.ItemType, item.GetItemType(), property); return; } } // Unoptimized accessor.Initialize(MemberAccessorType.SlowProperty, property, null); }
static void PopulateTypeInfo(ref ArrayTypeInfo info, MapItemInfo itemInfo, Type type) { int rank = type.GetArrayRank(); info.ElementType = itemInfo.GetItemType(); info.PerItem = itemInfo; if (type.IsSZArray) { info.FastConversion = GetFastType(info.ElementType); info.Type = ArrayType.SZArrayManual; //info.Type = info.FastConversion == FastConversionType.None ? ArrayType.SZArrayManual : ArrayType.SZArrayFast; } else if (rank == 1) { info.Rank = 1; info.Type = ArrayType.SNZArray; } else { if (rank == 32) { throw new Exception("ABSave does not support arrays with exactly 32 dimensions, only below."); } info.Rank = (byte)rank; info.Type = ArrayType.MultiDimensional; } }
internal MapItemInfo GetRuntimeMapItem(Type type) { MapGenerator?gen = GetGenerator(); MapItemInfo map = gen.GetRuntimeMap(type); ReleaseGenerator(gen); return(map); }
void SerializeItemNoSetup(object obj, MapItemInfo info, ref BitTarget header, bool skipHeader) { Converter item = info.Converter; ABSaveUtils.WaitUntilNotGenerating(item); SerializeConverter(obj, info.Converter, ref header, skipHeader); }
void SerializeActualType(object obj, Type type) { MapItemInfo info = GetRuntimeMapItem(type); var newTarget = new BitTarget(this); SerializeItemNoSetup(obj, info, ref newTarget, true); }
object DeserializeItemNoSetup(MapItemInfo info, bool skipHeader) { Converter item = info.Converter; ABSaveUtils.WaitUntilNotGenerating(item); return(DeserializeConverter(info.Converter, skipHeader)); }
public object DeserializeExactNonNullItem(MapItemInfo info) { _currentHeader = new BitSource() { Deserializer = this }; _readHeader = false; return(DeserializeItemNoSetup(info, true)); }
public void ResetStateWithMapFor(Type type) { ResetState(); var gen = CurrentMap.GetGenerator(); CurrentMapItem = gen.GetMap(type); ABSaveMap.ReleaseGenerator(gen); }
public void SerializePossibleNullableItem(object obj, MapItemInfo info, ref BitTarget header) { // Say it's "not null" if it is nullable. if (info.IsNullable) { header.WriteBitOn(); } SerializeItemNoSetup(obj, info, ref header, info.IsNullable); }
/// <summary> /// Insantiates the status at given position and sets the info (sprite, text). /// For now only used for player. /// </summary> public void ShowMapItem(Vector2 pWorldPosition, MapItemInfo pInfo) { if (pInfo.StatusSprite == null) { Debug.Log($"Map item has no status defined"); return; } ShowStatus(pWorldPosition, pInfo.StatusText, pInfo.StatusSprite); }
public object?DeserializeItem(MapItemInfo info, ref BitSource header) { // Do null checks if (!info.IsValueTypeItem && !header.ReadBit()) { return(null); } _currentHeader = header; _readHeader = true; return(DeserializeNullableItem(info, false)); }
public static Units CreateMapItem(MapItemInfo info, UnitControlType unitControlType = UnitControlType.None) { if (info == null) { return(null); } SkillUnitData vo = Singleton <SkillUnitDataMgr> .Instance.GetVo(info.uniTypeId); if (vo == null) { return(null); } Dictionary <DataType, object> dictionary = new Dictionary <DataType, object>(); dictionary.Add(DataType.NameId, info.uniTypeId); dictionary.Add(DataType.TeamType, (TeamType)info.group); if (info.unitId != 0) { dictionary.Add(DataType.UniqueId, info.unitId); } Units units; if (vo.IsBloodBall) { units = MapManager.Instance.SpawnBuffItem(dictionary, null, MoveController.SVectgor3ToVector3(info.burnPos), Quaternion.identity, unitControlType); } else { Units unit = MapManager.Instance.GetUnit(info.callUnitId); units = MapManager.Instance.SpawnSkillUnit(dictionary, null, MoveController.SVectgor3ToVector3(info.burnPos), Quaternion.identity, unitControlType, unit, info.callSkillId); HighEffectData vo2 = Singleton <HighEffectDataManager> .Instance.GetVo(info.hieffId); if (vo2 != null) { List <Units> list = new List <Units>(); if (info.targetUnitIds != null) { for (int i = 0; i < info.targetUnitIds.Count; i++) { Units unit2 = MapManager.Instance.GetUnit(info.targetUnitIds[i]); list.Add(unit2); } } BornUnitAction.SetPosition(units, list, unit, vo2, MoveController.SVectgor3ToVector3(info.burnPos)); } } if (units) { units.UpdateVisible(); } return(units); }
public void SerializeItem(object?obj, MapItemInfo item, ref BitTarget header) { if (obj == null) { header.WriteBitOff(); header.Apply(); } else { SerializePossibleNullableItem(obj, item, ref header); } }
public void SerializeItem(object?obj, MapItemInfo item) { if (obj == null) { WriteByte(0); } else { var currentHeader = new BitTarget(this); SerializePossibleNullableItem(obj, item, ref currentHeader); } }
object?DeserializeNullableItem(MapItemInfo info, bool skipHeader) { if (info.IsNullable) { EnsureReadHeader(); if (!_currentHeader.ReadBit()) { return(null); } skipHeader = true; } return(DeserializeItemNoSetup(info, skipHeader)); }
public object?DeserializeItem(MapItemInfo info) { // Do null checks if (info.IsValueTypeItem) { _currentHeader = new BitSource() { Deserializer = this }; _readHeader = false; } else { _currentHeader = new BitSource(this); if (!_currentHeader.ReadBit()) { return(null); } _readHeader = true; } return(DeserializeNullableItem(info, false)); }
public void SerializeExactNonNullItem(object obj, MapItemInfo item, ref BitTarget header) => SerializeItemNoSetup(obj, item, ref header, true);
public void SerializeExactNonNullItem(object obj, MapItemInfo item) { var currentHeader = new BitTarget(this); SerializeItemNoSetup(obj, item, ref currentHeader, true); }
public GenMap(object obj, MapItemInfo item) => (Obj, Item) = (obj, item);
public object DeserializeExactNonNullItem(MapItemInfo info, ref BitSource header) { _currentHeader = header; _readHeader = true; return(DeserializeItemNoSetup(info, true)); }