public SqdSchedule(EnSolution Sln, EnSquad Squad) { this.squad = Squad; matrix = new DtMatrix <ScheduleNode>(Sln); foreach (VcTime time in matrix.eachTime()) { matrix[time] = new ScheduleNode(); } }
/// <summary> /// 把sqdSch.FailLsnActs中所有LsnAct安排进sqdSch.Matrix /// 不准备环境(即不清除各单元的Rule、LsnAct) /// </summary> private void PutActToMatrix(SqdSchedule sqdSch) { EnLsnAct FillAct = new EnLsnAct(); IList <EnLsnAct> tmpActs = sqdSch.FailLsnActs == null ? null : new List <EnLsnAct>(sqdSch.FailLsnActs); sqdSch.FailLsnActs.Clear(); foreach (EnLsnAct act in tmpActs) { if (sqdSch.Matrix.TestTime(act.Time)) { ScheduleNode node = sqdSch.Matrix[act.Time]; if (node.LsnAct == null) { node.LsnAct = act; } else { sqdSch.FailLsnActs.Add(act); if (node.LsnAct != FillAct) { sqdSch.FailLsnActs.Add(node.LsnAct); node.LsnAct = FillAct; } } } else { sqdSch.FailLsnActs.Add(act); } } foreach (ScheduleNode node in sqdSch.Matrix.eachElement()) { if (node.LsnAct == FillAct) { node.LsnAct = null; } } }
/// <summary> /// 生成全校待处理任务(FailActs) /// </summary> private void SetFailActs() { FailActs.Clear(); foreach (SqdSchedule sqdSch in SqdScheduleList.Values) { foreach (EnLsnAct act in sqdSch.FailLsnActs) { FailActs.Add(new EnFailAct(act)); } foreach (VcTime time in sqdSch.Matrix.eachTime()) { ScheduleNode node = sqdSch.Matrix[time]; if (node.Rule == eRule.crisscross && node.LsnAct != null) { FailActs.Add(new EnFailAct(node.LsnAct, time)); } } } }
public void Load(Stream input) { Deserializer deserializer = new Deserializer(input); this.header = new Header(); this.header.dMajorMapVersion = deserializer.DeserializeFloat(); this.header.ubMinorMapVersion = deserializer.DeserializeByte(); this.header.uiFlags = deserializer.DeserializeUInt(); this.header.iTilesetID = deserializer.DeserializeInt(); this.header.uiSoldierSize = deserializer.DeserializeUInt(); // FP 0x000010 // Read height values for (Int32 cnt = 0; cnt < WORLD_MAX; cnt++) { MapElement element = new MapElement(); element.sHeight = deserializer.DeserializeUShort(); elementes[cnt] = element; } // FP 0x00c810 // Read layer counts for (Int32 cnt = 0; cnt < WORLD_MAX; cnt++) { byte[] layerCountsData = deserializer.DeserializeBytes(4); elementes[cnt].SetLayerCounts(layerCountsData); } // FP 0x025810 for (UInt32 cnt = 0; cnt < WORLD_MAX; cnt++) { this.elementes[cnt].pLandHead.Load(deserializer, true); } for (UInt32 cnt = 0; cnt < WORLD_MAX; cnt++) { this.elementes[cnt].pLandStart.Load(deserializer, false); } for (UInt32 cnt = 0; cnt < WORLD_MAX; cnt++) { this.elementes[cnt].pObjectHead.Load(deserializer, true); } for (UInt32 cnt = 0; cnt < WORLD_MAX; cnt++) { this.elementes[cnt].pStructHead.Load(deserializer, true); } for (UInt32 cnt = 0; cnt < WORLD_MAX; cnt++) { this.elementes[cnt].pShadowHead.Load(deserializer, true); } for (UInt32 cnt = 0; cnt < WORLD_MAX; cnt++) { this.elementes[cnt].pMercHead.Load(deserializer, true); } return; //for (UInt32 cnt = 0; cnt < WORLD_MAX; cnt++) //{ // this.elementes[cnt].pRoofHead.Load(deserializer, true); //} //for (UInt32 cnt = 0; cnt < WORLD_MAX; cnt++) //{ // this.elementes[cnt].pOnRoofHead.Load(deserializer, true); //} //for (UInt32 cnt = 0; cnt < WORLD_MAX; cnt++) //{ // this.elementes[cnt].pTopmostHead.Load(deserializer, true); //} if (this.header.dMajorMapVersion == 6.00 && this.header.ubMinorMapVersion < 27) { input.Seek(37, SeekOrigin.Current); } this.gubWorldRoomInfo = deserializer.DeserializeBytes(WORLD_MAX); if ((this.header.Flags & MapFlags.MAP_WORLDITEMS_SAVED) != 0) { this.uiNumWorldItems = deserializer.DeserializeUInt(); // size(WORLDITEM) = 52 input.Seek(this.uiNumWorldItems * 52, SeekOrigin.Current); } if ((this.header.Flags & MapFlags.MAP_AMBIENTLIGHTLEVEL_SAVED) != 0) { //Ambient light levels are only saved in underground levels this.gfBasement = deserializer.DeserializeBool(); this.gfCaves = deserializer.DeserializeBool(); this.ubAmbientLightLevel = deserializer.DeserializeByte(); } if ((this.header.Flags & MapFlags.MAP_WORLDLIGHTS_SAVED) != 0) { this.ubNumColors = deserializer.DeserializeByte(); this.colors = new SGPPaletteEntry[this.ubNumColors]; for (int i = 0; i < this.ubNumColors; i++) { this.colors[i] = (SGPPaletteEntry)deserializer.Deserialize(typeof(SGPPaletteEntry)); } this.usNumLights = deserializer.DeserializeUShort(); this.lights = new LightSprite[this.usNumLights]; for (int cnt = 0; cnt < this.usNumLights; cnt++) { this.lights[cnt] = (LightSprite)deserializer.Deserialize(typeof(LightSprite)); this.lightTemplateName = deserializer.DeserializeString(); } } this.mapInfo = (MapCreateStruct)deserializer.Deserialize(typeof(MapCreateStruct)); if ((this.header.Flags & MapFlags.MAP_FULLSOLDIER_SAVED) != 0) { byte numIndividuals = this.mapInfo.ubNumIndividuals; this.mapInfo.ubNumIndividuals = 0; this.soldiers = new BasicSoldierCreateStruct[numIndividuals]; for (int i = 0; i < numIndividuals; i++) { this.soldiers[i] = (BasicSoldierCreateStruct)deserializer.Deserialize(typeof(BasicSoldierCreateStruct)); } } if ((this.header.Flags & MapFlags.MAP_EXITGRIDS_SAVED) != 0) { this.usNumSave = deserializer.DeserializeUShort(); for (int i = 0; i < this.usNumSave; i++) { UInt16 exitGridIndex = deserializer.DeserializeUShort(); ExitGrid exitGrid = (ExitGrid)deserializer.Deserialize(typeof(ExitGrid)); if (!this.exitGrids.ContainsKey(exitGridIndex)) { this.exitGrids.Add(exitGridIndex, exitGrid); } } } if ((this.header.Flags & MapFlags.MAP_DOORTABLE_SAVED) != 0) { this.gubNumDoors = deserializer.DeserializeByte(); this.doorTable = new Door[this.gubNumDoors]; for (int i = 0; i < this.gubNumDoors; i++) { this.doorTable[i] = (Door)deserializer.Deserialize(typeof(Door)); } } if ((this.header.Flags & MapFlags.MAP_EDGEPOINTS_SAVED) != 0) { this.gus1stNorthEdgepointArraySize = deserializer.DeserializeUShort(); this.gus1stNorthEdgepointMiddleIndex = deserializer.DeserializeUShort(); if (gus1stNorthEdgepointArraySize > 0) { this.gps1stNorthEdgepointArray = new Int16[this.gus1stNorthEdgepointArraySize]; for (int i = 0; i < this.gus1stNorthEdgepointArraySize; i++) { this.gps1stNorthEdgepointArray[i] = deserializer.DeserializeShort(); } } this.gus1stEastEdgepointArraySize = deserializer.DeserializeUShort(); this.gus1stEastEdgepointMiddleIndex = deserializer.DeserializeUShort(); if (gus1stEastEdgepointArraySize > 0) { this.gps1stEastEdgepointArray = new Int16[this.gus1stEastEdgepointArraySize]; for (int i = 0; i < this.gus1stEastEdgepointArraySize; i++) { this.gps1stEastEdgepointArray[i] = deserializer.DeserializeShort(); } } this.gus1stSouthEdgepointArraySize = deserializer.DeserializeUShort(); this.gus1stSouthEdgepointMiddleIndex = deserializer.DeserializeUShort(); if (gus1stSouthEdgepointArraySize > 0) { this.gps1stSouthEdgepointArray = new Int16[this.gus1stSouthEdgepointArraySize]; for (int i = 0; i < this.gus1stSouthEdgepointArraySize; i++) { this.gps1stSouthEdgepointArray[i] = deserializer.DeserializeShort(); } } this.gus1stWestEdgepointArraySize = deserializer.DeserializeUShort(); this.gus1stWestEdgepointMiddleIndex = deserializer.DeserializeUShort(); if (gus1stWestEdgepointArraySize > 0) { this.gps1stWestEdgepointArray = new Int16[this.gus1stWestEdgepointArraySize]; for (int i = 0; i < this.gus1stWestEdgepointArraySize; i++) { this.gps1stWestEdgepointArray[i] = deserializer.DeserializeShort(); } } if (this.mapInfo.ubMapVersion < 17) { //To prevent invalidation of older maps, which only used one layer of edgepoints, and a UINT8 for //containing the size, we will preserve that paradigm, then kill the loaded edgepoints and //regenerate them. //OldLoadMapEdgepoints(hBuffer); //TrashMapEdgepoints(); this.fGenerateEdgePoints = true; //only if the map had the older edgepoint system return; } else { this.gus2ndNorthEdgepointArraySize = deserializer.DeserializeUShort(); this.gus2ndNorthEdgepointMiddleIndex = deserializer.DeserializeUShort(); if (gus2ndNorthEdgepointArraySize > 0) { this.gps2ndNorthEdgepointArray = new Int16[this.gus2ndNorthEdgepointArraySize]; for (int i = 0; i < this.gus2ndNorthEdgepointArraySize; i++) { this.gps2ndNorthEdgepointArray[i] = deserializer.DeserializeShort(); } } this.gus2ndEastEdgepointArraySize = deserializer.DeserializeUShort(); this.gus2ndEastEdgepointMiddleIndex = deserializer.DeserializeUShort(); if (gus2ndEastEdgepointArraySize > 0) { this.gps2ndEastEdgepointArray = new Int16[this.gus2ndEastEdgepointArraySize]; for (int i = 0; i < this.gus2ndEastEdgepointArraySize; i++) { this.gps2ndEastEdgepointArray[i] = deserializer.DeserializeShort(); } } this.gus2ndSouthEdgepointArraySize = deserializer.DeserializeUShort(); this.gus2ndSouthEdgepointMiddleIndex = deserializer.DeserializeUShort(); if (gus2ndSouthEdgepointArraySize > 0) { this.gps2ndSouthEdgepointArray = new Int16[this.gus2ndSouthEdgepointArraySize]; for (int i = 0; i < this.gus2ndSouthEdgepointArraySize; i++) { this.gps2ndSouthEdgepointArray[i] = deserializer.DeserializeShort(); } } this.gus2ndWestEdgepointArraySize = deserializer.DeserializeUShort(); this.gus2ndWestEdgepointMiddleIndex = deserializer.DeserializeUShort(); if (gus2ndWestEdgepointArraySize > 0) { this.gps2ndWestEdgepointArray = new Int16[this.gus2ndWestEdgepointArraySize]; for (int i = 0; i < this.gus2ndWestEdgepointArraySize; i++) { this.gps2ndWestEdgepointArray[i] = deserializer.DeserializeShort(); } } } if (this.mapInfo.ubMapVersion < 22) { //regenerate them. //TrashMapEdgepoints(); this.fGenerateEdgePoints = true; //only if the map had the older edgepoint system } } else { fGenerateEdgePoints = true; } if ((this.header.Flags & MapFlags.MAP_NPCSCHEDULES_SAVED) != 0) { this.gubScheduleID = 1; this.ubNumSchedules = deserializer.DeserializeByte(); this.gpScheduleList = new List <ScheduleNode>(); for (int i = 0; i < this.ubNumSchedules; i++) { ScheduleNode schedule = (ScheduleNode)deserializer.Deserialize(typeof(ScheduleNode)); schedule.ubScheduleID = gubScheduleID; schedule.ubSoldierID = NO_SOLDIER; this.gpScheduleList.Add(schedule); this.gubScheduleID++; } } }