diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index ff794f987b..f39d0c7beb 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -216,5 +216,6 @@ namespace OpenSim.Framework.Interfaces void SendAlertMessage(string message); void SendAgentAlertMessage(string message, bool modal); void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url); + bool AddMoney( int debit ); } } diff --git a/OpenSim/Framework/General/NullClientAPI.cs b/OpenSim/Framework/General/NullClientAPI.cs index 876c9b3bf6..e85b88fd60 100644 --- a/OpenSim/Framework/General/NullClientAPI.cs +++ b/OpenSim/Framework/General/NullClientAPI.cs @@ -145,6 +145,11 @@ namespace OpenSim.Framework public void SendAgentAlertMessage(string message, bool modal) { } public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { } + + public bool AddMoney(int debit) + { + return false; + } } } diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 1e3685bc64..f380c257f5 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -38,6 +38,27 @@ namespace OpenSim.Region.ClientStack { public partial class ClientView { + private int m_moneyBalance; + + public int MoneyBalance + { + get { return m_moneyBalance; } + } + + public bool AddMoney( int debit ) + { + if( m_moneyBalance + debit >= 0 ) + { + m_moneyBalance += debit; + SendMoneyBalance( LLUUID.Zero, true, Helpers.StringToField("Poof Poof!"), m_moneyBalance ); + return true; + } + else + { + return false; + } + } + protected override void ProcessInPacket(Packet Pack) { ack_pack(Pack); @@ -521,7 +542,7 @@ namespace OpenSim.Region.ClientStack #endregion case PacketType.MoneyBalanceRequest: - this.SendMoneyBalance(LLUUID.Zero, true, new byte[0], 1000); + SendMoneyBalance(LLUUID.Zero, true, new byte[0], MoneyBalance); break; case PacketType.UUIDNameRequest: UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 1375f6cfde..5a600967ee 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -87,6 +87,8 @@ namespace OpenSim.Region.ClientStack public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IScene scene, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AgentCircuitManager authenSessions ) { + m_moneyBalance = 1000; + m_scene = scene; m_clientThreads = clientThreads; m_assetCache = assetCache; diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 2698d3f2b6..1daf5c3958 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -91,16 +91,23 @@ namespace OpenSim.Region.Environment #region Object Permissions - protected virtual bool GenericObjectPermission(LLUUID user, LLUUID obj) + protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) { // Default: deny bool permission = false; - // If it's not an object, we cant edit it. - if (!(m_scene.Entities[obj] is SceneObjectGroup)) + if( !m_scene.Entities.ContainsKey( objId )) + { return false; - - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + } + + // If it's not an object, we cant edit it. + if (!(m_scene.Entities[objId] is SceneObjectGroup)) + { + return false; + } + + SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objId]; LLUUID taskOwner = null; // Object owners should be able to edit their own content diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index afa4ea5bfd..10bdd54517 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -752,7 +752,7 @@ namespace OpenSim.Region.Environment.Scenes } } - public void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) + public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) { this.EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient); } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 3bd83aae72..77d936d62a 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -863,5 +863,28 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.Text = text; m_rootPart.ScheduleTerseUpdate(); } + + public void ObjectGrabHandler(uint localId, LLVector3 offsetPos, IClientAPI remoteClient) + { + if( m_rootPart.LocalID == localId ) + { + OnGrabGroup(offsetPos, remoteClient); + } + else + { + SceneObjectPart part = GetChildPrim(localId); + OnGrabPart(part, offsetPos, remoteClient); + } + } + + public virtual void OnGrabPart(SceneObjectPart part, LLVector3 offsetPos, IClientAPI remoteClient) + { + part.OnGrab(offsetPos, remoteClient); + } + + public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) + { + + } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index c4752a5e34..8e570d4d18 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -566,6 +566,10 @@ namespace OpenSim.Region.Environment.Scenes public virtual void UpdateMovement() { } + + public virtual void OnGrab(LLVector3 offsetPos, IClientAPI remoteClient) + { + } } } diff --git a/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs b/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs index b1da33a751..5821b9fe2f 100644 --- a/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs +++ b/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs @@ -5,6 +5,7 @@ using OpenSim.Region.Environment.Scenes; using Axiom.Math; using libsecondlife; using OpenSim.Framework.Types; +using OpenSim.Framework.Interfaces; namespace SimpleApp { @@ -35,6 +36,8 @@ namespace SimpleApp base.UpdateMovement(); } + + public ComplexObject(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos ) : base(scene, regionHandle, ownerID, localID, pos, BoxShape.Default ) { @@ -51,5 +54,25 @@ namespace SimpleApp UpdateParentIDs(); } + + public override void OnGrabPart(SceneObjectPart part, LLVector3 offsetPos, IClientAPI remoteClient) + { + m_parts.Remove(part.UUID); + remoteClient.SendKillObject(m_regionHandle, part.LocalID); + remoteClient.AddMoney(1); + remoteClient.SendChatMessage("Poof!", 1, Pos, "Party Party", LLUUID.Zero); + } + + public override void OnGrabGroup( LLVector3 offsetPos, IClientAPI remoteClient) + { + if( m_parts.Count == 1 ) + { + m_parts.Remove(m_rootPart.UUID); + m_scene.RemoveEntity(this); + remoteClient.SendKillObject(m_regionHandle, m_rootPart.LocalID); + remoteClient.AddMoney(50); + remoteClient.SendChatMessage("KABLAM!!!", 1, Pos, "Groupie Groupie", LLUUID.Zero); + } + } } } diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index c0132f539a..8bd7496c66 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -202,5 +202,10 @@ namespace SimpleApp count++; } + + public bool AddMoney(int debit) + { + return false; + } } } diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index 92dd61b706..6cf8974c9a 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs @@ -41,38 +41,43 @@ namespace SimpleApp this.CreateTerrainTexture(); } + public override void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) + { + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + SceneObjectGroup obj = ent as SceneObjectGroup; + + if( obj.HasChildPrim( localID ) ) + { + obj.ObjectGrabHandler(localID, offsetPos, remoteClient); + return; + } + } + } + + base.ProcessObjectGrab(localID, offsetPos, remoteClient); + } + #region IWorld Members override public void AddNewClient(IClientAPI client, bool child) { + SubscribeToClientEvents(client); + + ScenePresence avatar = CreateAndAddScenePresence(client); + avatar.Pos = new LLVector3(128, 128, 26); + LLVector3 pos = new LLVector3(128, 128, 128); - - client.OnRegionHandShakeReply += SendLayerData; - /*client.OnChatFromViewer += - delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) - { - // Echo it (so you know what you typed) - client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); - client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero ); - }; - */ - client.OnChatFromViewer += this.SimChat; - client.OnAddPrim += AddNewPrim; - client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; - client.OnRequestMapBlocks += this.RequestMapBlocks; - client.OnTeleportLocationRequest += this.RequestTeleportLocation; - client.OnGrabUpdate += this.MoveObject; - client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; - + client.OnCompleteMovementToRegion += delegate() { client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero ); }; - client.SendRegionHandshake(m_regInfo); - ScenePresence avatar = CreateAndAddScenePresence(client); - avatar.Pos = new LLVector3(128, 128, 26); + client.SendRegionHandshake(m_regInfo); } #endregion