public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)3); // version writer.Write((int)m_Level); writer.Write(m_Active); writer.Write(m_Multiplier); writer.Write(m_Charges); //writer.WriteItemList( m_Connected, true ); ItemBroker.WriteSerialList(writer, m_Connected); writer.Write(m_TextHue); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 3: { goto case 2; } case 2: case 1: { m_Level = (SecureLevel)reader.ReadInt(); goto case 0; } case 0: { m_Active = reader.ReadBool(); m_Multiplier = reader.ReadDouble(); m_Charges = reader.ReadInt(); if (version < 3) { //m_Connected = reader.ReadItemList(); ArrayList list = reader.ReadItemList(); m_Connected = new List <Serial>(list.Count); for (int i = 0; i < list.Count; i++) { CommunicationCrystal cc = list[i] as CommunicationCrystal; if (cc != null) { m_Connected.Add(cc.Serial); } } } else { m_Connected = ItemBroker.ReadSerialList(reader); } m_TextHue = reader.ReadInt(); break; } } }
new private void SendMessage(string text) { ArrayList ToDelete = new ArrayList(); foreach (Serial commSerial in m_Connected) { bool bIsFD = false; CommunicationCrystal comm = ItemBroker.GetItem <CommunicationCrystal>(commSerial, ref bIsFD); if (bIsFD) { //skip, because that Crystal is freezedried } else if (comm == null || comm.Deleted) { //Mark to delete it if we can't find it in the world OR it's been deleted ToDelete.Add(commSerial); } else { // If the crystals are not in the same place, or the receiver is locked down, send message. if (comm.RootParent != RootParent || comm.IsLockedDown) { comm.ReceiveMessage(text); // Decrement charges if Multiplier is not 0.0, and turn the crystal off when empty. if (m_Multiplier != 0.0 && --Charges <= 0) { Active = false; } } } } // Remove deleted crystals foreach (Serial s in ToDelete) { if (m_Connected.Contains(s)) { m_Connected.Remove(s); } } }