/// <summary> /// 判断协议cd是否ok /// </summary> public bool CheckCooldown(ushort msg_idx) { StdPacketCDInfo cd_info = PacketCDConfig.Instance.GetInfo(msg_idx); if (cd_info == null) { return(true); } long old_time = 0; if (!m_cooldowns.TryGetValue(msg_idx, out old_time)) { m_cooldowns.Add(msg_idx, Time.timeSinceStartup); return(true); } if (Time.timeSinceStartup - old_time >= cd_info.cd) { m_cooldowns[msg_idx] = Time.timeSinceStartup; return(true); } return(false); }
private void OnLoaded(CSVDocument doc) { int totalCount = (int)doc.TableRows(); for (int i = 0; i < totalCount; ++i) { StdPacketCDInfo info = new StdPacketCDInfo(); info.idx = doc.GetValue(i, "idx").ToUInt16(); info.type = doc.GetValue(i, "type").ToByte(); info.cd = doc.GetValue(i, "cd").ToInt32(); if (info.idx > 0) { m_infos.Add(info.idx, info); } } }