joker
°¡ÀÔÀÏ: 2005³â 10¿ù 18ÀÏ
°Ô½Ã¹°: 7
|
±Û ÀÛ¼º½Ã°£ : 2005-10-27 ¸ñ 1:12 pm Á¦¸ñ: -_-... ¾Æ ÀÌ°Å ¾î·Æ³× |
|
|
ÄÚµå :
using System;
using Server;
using Server.Network;
using Server.Mobiles;
namespace Server.Items
{
public class YoungTeleporter : Item
{
private bool m_Active, m_Creatures;
private Point3D m_PointDest;
private Map m_MapDest;
private bool m_SourceEffect;
private bool m_DestEffect;
private int m_SoundID;
private TimeSpan m_Delay;
[CommandProperty( AccessLevel.GameMaster )]
public bool SourceEffect
{
get{ return m_SourceEffect; }
set{ m_SourceEffect = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool DestEffect
{
get{ return m_DestEffect; }
set{ m_DestEffect = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public int SoundID
{
get{ return m_SoundID; }
set{ m_SoundID = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan Delay
{
get{ return m_Delay; }
set{ m_Delay = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Active
{
get { return m_Active; }
set { m_Active = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public Point3D PointDest
{
get { return m_PointDest; }
set { m_PointDest = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public Map MapDest
{
get { return m_MapDest; }
set { m_MapDest = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Creatures
{
get { return m_Creatures; }
set { m_Creatures = value; }
}
public override int LabelNumber{ get{ return 1026095; } } // ÅÚ·¹Æ÷Æ®
[Constructable]
public YoungTeleporter() : this( new Point3D( 0, 0, 0 ), null, false )
{
}
[Constructable]
public YoungTeleporter( Point3D pointDest, Map mapDest ) : this( pointDest, mapDest, false )
{
}
[Constructable]
public YoungTeleporter( Point3D pointDest, Map mapDest, bool creatures ) : base( 0x1BC3 )
{
Movable = false;
Visible = false;
m_Active = true;
m_PointDest = pointDest;
m_MapDest = mapDest;
m_Creatures = creatures;
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
if ( m_Active )
list.Add( 1060742 ); // active
else
list.Add( 1060743 ); // inactive
if ( m_MapDest != null )
list.Add( 1060658, "Map\t{0}", m_MapDest );
if ( m_PointDest != Point3D.Zero )
list.Add( 1060659, "Coords\t{0}", m_PointDest );
list.Add( 1060660, "Creatures\t{0}", m_Creatures ? "Yes" : "No" );
}
public override void OnSingleClick( Mobile from )
{
base.OnSingleClick( from );
if ( m_Active )
{
if ( m_MapDest != null && m_PointDest != Point3D.Zero )
LabelTo( from, "{0} [{1}]", m_PointDest, m_MapDest );
else if ( m_MapDest != null )
LabelTo( from, "[{0}]", m_MapDest );
else if ( m_PointDest != Point3D.Zero )
LabelTo( from, m_PointDest.ToString() );
}
else
{
LabelTo( from, "(inactive)" );
}
}
public virtual void StartTeleport( Mobile m )
{
PlayerMobile pm = m as PlayerMobile; // cast the Mobile as a PlayerMobile to enable checking of Young status
if ( pm != null && !pm.Young && m.AccessLevel < AccessLevel.Counselor ) // if the player is a playermobile (sanity check) AND the player is not young AND the player isn't a staff member
return; // do nothing
else if ( m_Delay == TimeSpan.Zero ) // if teleport delay is 0 seconds..
DoTeleport( m ); // teleport immediately
else // otherwise..
Timer.DelayCall( m_Delay, new TimerStateCallback( DoTeleport_Callback ), m ); // start the timer for the delay, then teleport when timer is complete
}
private void DoTeleport_Callback( object state )
{
DoTeleport( (Mobile) state );
}
public virtual void DoTeleport( Mobile m )
{
Map map = m_MapDest;
if ( map == null || map == Map.Internal )
map = m.Map;
Point3D p = m_PointDest;
if ( p == Point3D.Zero )
p = m.Location;
Server.Mobiles.BaseCreature.TeleportPets( m, p, map );
bool sendEffect = ( !m.Hidden || m.AccessLevel == AccessLevel.Player );
if ( m_SourceEffect && sendEffect )
Effects.SendLocationEffect( m.Location, m.Map, 0x3728, 10, 10 );
m.MoveToWorld( p, map );
if ( m_DestEffect && sendEffect )
Effects.SendLocationEffect( m.Location, m.Map, 0x3728, 10, 10 );
if ( m_SoundID > 0 && sendEffect )
Effects.PlaySound( m.Location, m.Map, m_SoundID );
}
public override bool OnMoveOver( Mobile m )
{
if ( m_Active )
{
if ( !m_Creatures && !m.Player )
return true;
StartTeleport( m );
return false;
}
return true;
}
public YoungTeleporter( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 2 ); // version
writer.Write( (bool) m_SourceEffect );
writer.Write( (bool) m_DestEffect );
writer.Write( (TimeSpan) m_Delay );
writer.WriteEncodedInt( (int) m_SoundID );
writer.Write( m_Creatures );
writer.Write( m_Active );
writer.Write( m_PointDest );
writer.Write( m_MapDest );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 2:
{
m_SourceEffect = reader.ReadBool();
m_DestEffect = reader.ReadBool();
m_Delay = reader.ReadTimeSpan();
m_SoundID = reader.ReadEncodedInt();
goto case 1;
}
case 1:
{
m_Creatures = reader.ReadBool();
goto case 0;
}
case 0:
{
m_Active = reader.ReadBool();
m_PointDest = reader.ReadPoint3D();
m_MapDest = reader.ReadMap();
break;
}
}
}
}
}
|
|