public void OnTentFinish(Sickbed sickbed) { CSMain.Instance.RemoveCounter(sickbed.cs); if (GameConfig.IsMultiMode) { sickbed.isNpcReady = false; return; } //--to do: 更新npc状态,更新sickbed PeEntity npc = sickbed.Npc; sickbed.Npc = null; sickbed.isNpcReady = false; if (m_MgCreator.FindTreatment(npc.Id) != null) { npc.GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.SearchTreat; } else { npc.GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.Cure; } allPatients.Remove(npc); Data.npcIds.Remove(npc.Id); if (allPatients.Count >= CSMedicalTentConst.BED_AMOUNT_MAX) { allPatients[CSMedicalTentConst.BED_AMOUNT_MAX - 1].GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.SearchHospital; } RefreshPatientGrids(patientsInTent); }
public bool StartTent(PeEntity npc) { if (allPatients.Count <= 0) { return(false); } //if (allPatients[0] != npc) // return false; Sickbed npcBed = null; bool npcLinkBed = false; for (int i = 0; i < CSMedicalTentConst.BED_AMOUNT_MAX; i++) { if (allSickbeds[i].Npc == npc) { npcLinkBed = true; npcBed = allSickbeds[i]; } } if (!npcLinkBed) { return(false); } if (!CallDoctor()) { //--to do: remind player to doctor } npcBed.isNpcReady = true; npc.GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.In_Hospital; return(true); }
public CSTentData() { dType = CSConst.dtTent; allSickbeds = new Sickbed[CSMedicalTentConst.BED_AMOUNT_MAX]; for (int i = 0; i < CSMedicalTentConst.BED_AMOUNT_MAX; i++) { allSickbeds[i] = new Sickbed(i); } }
public static CSMedicalTent FindMedicalTent(out bool isReady, PeEntity npc, out Sickbed sickBed) { isReady = false; sickBed = null; if (PeGameMgr.IsMulti) { NetworkInterface npcnet = AiAdNpcNetwork.Get(npc.Id); if (npcnet == null) { return(null); } CSMgCreator creator = MultiColonyManager.GetCreator(npcnet.TeamId); if (creator.Assembly == null) { return(null); } if (creator.Assembly.MedicalTent == null) { return(null); } CSMedicalTent tent = creator.Assembly.MedicalTent; if (!tent.IsRunning) { return(null); } sickBed = tent.CheckNpcBed(npc); if (sickBed == null) { tent._ColonyObj._Network.RPCServer(EPacketType.PT_CL_TET_FindMachine, npc.Id); } else { isReady = true; } return(tent); } else { if (s_MgCreator.Assembly == null) { return(null); } if (s_MgCreator.Assembly.MedicalTent == null) { return(null); } CSMedicalTent tent = s_MgCreator.Assembly.MedicalTent; if (!tent.IsRunning) { return(null); } isReady = tent.IsReady(npc, out sickBed); tent.AppointTent(npc); return(tent); } }
//根据病床号查询病床信息 public static List <Sickbed> Getinfobysid(string sid = "") { OdbcConnection odbcConnection = DB.DBManager.GetOdbcConnection(); odbcConnection.Open(); string sql = "SELECT * FROM `hospital`.`sickbed` " + "WHERE `S_ID`='" + sid + "'"; OdbcCommand odbcCommand = new OdbcCommand(sql, odbcConnection); OdbcDataReader odbcDataReader = odbcCommand.ExecuteReader(CommandBehavior.CloseConnection); if (odbcDataReader.HasRows) { List <Sickbed> list = Sickbed.getList(odbcDataReader); odbcConnection.Close(); return(list); } odbcConnection.Close(); return(null); }
public static List <Sickbed> SickBedInfobyde(string deid) { OdbcConnection sqlConnection1 = DBManager.GetOdbcConnection(); sqlConnection1.Open(); OdbcCommand odbcCommand = new OdbcCommand("select * from sickbed where `DE_ID`='" + deid + "'", sqlConnection1); OdbcDataReader odbcDataReader = odbcCommand.ExecuteReader(); if (odbcDataReader.HasRows) { List <Sickbed> list = Sickbed.getList(odbcDataReader); sqlConnection1.Close(); return(list); } else { sqlConnection1.Close(); } return(null); }
public static void ParseData(byte[] data, CSTentData recordData) { using (MemoryStream ms = new MemoryStream(data)) using (BinaryReader reader = new BinaryReader(ms)) { int npcCount = BufferHelper.ReadInt32(reader); for (int j = 0; j < npcCount; j++) { recordData.npcIds.Add(BufferHelper.ReadInt32(reader)); } for (int i = 0; i < CSMedicalTentConst.BED_AMOUNT_MAX; i++) { Sickbed sb = recordData.allSickbeds[i]; sb.npcId = BufferHelper.ReadInt32(reader); sb.m_CurTime = BufferHelper.ReadSingle(reader); sb.m_Time = BufferHelper.ReadSingle(reader); sb.isNpcReady = BufferHelper.ReadBoolean(reader); sb.occupied = BufferHelper.ReadBoolean(reader); } } }
public void TentFinish(int npcId) { PeEntity npc = EntityMgr.Instance.Get(npcId); Sickbed sickbed = CheckNpcBed(npcId); sickbed.Npc = null; sickbed.isNpcReady = false; if (m_MgCreator.FindTreatment(npc.Id) != null) { npc.GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.SearchTreat; } else { npc.GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.Cure; } allPatients.Remove(npc); Data.npcIds.Remove(npc.Id); if (allPatients.Count >= CSMedicalTentConst.BED_AMOUNT_MAX) { allPatients[CSMedicalTentConst.BED_AMOUNT_MAX - 1].GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.SearchHospital; } RefreshPatientGrids(patientsInTent); }
public override void CreateData() { CSDefaultData ddata = null; bool isNew; if (GameConfig.IsMultiMode) { isNew = MultiColonyManager.Instance.AssignData(ID, CSConst.dtTent, ref ddata, _ColonyObj); } else { isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.dtTent, ref ddata); } m_Data = ddata as CSTentData; if (isNew) { Data.m_Name = CSUtils.GetEntityName(m_Type); Data.m_Durability = Info.m_Durability; for (int i = 0; i < allSickbeds.Length; i++) { allSickbeds[i].tentBuilding = this; if (pePatient != null) { allSickbeds[i].bedLay = pePatient.Lays[i]; } if (resultTrans != null) { allSickbeds[i].bedTrans = resultTrans[i]; } } } else { StartRepairCounter(Data.m_CurRepairTime, Data.m_RepairTime, Data.m_RepairValue); StartDeleteCounter(Data.m_CurDeleteTime, Data.m_DeleteTime); //--to do if (Data.npcIds.Count > 0) { foreach (int id in Data.npcIds) { PeEntity npc = EntityMgr.Instance.Get(id); if (npc != null) { allPatients.Add(npc); } } } for (int i = 0; i < CSMedicalTentConst.BED_AMOUNT_MAX; i++) { Sickbed sb = allSickbeds[i]; if (sb.npcId >= 0) { sb.npc = EntityMgr.Instance.Get(sb.npcId); } else { sb.npc = null; } sb.StartCounterFromRecord(); sb.tentBuilding = this; if (pePatient != null) { sb.bedLay = pePatient.Lays[i]; } if (resultTrans != null) { sb.bedTrans = resultTrans[i]; } } } }
public bool IsReady(PeEntity npc, out Sickbed sickBed) { sickBed = FindEmptyBed(npc); return(sickBed != null); }