protected override void onEnter() { base.onEnter(); int[] keys = _playerEventListenerDic.getKeys(); EventAction[] values = _playerEventListenerDic.getValues(); int fv = _playerEventListenerDic.getFreeValue(); int k; EventAction v; for (int i = keys.Length - 1; i >= 0; --i) { if ((k = keys[i]) != fv) { v = values[i]; _eventListenerList.add(me.addListener(k, v)); if (_needCallListenerOnEnter) { v.execute(null); } } } }
/// <summary> /// 派发消息 /// </summary> public void dispatch(int type, T data = default(T)) { IntObjectMap <BaseEventAction> dic = _listenerDic.get(type); if (dic == null) { return; } int[] keys = dic.getKeys(); BaseEventAction[] values = dic.getValues(); int fv = dic.getFreeValue(); int k; int safeIndex = dic.getLastFreeIndex(); for (int i = safeIndex - 1; i != safeIndex; --i) { if (i < 0) { i = values.Length; } else if ((k = keys[i]) != fv) { values[i].execute(data); if (k != keys[i]) { ++i; } } } if (data != null && data is IEvt) { ((IEvt)data).clear(); } }
/// <summary> /// 转文本输出 /// </summary> protected override void toWriteDataString(DataWriter writer) { writer.writeTabs(); writer.sb.Append("funcTools"); writer.sb.Append(':'); writer.sb.Append("Map<int,IntObjectMap<FuncToolData>>"); if (this.funcTools != null) { writer.sb.Append('('); writer.sb.Append(this.funcTools.size()); writer.sb.Append(')'); writer.writeEnter(); writer.writeLeftBrace(); if (!this.funcTools.isEmpty()) { int funcToolsKFreeValue = this.funcTools.getFreeValue(); int[] funcToolsKKeys = this.funcTools.getKeys(); IntObjectMap <FuncToolData>[] funcToolsVValues = this.funcTools.getValues(); for (int funcToolsKI = funcToolsKKeys.Length - 1; funcToolsKI >= 0; --funcToolsKI) { int funcToolsK = funcToolsKKeys[funcToolsKI]; if (funcToolsK != funcToolsKFreeValue) { IntObjectMap <FuncToolData> funcToolsV = funcToolsVValues[funcToolsKI]; writer.writeTabs(); writer.sb.Append(funcToolsK); writer.sb.Append(':'); writer.sb.Append("Map<int,FuncToolData>"); if (funcToolsV != null) { writer.sb.Append('('); writer.sb.Append(funcToolsV.size()); writer.sb.Append(')'); writer.writeEnter(); writer.writeLeftBrace(); if (!funcToolsV.isEmpty()) { int funcToolsVKFreeValue = funcToolsV.getFreeValue(); int[] funcToolsVKKeys = funcToolsV.getKeys(); FuncToolData[] funcToolsVVValues = funcToolsV.getValues(); for (int funcToolsVKI = funcToolsVKKeys.Length - 1; funcToolsVKI >= 0; --funcToolsVKI) { int funcToolsVK = funcToolsVKKeys[funcToolsVKI]; if (funcToolsVK != funcToolsVKFreeValue) { FuncToolData funcToolsVV = funcToolsVVValues[funcToolsVKI]; writer.writeTabs(); writer.sb.Append(funcToolsVK); writer.sb.Append(':'); if (funcToolsVV != null) { funcToolsVV.writeDataString(writer); } else { writer.sb.Append("FuncToolData=null"); } writer.writeEnter(); } } } writer.writeRightBrace(); } else { writer.sb.Append("=null"); } writer.writeEnter(); } } } writer.writeRightBrace(); } else { writer.sb.Append("=null"); } writer.writeEnter(); writer.writeTabs(); writer.sb.Append("funcOpenSet"); writer.sb.Append(':'); writer.sb.Append("Set<int>"); if (this.funcOpenSet != null) { writer.sb.Append('('); writer.sb.Append(this.funcOpenSet.size()); writer.sb.Append(')'); writer.writeEnter(); writer.writeLeftBrace(); if (!this.funcOpenSet.isEmpty()) { int funcOpenSetVFreeValue = this.funcOpenSet.getFreeValue(); int[] funcOpenSetVKeys = this.funcOpenSet.getKeys(); for (int funcOpenSetVI = funcOpenSetVKeys.Length - 1; funcOpenSetVI >= 0; --funcOpenSetVI) { int funcOpenSetV = funcOpenSetVKeys[funcOpenSetVI]; if (funcOpenSetV != funcOpenSetVFreeValue) { writer.writeTabs(); writer.sb.Append(funcOpenSetV); writer.writeEnter(); } } } writer.writeRightBrace(); } else { writer.sb.Append("=null"); } writer.writeEnter(); }
/// <summary> /// 是否数据一致 /// </summary> protected override bool toDataEquals(BaseData data) { FuncPartData mData = (FuncPartData)data; if (mData.funcTools != null) { if (this.funcTools == null) { return(false); } if (this.funcTools.size() != mData.funcTools.size()) { return(false); } IntObjectMap <IntObjectMap <FuncToolData> > funcToolsR = mData.funcTools; if (!this.funcTools.isEmpty()) { int funcToolsKFreeValue = this.funcTools.getFreeValue(); int[] funcToolsKKeys = this.funcTools.getKeys(); IntObjectMap <FuncToolData>[] funcToolsVValues = this.funcTools.getValues(); for (int funcToolsKI = funcToolsKKeys.Length - 1; funcToolsKI >= 0; --funcToolsKI) { int funcToolsK = funcToolsKKeys[funcToolsKI]; if (funcToolsK != funcToolsKFreeValue) { IntObjectMap <FuncToolData> funcToolsV = funcToolsVValues[funcToolsKI]; IntObjectMap <FuncToolData> funcToolsU = funcToolsR.get(funcToolsK); if (funcToolsU != null) { if (funcToolsV == null) { return(false); } if (funcToolsV.size() != funcToolsU.size()) { return(false); } IntObjectMap <FuncToolData> funcToolsVR = funcToolsU; if (!funcToolsV.isEmpty()) { int funcToolsVKFreeValue = funcToolsV.getFreeValue(); int[] funcToolsVKKeys = funcToolsV.getKeys(); FuncToolData[] funcToolsVVValues = funcToolsV.getValues(); for (int funcToolsVKI = funcToolsVKKeys.Length - 1; funcToolsVKI >= 0; --funcToolsVKI) { int funcToolsVK = funcToolsVKKeys[funcToolsVKI]; if (funcToolsVK != funcToolsVKFreeValue) { FuncToolData funcToolsVV = funcToolsVVValues[funcToolsVKI]; FuncToolData funcToolsVU = funcToolsVR.get(funcToolsVK); if (funcToolsVU != null) { if (funcToolsVV == null) { return(false); } if (!funcToolsVV.dataEquals(funcToolsVU)) { return(false); } } else { if (funcToolsVV != null) { return(false); } } } } } } else { if (funcToolsV != null) { return(false); } } } } } } else { if (this.funcTools != null) { return(false); } } if (mData.funcOpenSet != null) { if (this.funcOpenSet == null) { return(false); } if (this.funcOpenSet.size() != mData.funcOpenSet.size()) { return(false); } IntSet funcOpenSetR = mData.funcOpenSet; if (!this.funcOpenSet.isEmpty()) { int funcOpenSetVFreeValue = this.funcOpenSet.getFreeValue(); int[] funcOpenSetVKeys = this.funcOpenSet.getKeys(); for (int funcOpenSetVI = funcOpenSetVKeys.Length - 1; funcOpenSetVI >= 0; --funcOpenSetVI) { int funcOpenSetV = funcOpenSetVKeys[funcOpenSetVI]; if (funcOpenSetV != funcOpenSetVFreeValue) { if (!funcOpenSetR.contains(funcOpenSetV)) { return(false); } } } } } else { if (this.funcOpenSet != null) { return(false); } } return(true); }
/// <summary> /// 写入字节流(完整版) /// </summary> protected override void toWriteBytesFull(BytesWriteStream stream) { stream.startWriteObj(); if (this.funcTools != null) { stream.writeBoolean(true); stream.writeLen(this.funcTools.size()); if (!this.funcTools.isEmpty()) { int funcToolsKFreeValue = this.funcTools.getFreeValue(); int[] funcToolsKKeys = this.funcTools.getKeys(); IntObjectMap <FuncToolData>[] funcToolsVValues = this.funcTools.getValues(); for (int funcToolsKI = funcToolsKKeys.Length - 1; funcToolsKI >= 0; --funcToolsKI) { int funcToolsK = funcToolsKKeys[funcToolsKI]; if (funcToolsK != funcToolsKFreeValue) { IntObjectMap <FuncToolData> funcToolsV = funcToolsVValues[funcToolsKI]; stream.writeInt(funcToolsK); if (funcToolsV != null) { stream.writeBoolean(true); stream.writeLen(funcToolsV.size()); if (!funcToolsV.isEmpty()) { int funcToolsVKFreeValue = funcToolsV.getFreeValue(); int[] funcToolsVKKeys = funcToolsV.getKeys(); FuncToolData[] funcToolsVVValues = funcToolsV.getValues(); for (int funcToolsVKI = funcToolsVKKeys.Length - 1; funcToolsVKI >= 0; --funcToolsVKI) { int funcToolsVK = funcToolsVKKeys[funcToolsVKI]; if (funcToolsVK != funcToolsVKFreeValue) { FuncToolData funcToolsVV = funcToolsVVValues[funcToolsVKI]; stream.writeInt(funcToolsVK); if (funcToolsVV != null) { stream.writeBoolean(true); stream.writeDataFullNotNull(funcToolsVV); } else { stream.writeBoolean(false); } } } } } else { stream.writeBoolean(false); } } } } } else { stream.writeBoolean(false); } if (this.funcOpenSet != null) { stream.writeLen(this.funcOpenSet.size()); if (!this.funcOpenSet.isEmpty()) { int funcOpenSetVFreeValue = this.funcOpenSet.getFreeValue(); int[] funcOpenSetVKeys = this.funcOpenSet.getKeys(); for (int funcOpenSetVI = funcOpenSetVKeys.Length - 1; funcOpenSetVI >= 0; --funcOpenSetVI) { int funcOpenSetV = funcOpenSetVKeys[funcOpenSetVI]; if (funcOpenSetV != funcOpenSetVFreeValue) { stream.writeInt(funcOpenSetV); } } } } else { nullObjError("funcOpenSet"); } stream.endWriteObj(); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is FuncPartData)) { return; } FuncPartData mData = (FuncPartData)data; if (mData.funcTools != null) { if (this.funcTools != null) { this.funcTools.clear(); this.funcTools.ensureCapacity(mData.funcTools.size()); } else { this.funcTools = new IntObjectMap <IntObjectMap <FuncToolData> >(mData.funcTools.size()); } IntObjectMap <IntObjectMap <FuncToolData> > funcToolsT = this.funcTools; if (!mData.funcTools.isEmpty()) { int funcToolsKFreeValue = mData.funcTools.getFreeValue(); int[] funcToolsKKeys = mData.funcTools.getKeys(); IntObjectMap <FuncToolData>[] funcToolsVValues = mData.funcTools.getValues(); for (int funcToolsKI = funcToolsKKeys.Length - 1; funcToolsKI >= 0; --funcToolsKI) { int funcToolsK = funcToolsKKeys[funcToolsKI]; if (funcToolsK != funcToolsKFreeValue) { IntObjectMap <FuncToolData> funcToolsV = funcToolsVValues[funcToolsKI]; int funcToolsW; IntObjectMap <FuncToolData> funcToolsU; funcToolsW = funcToolsK; if (funcToolsV != null) { funcToolsU = new IntObjectMap <FuncToolData>(funcToolsV.size()); IntObjectMap <FuncToolData> funcToolsUT = funcToolsU; if (!funcToolsV.isEmpty()) { int funcToolsUKFreeValue = funcToolsV.getFreeValue(); int[] funcToolsUKKeys = funcToolsV.getKeys(); FuncToolData[] funcToolsUVValues = funcToolsV.getValues(); for (int funcToolsUKI = funcToolsUKKeys.Length - 1; funcToolsUKI >= 0; --funcToolsUKI) { int funcToolsUK = funcToolsUKKeys[funcToolsUKI]; if (funcToolsUK != funcToolsUKFreeValue) { FuncToolData funcToolsUV = funcToolsUVValues[funcToolsUKI]; int funcToolsUW; FuncToolData funcToolsUU; funcToolsUW = funcToolsUK; if (funcToolsUV != null) { funcToolsUU = (FuncToolData)funcToolsUV.clone(); } else { funcToolsUU = null; } funcToolsUT.put(funcToolsUW, funcToolsUU); } } } } else { funcToolsU = null; } funcToolsT.put(funcToolsW, funcToolsU); } } } } else { this.funcTools = null; } if (mData.funcOpenSet != null) { if (this.funcOpenSet != null) { this.funcOpenSet.clear(); this.funcOpenSet.ensureCapacity(mData.funcOpenSet.size()); } else { this.funcOpenSet = new IntSet(); } IntSet funcOpenSetT = this.funcOpenSet; if (!mData.funcOpenSet.isEmpty()) { int funcOpenSetVFreeValue = mData.funcOpenSet.getFreeValue(); int[] funcOpenSetVKeys = mData.funcOpenSet.getKeys(); for (int funcOpenSetVI = funcOpenSetVKeys.Length - 1; funcOpenSetVI >= 0; --funcOpenSetVI) { int funcOpenSetV = funcOpenSetVKeys[funcOpenSetVI]; if (funcOpenSetV != funcOpenSetVFreeValue) { int funcOpenSetU; funcOpenSetU = funcOpenSetV; funcOpenSetT.add(funcOpenSetU); } } } } else { this.funcOpenSet = null; nullObjError("funcOpenSet"); } }
public void dispose() { if (_configDic == null) { return; } _configDic = null; _openDic.clear(); foreach (var list in _eventActiveDic) { TriggerEventRegistData[] values1 = list.getValues(); for (int i = 0, len = list.size(); i < len; ++i) { _eventRegistDataPool.back(values1[i]); values1[i] = null; } list.justClearSize(); } int[] keys = _instanceDic.getKeys(); TriggerInstance[] values = _instanceDic.getValues(); int fv = _instanceDic.getFreeValue(); TriggerInstance v; for (int i = keys.Length - 1; i >= 0; --i) { if ((keys[i]) != fv) { v = values[i]; _instancePool.back(v); keys[i] = fv; values[i] = null; } } _instanceDic.justClearSize(); TriggerActionRunner[] keys2 = _timerRunnerDic.getKeys(); TriggerActionRunner k2; for (int i2 = keys2.Length - 1; i2 >= 0; --i2) { if ((k2 = keys2[i2]) != null) { _argPool.back(k2.arg); disposeActionRunner(k2); keys2[i2] = null; } } _timerRunnerDic.justClearSize(); TriggerIntervalData[] keys3 = _timerIntervalDic.getKeys(); TriggerIntervalData k3; for (int i3 = keys3.Length - 1; i3 >= 0; --i3) { if ((k3 = keys3[i3]) != null) { _intervalPool.back(k3); keys3[i3] = null; } } _timerIntervalDic.justClearSize(); }