forked from runuo/runuo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovement.cs
75 lines (65 loc) · 2.13 KB
/
Movement.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/***************************************************************************
* Movement.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : [email protected]
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using System;
using System.Collections;
namespace Server.Movement
{
public static class Movement
{
private static IMovementImpl m_Impl;
public static IMovementImpl Impl
{
get{ return m_Impl; }
set{ m_Impl = value; }
}
public static bool CheckMovement( Mobile m, Direction d, out int newZ )
{
if ( m_Impl != null )
return m_Impl.CheckMovement( m, d, out newZ );
newZ = m.Z;
return false;
}
public static bool CheckMovement( Mobile m, Map map, Point3D loc, Direction d, out int newZ )
{
if ( m_Impl != null )
return m_Impl.CheckMovement( m, map, loc, d, out newZ );
newZ = m.Z;
return false;
}
public static void Offset( Direction d, ref int x, ref int y )
{
switch ( d & Direction.Mask )
{
case Direction.North: --y; break;
case Direction.South: ++y; break;
case Direction.West: --x; break;
case Direction.East: ++x; break;
case Direction.Right: ++x; --y; break;
case Direction.Left: --x; ++y; break;
case Direction.Down: ++x; ++y; break;
case Direction.Up: --x; --y; break;
}
}
}
public interface IMovementImpl
{
bool CheckMovement( Mobile m, Direction d, out int newZ );
bool CheckMovement( Mobile m, Map map, Point3D loc, Direction d, out int newZ );
}
}