forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL2Zone.cs
More file actions
110 lines (87 loc) · 2.92 KB
/
Copy pathL2Zone.cs
File metadata and controls
110 lines (87 loc) · 2.92 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System.Collections.Generic;
using System.Timers;
using L2dotNET.Models.Player;
using L2dotNET.Models.Zones.forms;
using L2dotNET.Network;
using L2dotNET.Tables;
using L2dotNET.World;
namespace L2dotNET.Models.Zones
{
public class L2Zone
{
public ZoneForm Territory;
public int ZoneId;
public string ZonePch;
public bool Enabled = false;
public ZoneTemplate Template;
public int InstanceId = -1;
public L2Object NpcCenter;
protected readonly IdFactory _idFactory;
public SortedList<int, L2Object> ObjectsInside = new SortedList<int, L2Object>();
public virtual void OnEnter(L2Object obj)
{
if (!ObjectsInside.ContainsKey(obj.ObjectId))
ObjectsInside.Add(obj.ObjectId, obj);
}
public void BroadcastPacket(GameserverPacket pk)
{
foreach (L2Object obj in ObjectsInside.Values)
{
if (obj is L2Player)
((L2Player)obj).SendPacketAsync(pk);
else
{
}
}
}
public virtual void OnExit(L2Object obj, bool cls)
{
if (!cls)
return;
lock (ObjectsInside)
{
if (ObjectsInside.ContainsKey(obj.ObjectId))
ObjectsInside.Remove(obj.ObjectId);
}
}
public virtual void OnDie(L2Character obj, L2Character killer) { }
public virtual void OnKill(L2Character obj, L2Character target) { }
public Timer Action;
public virtual void StartTimer()
{
Action = new Timer(Template.UnitTick * 1000);
Action.Elapsed += OnTimerAction;
Action.Interval = Template.UnitTick * 1000;
Action.Enabled = true;
}
public virtual void StopTimer() { }
public virtual void OnTimerAction(object sender, ElapsedEventArgs e) { }
public virtual void OnInit() { }
private Timer _selfDestruct;
public int[] CylinderCenter;
public string Name;
protected L2Zone(IdFactory idFactory)
{
_idFactory = idFactory;
}
public void SelfDestruct(int sec)
{
_selfDestruct = new Timer(sec * 1000);
_selfDestruct.Elapsed += DesctructTime;
_selfDestruct.Enabled = true;
}
private void DesctructTime(object sender, ElapsedEventArgs e)
{
_selfDestruct.Enabled = false;
NpcCenter.DecayMe();
foreach (L2Object o in ObjectsInside.Values)
OnExit(o, false);
ObjectsInside.Clear();
L2WorldRegion region = L2World.GetRegion(CylinderCenter[0], CylinderCenter[1]);
if (region != null)
{
// region._zoneManager.remZone(this);
}
}
}
}