aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs')
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs368
1 files changed, 184 insertions, 184 deletions
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index 7e6b1af..28c9b9a 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -1,184 +1,184 @@
1using System.Collections.Generic; 1using System.Collections.Generic;
2using System.Net; 2using System.Net;
3using System.Timers; 3using System.Timers;
4using System; 4using System;
5using System.Text; 5using System.Text;
6 6
7using libsecondlife; 7using libsecondlife;
8using libsecondlife.Packets; 8using libsecondlife.Packets;
9 9
10using OpenSim.Framework; 10using OpenSim.Framework;
11using OpenSim.Framework.Interfaces; 11using OpenSim.Framework.Interfaces;
12using OpenSim.Framework.Types; 12using OpenSim.Framework.Types;
13using OpenSim.Framework.Data; 13using OpenSim.Framework.Data;
14using OpenSim.Framework.Utilities; 14using OpenSim.Framework.Utilities;
15 15
16namespace SimpleApp 16namespace SimpleApp
17{ 17{
18 public class MyNpcCharacter : IClientAPI 18 public class MyNpcCharacter : IClientAPI
19 { 19 {
20 private uint movementFlag = 0; 20 private uint movementFlag = 0;
21 private short flyState = 0; 21 private short flyState = 0;
22 private LLQuaternion bodyDirection = LLQuaternion.Identity; 22 private LLQuaternion bodyDirection = LLQuaternion.Identity;
23 private short count = 0; 23 private short count = 0;
24 24
25 public event ImprovedInstantMessage OnInstantMessage; 25 public event ImprovedInstantMessage OnInstantMessage;
26 public event ChatFromViewer OnChatFromViewer; 26 public event ChatFromViewer OnChatFromViewer;
27 public event RezObject OnRezObject; 27 public event RezObject OnRezObject;
28 public event ModifyTerrain OnModifyTerrain; 28 public event ModifyTerrain OnModifyTerrain;
29 public event SetAppearance OnSetAppearance; 29 public event SetAppearance OnSetAppearance;
30 public event StartAnim OnStartAnim; 30 public event StartAnim OnStartAnim;
31 public event LinkObjects OnLinkObjects; 31 public event LinkObjects OnLinkObjects;
32 public event RequestMapBlocks OnRequestMapBlocks; 32 public event RequestMapBlocks OnRequestMapBlocks;
33 public event TeleportLocationRequest OnTeleportLocationRequest; 33 public event TeleportLocationRequest OnTeleportLocationRequest;
34 34
35 public event GenericCall4 OnDeRezObject; 35 public event GenericCall4 OnDeRezObject;
36 public event GenericCall OnRegionHandShakeReply; 36 public event GenericCall OnRegionHandShakeReply;
37 public event GenericCall OnRequestWearables; 37 public event GenericCall OnRequestWearables;
38 public event GenericCall2 OnCompleteMovementToRegion; 38 public event GenericCall2 OnCompleteMovementToRegion;
39 public event UpdateAgent OnAgentUpdate; 39 public event UpdateAgent OnAgentUpdate;
40 public event GenericCall OnRequestAvatarsData; 40 public event GenericCall OnRequestAvatarsData;
41 public event AddNewPrim OnAddPrim; 41 public event AddNewPrim OnAddPrim;
42 public event ObjectDuplicate OnObjectDuplicate; 42 public event ObjectDuplicate OnObjectDuplicate;
43 public event UpdateVector OnGrapObject; 43 public event UpdateVector OnGrapObject;
44 public event ObjectSelect OnDeGrapObject; 44 public event ObjectSelect OnDeGrapObject;
45 public event MoveObject OnGrapUpdate; 45 public event MoveObject OnGrapUpdate;
46 46
47 public event UpdateShape OnUpdatePrimShape; 47 public event UpdateShape OnUpdatePrimShape;
48 public event ObjectSelect OnObjectSelect; 48 public event ObjectSelect OnObjectSelect;
49 public event GenericCall7 OnObjectDescription; 49 public event GenericCall7 OnObjectDescription;
50 public event GenericCall7 OnObjectName; 50 public event GenericCall7 OnObjectName;
51 public event UpdatePrimFlags OnUpdatePrimFlags; 51 public event UpdatePrimFlags OnUpdatePrimFlags;
52 public event UpdatePrimTexture OnUpdatePrimTexture; 52 public event UpdatePrimTexture OnUpdatePrimTexture;
53 public event UpdateVector OnUpdatePrimGroupPosition; 53 public event UpdateVector OnUpdatePrimGroupPosition;
54 public event UpdateVector OnUpdatePrimSinglePosition; 54 public event UpdateVector OnUpdatePrimSinglePosition;
55 public event UpdatePrimRotation OnUpdatePrimGroupRotation; 55 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
56 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; 56 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
57 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; 57 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
58 public event UpdateVector OnUpdatePrimScale; 58 public event UpdateVector OnUpdatePrimScale;
59 public event StatusChange OnChildAgentStatus; 59 public event StatusChange OnChildAgentStatus;
60 public event GenericCall2 OnStopMovement; 60 public event GenericCall2 OnStopMovement;
61 public event NewAvatar OnNewAvatar; 61 public event NewAvatar OnNewAvatar;
62 public event GenericCall6 OnRemoveAvatar; 62 public event GenericCall6 OnRemoveAvatar;
63 63
64 public event UUIDNameRequest OnNameFromUUIDRequest; 64 public event UUIDNameRequest OnNameFromUUIDRequest;
65 65
66 public event ParcelPropertiesRequest OnParcelPropertiesRequest; 66 public event ParcelPropertiesRequest OnParcelPropertiesRequest;
67 public event ParcelDivideRequest OnParcelDivideRequest; 67 public event ParcelDivideRequest OnParcelDivideRequest;
68 public event ParcelJoinRequest OnParcelJoinRequest; 68 public event ParcelJoinRequest OnParcelJoinRequest;
69 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; 69 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
70 70
71 public event ParcelSelectObjects OnParcelSelectObjects; 71 public event ParcelSelectObjects OnParcelSelectObjects;
72 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; 72 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
73 public event ObjectDeselect OnObjectDeselect; 73 public event ObjectDeselect OnObjectDeselect;
74 public event EstateOwnerMessageRequest OnEstateOwnerMessage; 74 public event EstateOwnerMessageRequest OnEstateOwnerMessage;
75 75
76 private LLUUID myID = LLUUID.Random(); 76 private LLUUID myID = LLUUID.Random();
77 public MyNpcCharacter() 77 public MyNpcCharacter()
78 { 78 {
79 79
80 } 80 }
81 81
82 public virtual LLVector3 StartPos 82 public virtual LLVector3 StartPos
83 { 83 {
84 get { return new LLVector3(128, 100, 2); } 84 get { return new LLVector3(128, 100, 2); }
85 set { } 85 set { }
86 } 86 }
87 87
88 public virtual LLUUID AgentId 88 public virtual LLUUID AgentId
89 { 89 {
90 get { return myID; } 90 get { return myID; }
91 } 91 }
92 92
93 public virtual string FirstName 93 public virtual string FirstName
94 { 94 {
95 get { return "Annoying"; } 95 get { return "Annoying"; }
96 } 96 }
97 97
98 public virtual string LastName 98 public virtual string LastName
99 { 99 {
100 get { return "NPC"; } 100 get { return "NPC"; }
101 } 101 }
102 102
103 public virtual void OutPacket(Packet newPack) { } 103 public virtual void OutPacket(Packet newPack) { }
104 public virtual void SendWearables(AvatarWearable[] wearables) { } 104 public virtual void SendWearables(AvatarWearable[] wearables) { }
105 public virtual void SendStartPingCheck(byte seq) { } 105 public virtual void SendStartPingCheck(byte seq) { }
106 public virtual void SendKillObject(ulong regionHandle, uint avatarLocalID) { } 106 public virtual void SendKillObject(ulong regionHandle, uint avatarLocalID) { }
107 public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) { } 107 public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) { }
108 public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { } 108 public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { }
109 public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { } 109 public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { }
110 public virtual void SendInstantMessage(string message, LLUUID target, string fromName) { } 110 public virtual void SendInstantMessage(string message, LLUUID target, string fromName) { }
111 public virtual void SendLayerData(float[] map) { } 111 public virtual void SendLayerData(float[] map) { }
112 public virtual void SendLayerData(int px, int py, float[] map) { } 112 public virtual void SendLayerData(int px, int py, float[] map) { }
113 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) { } 113 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) { }
114 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) { } 114 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) { }
115 public virtual AgentCircuitData RequestClientInfo() { return new AgentCircuitData(); } 115 public virtual AgentCircuitData RequestClientInfo() { return new AgentCircuitData(); }
116 public virtual void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint) { } 116 public virtual void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint) { }
117 public virtual void SendMapBlock(List<MapBlockData> mapBlocks) { } 117 public virtual void SendMapBlock(List<MapBlockData> mapBlocks) { }
118 public virtual void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) { } 118 public virtual void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) { }
119 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags) { } 119 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags) { }
120 public virtual void SendTeleportCancel() { } 120 public virtual void SendTeleportCancel() { }
121 public virtual void SendTeleportLocationStart() { } 121 public virtual void SendTeleportLocationStart() { }
122 public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { } 122 public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { }
123 123
124 public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) { } 124 public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) { }
125 public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) { } 125 public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) { }
126 126
127 public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) { } 127 public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) { }
128 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags) { } 128 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags) { }
129 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags) { } 129 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags) { }
130 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { } 130 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { }
131 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { } 131 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { }
132 public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) { } 132 public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) { }
133 133
134 public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) { } 134 public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) { }
135 public virtual void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) { } 135 public virtual void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) { }
136 public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname) { } 136 public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname) { }
137 137
138 public virtual void SendRegionHandshake(RegionInfo regionInfo) 138 public virtual void SendRegionHandshake(RegionInfo regionInfo)
139 { 139 {
140 this.OnRegionHandShakeReply(this); 140 this.OnRegionHandShakeReply(this);
141 this.OnCompleteMovementToRegion(); 141 this.OnCompleteMovementToRegion();
142 this.StartMovement(); 142 this.StartMovement();
143 } 143 }
144 144
145 public void StartMovement() 145 public void StartMovement()
146 { 146 {
147 Timer timer = new Timer(); 147 Timer timer = new Timer();
148 timer.Enabled = true; 148 timer.Enabled = true;
149 timer.Interval = 500; 149 timer.Interval = 500;
150 timer.Elapsed += new ElapsedEventHandler(this.Heartbeat); 150 timer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
151 } 151 }
152 152
153 public void Heartbeat(object sender, EventArgs e) 153 public void Heartbeat(object sender, EventArgs e)
154 { 154 {
155 Encoding enc = Encoding.ASCII; 155 Encoding enc = Encoding.ASCII;
156 156
157 this.OnAgentUpdate(this, movementFlag, bodyDirection); 157 this.OnAgentUpdate(this, movementFlag, bodyDirection);
158 158
159 if (this.flyState == 0) 159 if (this.flyState == 0)
160 { 160 {
161 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG; 161 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG;
162 flyState = 1; 162 flyState = 1;
163 } 163 }
164 else if (this.flyState == 1) 164 else if (this.flyState == 1)
165 { 165 {
166 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS; 166 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS;
167 flyState = 2; 167 flyState = 2;
168 } 168 }
169 else 169 else
170 { 170 {
171 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY; 171 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY;
172 flyState = 0; 172 flyState = 0;
173 } 173 }
174 174
175 if (count >= 40) 175 if (count >= 40)
176 { 176 {
177 this.OnChatFromViewer(enc.GetBytes("Kind of quiet around here, isn't it! \0"), 2, new LLVector3(128, 128, 26), this.FirstName + " " + this.LastName, this.AgentId); 177 this.OnChatFromViewer(enc.GetBytes("Kind of quiet around here, isn't it! \0"), 2, new LLVector3(128, 128, 26), this.FirstName + " " + this.LastName, this.AgentId);
178 count = -1; 178 count = -1;
179 } 179 }
180 180
181 count++; 181 count++;
182 } 182 }
183 } 183 }
184} 184}