From 94af93874226bf4441a35bfd4cf498e9ed83ccf5 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 15 Aug 2007 21:24:25 +0000 Subject: The 'Party Party Groupie Groupie Life is a game' commit: * Added prototypical MoneyBalance support * Finalized konceptual touch wiring * Turned SimpleApp into a tedious harvesting game. --- OpenSim/Framework/General/Interfaces/IClientAPI.cs | 1 + OpenSim/Framework/General/NullClientAPI.cs | 5 +++ .../ClientStack/ClientView.ProcessPackets.cs | 23 ++++++++++- OpenSim/Region/ClientStack/ClientView.cs | 2 + OpenSim/Region/Environment/PermissionManager.cs | 15 +++++-- .../Environment/Scenes/Scene.PacketHandlers.cs | 2 +- .../Region/Environment/Scenes/SceneObjectGroup.cs | 23 +++++++++++ .../Region/Environment/Scenes/SceneObjectPart.cs | 4 ++ OpenSim/Region/Examples/SimpleApp/ComplexObject.cs | 23 +++++++++++ .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 5 +++ OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 47 ++++++++++++---------- 11 files changed, 123 insertions(+), 27 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index ff794f9..f39d0c7 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 876c9b3..e85b88f 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 1e3685b..f380c25 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 1375f6c..5a60096 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 2698d3f..1daf5c3 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( !m_scene.Entities.ContainsKey( objId )) + { + return false; + } + // If it's not an object, we cant edit it. - if (!(m_scene.Entities[obj] is SceneObjectGroup)) + if (!(m_scene.Entities[objId] is SceneObjectGroup)) + { return false; - - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + } + + 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 afa4ea5..10bdd54 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 3bd83aa..77d936d 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 c4752a5..8e570d4 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 b1da33a..5821b9f 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 c0132f5..8bd7496 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 92dd61b..6cf8974 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 -- cgit v1.1