protected void OnTarget(Mobile m, object obj) { if (Recharge(m, obj)) { return; } if (!(obj is CommunicationCrystal)) { return; } if (obj == this) { if (Active) { Active = false; ItemID = 0x1ED0; m.SendMessage(InactiveHue, "You turn the crystal off."); } else { if (m_Charges == 0) { m.SendMessage("The crystal has no charges."); } else { Active = true; ItemID = 0x1ECD; m.SendMessage(ActiveHue, "You turn the crystal on."); } } return; } if (!((Item)obj).Movable) { m.SendMessage("You cannot connect to this crystal."); return; } CommunicationCrystal ccTarget = (CommunicationCrystal)obj; if (m_Connected.Contains(ccTarget.Serial)) { m_Connected.Remove(ccTarget.Serial); m.SendMessage("You have disconnected the crystals."); } else { m_Connected.Add(ccTarget.Serial); m.SendMessage("You have connected the crystals."); } }
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); } } }
public InternalTarget( CommunicationCrystal crystal ) : base( 1, false, TargetFlags.None ) { m_Crystal = crystal; }
public InternalTarget(CommunicationCrystal crystal) : base(1, false, TargetFlags.None) { m_Crystal = crystal; }