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