/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is MUnitSaveData)) { return; } MUnitSaveData mData = (MUnitSaveData)data; this.id = mData.id; if (mData.cache != null) { this.cache = (MUnitCacheData)mData.cache.clone(); } else { this.cache = null; } if (mData.equips != null) { this.equips = (EquipContainerData)mData.equips.clone(); } else { this.equips = null; nullObjError("equips"); } this.mIndex = mData.mIndex; }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { this.id = 0; this.cache = null; this.equips = null; this.mIndex = 0; }
/// <summary> /// 初始化初值 /// </summary> public override void initDefault() { this.avatar = new UnitAvatarData(); this.avatar.initDefault(); this.fight = new UnitFightData(); this.fight.initDefault(); this.equips = new EquipContainerData(); this.equips.initDefault(); }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { this.id = 0; this.level = 0; this.avatar = null; this.fight = null; this.equips = null; this.mIndex = 0; this.isWorking = false; }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is MUnitSaveData)) { return; } MUnitSaveData mData = (MUnitSaveData)data; this.id = mData.id; this.cache = mData.cache; this.equips = mData.equips; this.mIndex = mData.mIndex; }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { base.toShadowCopy(data); if (!(data is EquipContainerData)) { return; } EquipContainerData mData = (EquipContainerData)data; this.equips = mData.equips; this.openSlots = mData.openSlots; }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { this.id = stream.readInt(); this.level = stream.readInt(); this.avatar = (UnitAvatarData)stream.readDataSimpleNotNull(); this.fight = (UnitFightData)stream.readDataSimpleNotNull(); this.equips = (EquipContainerData)stream.readDataSimpleNotNull(); this.mIndex = stream.readInt(); this.isWorking = stream.readBoolean(); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is MUnitUseData)) { return; } MUnitUseData mData = (MUnitUseData)data; this.id = mData.id; this.level = mData.level; if (mData.avatar != null) { this.avatar = (UnitAvatarData)mData.avatar.clone(); } else { this.avatar = null; nullObjError("avatar"); } if (mData.fight != null) { this.fight = (UnitFightData)mData.fight.clone(); } else { this.fight = null; nullObjError("fight"); } if (mData.equips != null) { this.equips = (EquipContainerData)mData.equips.clone(); } else { this.equips = null; nullObjError("equips"); } this.mIndex = mData.mIndex; this.isWorking = mData.isWorking; }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { this.id = stream.readInt(); if (stream.readBoolean()) { this.cache = (MUnitCacheData)stream.readDataSimpleNotNull(); } else { this.cache = null; } this.equips = (EquipContainerData)stream.readDataSimpleNotNull(); this.mIndex = stream.readInt(); }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is MUnitUseData)) { return; } MUnitUseData mData = (MUnitUseData)data; this.id = mData.id; this.level = mData.level; this.avatar = mData.avatar; this.fight = mData.fight; this.equips = mData.equips; this.mIndex = mData.mIndex; this.isWorking = mData.isWorking; }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { stream.startReadObj(); this.id = stream.readInt(); if (stream.readBoolean()) { BaseData cacheT = stream.readDataFullNotNull(); if (cacheT != null) { if (cacheT is MUnitCacheData) { this.cache = (MUnitCacheData)cacheT; } else { this.cache = new MUnitCacheData(); if (!(cacheT.GetType().IsAssignableFrom(typeof(MUnitCacheData)))) { stream.throwTypeReadError(typeof(MUnitCacheData), cacheT.GetType()); } this.cache.shadowCopy(cacheT); } } else { this.cache = null; } } else { this.cache = null; } BaseData equipsT = stream.readDataFullNotNull(); if (equipsT != null) { if (equipsT is EquipContainerData) { this.equips = (EquipContainerData)equipsT; } else { this.equips = new EquipContainerData(); if (!(equipsT.GetType().IsAssignableFrom(typeof(EquipContainerData)))) { stream.throwTypeReadError(typeof(EquipContainerData), equipsT.GetType()); } this.equips.shadowCopy(equipsT); } } else { this.equips = null; } this.mIndex = stream.readInt(); stream.endReadObj(); }
/// <summary> /// 初始化初值 /// </summary> public override void initDefault() { this.equips = new EquipContainerData(); this.equips.initDefault(); }
/// <summary> /// 是否数据一致 /// </summary> protected override bool toDataEquals(BaseData data) { if (!base.toDataEquals(data)) { return(false); } EquipContainerData mData = (EquipContainerData)data; if (mData.equips != null) { if (this.equips == null) { return(false); } if (this.equips.size() != mData.equips.size()) { return(false); } IntObjectMap <ItemData> equipsR = mData.equips; if (!this.equips.isEmpty()) { int equipsKFreeValue = this.equips.getFreeValue(); int[] equipsKKeys = this.equips.getKeys(); ItemData[] equipsVValues = this.equips.getValues(); for (int equipsKI = equipsKKeys.Length - 1; equipsKI >= 0; --equipsKI) { int equipsK = equipsKKeys[equipsKI]; if (equipsK != equipsKFreeValue) { ItemData equipsV = equipsVValues[equipsKI]; ItemData equipsU = equipsR.get(equipsK); if (equipsU != null) { if (equipsV == null) { return(false); } if (!equipsV.dataEquals(equipsU)) { return(false); } } else { if (equipsV != null) { return(false); } } } } } } else { if (this.equips != null) { return(false); } } if (mData.openSlots != null) { if (this.openSlots == null) { return(false); } if (this.openSlots.size() != mData.openSlots.size()) { return(false); } IntSet openSlotsR = mData.openSlots; if (!this.openSlots.isEmpty()) { int openSlotsVFreeValue = this.openSlots.getFreeValue(); int[] openSlotsVKeys = this.openSlots.getKeys(); for (int openSlotsVI = openSlotsVKeys.Length - 1; openSlotsVI >= 0; --openSlotsVI) { int openSlotsV = openSlotsVKeys[openSlotsVI]; if (openSlotsV != openSlotsVFreeValue) { if (!openSlotsR.contains(openSlotsV)) { return(false); } } } } } else { if (this.openSlots != null) { return(false); } } return(true); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { base.toCopy(data); if (!(data is EquipContainerData)) { return; } EquipContainerData mData = (EquipContainerData)data; if (mData.equips != null) { if (this.equips != null) { this.equips.clear(); this.equips.ensureCapacity(mData.equips.size()); } else { this.equips = new IntObjectMap <ItemData>(mData.equips.size()); } IntObjectMap <ItemData> equipsT = this.equips; if (!mData.equips.isEmpty()) { int equipsKFreeValue = mData.equips.getFreeValue(); int[] equipsKKeys = mData.equips.getKeys(); ItemData[] equipsVValues = mData.equips.getValues(); for (int equipsKI = equipsKKeys.Length - 1; equipsKI >= 0; --equipsKI) { int equipsK = equipsKKeys[equipsKI]; if (equipsK != equipsKFreeValue) { ItemData equipsV = equipsVValues[equipsKI]; int equipsW; ItemData equipsU; equipsW = equipsK; if (equipsV != null) { equipsU = (ItemData)equipsV.clone(); } else { equipsU = null; nullObjError("equipsU"); } equipsT.put(equipsW, equipsU); } } } } else { this.equips = null; nullObjError("equips"); } if (mData.openSlots != null) { if (this.openSlots != null) { this.openSlots.clear(); this.openSlots.ensureCapacity(mData.openSlots.size()); } else { this.openSlots = new IntSet(); } IntSet openSlotsT = this.openSlots; if (!mData.openSlots.isEmpty()) { int openSlotsVFreeValue = mData.openSlots.getFreeValue(); int[] openSlotsVKeys = mData.openSlots.getKeys(); for (int openSlotsVI = openSlotsVKeys.Length - 1; openSlotsVI >= 0; --openSlotsVI) { int openSlotsV = openSlotsVKeys[openSlotsVI]; if (openSlotsV != openSlotsVFreeValue) { int openSlotsU; openSlotsU = openSlotsV; openSlotsT.add(openSlotsU); } } } } else { this.openSlots = null; nullObjError("openSlots"); } }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { stream.startReadObj(); this.id = stream.readInt(); this.level = stream.readInt(); BaseData avatarT = stream.readDataFullNotNull(); if (avatarT != null) { if (avatarT is UnitAvatarData) { this.avatar = (UnitAvatarData)avatarT; } else { this.avatar = new UnitAvatarData(); if (!(avatarT.GetType().IsAssignableFrom(typeof(UnitAvatarData)))) { stream.throwTypeReadError(typeof(UnitAvatarData), avatarT.GetType()); } this.avatar.shadowCopy(avatarT); } } else { this.avatar = null; } BaseData fightT = stream.readDataFullNotNull(); if (fightT != null) { if (fightT is UnitFightData) { this.fight = (UnitFightData)fightT; } else { this.fight = new UnitFightData(); if (!(fightT.GetType().IsAssignableFrom(typeof(UnitFightData)))) { stream.throwTypeReadError(typeof(UnitFightData), fightT.GetType()); } this.fight.shadowCopy(fightT); } } else { this.fight = null; } BaseData equipsT = stream.readDataFullNotNull(); if (equipsT != null) { if (equipsT is EquipContainerData) { this.equips = (EquipContainerData)equipsT; } else { this.equips = new EquipContainerData(); if (!(equipsT.GetType().IsAssignableFrom(typeof(EquipContainerData)))) { stream.throwTypeReadError(typeof(EquipContainerData), equipsT.GetType()); } this.equips.shadowCopy(equipsT); } } else { this.equips = null; } this.mIndex = stream.readInt(); this.isWorking = stream.readBoolean(); stream.endReadObj(); }
protected override void toSetData(FuncToolData data) { base.toSetData(data); _data = (EquipContainerData)data; }