public void CopyBuildData(PlanetFactory factory, int i) { var fSystem = factory.factorySystem; var ed = factory.entityPool[i]; if (ed.protoId > 0) { if (ed.labId > 0 && ed.storageId > 0 || ed.tankId > 0) { return; } MyPreBuildData temp = null; if (ed.splitterId > 0) { var ap = factory.cargoTraffic.splitterPool[ed.splitterId]; int c0 = factory.entityConnPool[16 * ap.entityId]; int c1 = factory.entityConnPool[16 * ap.entityId + 1]; int c2 = factory.entityConnPool[16 * ap.entityId + 2]; int c3 = factory.entityConnPool[16 * ap.entityId + 3]; temp = new Splitter(GetPreDate(ed), c0, c1, c2, c3); } else if (ed.stationId > 0) { var ap = factory.transport.stationPool[ed.stationId]; if (ap != null) { temp = new Station(GetPreDate(ed), ap); } } else if (ed.inserterId > 0) { var ip = fSystem.inserterPool[ed.inserterId]; InserterComponent tempp = ip; int outConn = factory.entityConnPool[i * 16]; int inConn = factory.entityConnPool[i * 16 + 1]; temp = new Inserter(GetPreDate(tempp, ed), ip, outConn, inConn); } else if (ed.beltId > 0) { var ap = factory.cargoTraffic.beltPool[ed.beltId]; bool flag2; int slot; factory.ReadObjectConn(i, 0, out flag2, out int out1, out slot); factory.ReadObjectConn(i, 1, out flag2, out int in1, out slot); factory.ReadObjectConn(i, 2, out flag2, out int in2, out slot); factory.ReadObjectConn(i, 3, out flag2, out int in3, out slot); temp = new Belt(GetPreDate(ap, ed), ap, out1, in1, in2, in3); Belt tBelt = (Belt)temp; if (out1 == 0) { CheckBeltData.Add(i, tBelt); } tBelt.beltOut = EIdIsBeltId(out1); tBelt.beltIn1 = EIdIsBeltId(in1); tBelt.beltIn2 = EIdIsBeltId(in2); tBelt.beltIn3 = EIdIsBeltId(in3); } else if (ed.fractionateId > 0) { var ap = factory.factorySystem.fractionatePool[ed.fractionateId]; int c0 = factory.entityConnPool[i * 16]; int c1 = factory.entityConnPool[i * 16 + 1]; int c2 = factory.entityConnPool[i * 16 + 2]; temp = new Fractionate(GetPreDate(ed), c0, c1, c2); } else if (ed.powerExcId > 0) { var ap = factory.powerSystem.excPool[ed.powerExcId]; int c0 = factory.entityConnPool[i * 16]; int c1 = factory.entityConnPool[i * 16 + 1]; int c2 = factory.entityConnPool[i * 16 + 2]; int c3 = factory.entityConnPool[i * 16 + 3]; temp = new PowerExchanger(GetPreDate(ed), c0, c1, c2, c3, ap.targetState); } else if (ed.assemblerId > 0) { var ap = fSystem.assemblerPool[ed.assemblerId]; temp = new Assembler(GetPreDate(ap, ed)); } else if (ed.ejectorId > 0) { var ap = fSystem.ejectorPool[ed.ejectorId]; temp = new Assembler(GetPreDate(ed)); } else if (ed.siloId > 0) { var ap = fSystem.siloPool[ed.siloId]; temp = new Assembler(GetPreDate(ed)); } else if (ed.powerGenId > 0) { var ap = factory.powerSystem.genPool[ed.powerGenId]; if (ap.gamma) { int c0 = factory.entityConnPool[16 * ap.entityId]; int c1 = factory.entityConnPool[16 * ap.entityId + 1]; temp = new Gamm(GetPreDate(ed), ap.productId, c0, c1); } else { temp = new Assembler(GetPreDate(ed)); temp.type = EDataType.PowGen; } } else if (ed.powerNodeId > 0) { var ap = factory.powerSystem.nodePool[ed.powerNodeId]; temp = new Assembler(GetPreDate(ed)); } //else if (ed.storageId > 0) //{ // var ap = factory.factoryStorage.storagePool[ed.storageId]; // if (ap.next == 0) // { // temp = new Assembler(GetPreDate(ed)); // } //} if (temp != null) { temp.oldEId = i; AllData.Add(temp); AddItemCount(ed.protoId); } } }
public void OldImport(string[] s) { try { if (s.Length > 7) { Name = s[0]; AddItemCount(s[1]); int c = int.Parse(s[2]); int i = 3; for (int j = 0; j < c; j++) { var temp = new Assembler(s[i + j]); AllData.Add(temp); } i += c; c = int.Parse(s[i]); i++; for (int j = 0; j < c; j++) { var temp = new Assembler(s[i + j]); temp.type = EDataType.PowGen; AllData.Add(temp); } i += c; c = int.Parse(s[i]); i++; for (int j = 0; j < c; j++) { var temp = new Assembler(s[i + j]); AllData.Add(temp); } i += c; c = int.Parse(s[i]); i++; for (int j = 0; j < c; j++) { var temp = new Inserter(s[i + j]); AllData.Add(temp); } i += c; c = int.Parse(s[i]); i++; for (int j = 0; j < c; j++) { var temp = new Belt(s[i + j]); AllData.Add(temp); } i += c; if (s.Length < i + 1) { return; } c = int.Parse(s[i]); i++; if (s.Length < i + c) { return; } for (int j = 0; j < c; j++) { Station temp = new Station(s[i + j]); if (temp.isStation) { AllData.Add(temp); } } i += c; if (s.Length < i + 1) { return; } if (s[i].Length < 1) { return; } c = int.Parse(s[i]); i++; if (s.Length < i + c) { return; } for (int j = 0; j < c; j++) { Lab temp = new Lab(s[i + j]); if (temp.isLab) { AllData.Add(temp); } } i += c; if (s.Length < i + 1) { return; } if (s[i].Length < 1) { return; } c = int.Parse(s[i]); i++; if (s.Length < i + c) { return; } for (int j = 0; j < c; j++) { Gamm temp = new Gamm(s[i + j]); if (temp.isGamm) { AllData.Add(temp); } } i += c; if (Count > 0 && ItemNeed.Count == 0) { InitItemNeed(); } Export(); } } catch (Exception e) { Debug.LogError("ParseError"); Debug.LogError(e.Message); Name = Name + "【Error!】"; Clear(); } }