Example #1
0
		void Self_OnChat(string message, MainAvatar.ChatAudibleLevel audible, MainAvatar.ChatType type, 
            MainAvatar.ChatSourceType sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position)
		{
			if (message.Length > 0 && Client.MasterKey == id)
			{
			    Client.Self.Chat(message, 0, MainAvatar.ChatType.Normal);
			}
		}
Example #2
0
 private void Avatars_OnEffect(MainAvatar.EffectType type, LLUUID sourceID, LLUUID targetID, 
     LLVector3d targetPos, float duration, LLUUID id)
 {
     if (ShowEffects)
         Console.WriteLine(
         "ViewerEffect [{0}]: SourceID: {1} TargetID: {2} TargetPos: {3} Duration: {4} ID: {5}",
         type, sourceID.ToStringHyphenated(), targetID.ToStringHyphenated(), targetPos, duration,
         id.ToStringHyphenated());
 }
Example #3
0
 private void Avatars_OnLookAt(LLUUID sourceID, LLUUID targetID, LLVector3d targetPos, 
     MainAvatar.LookAtType lookType, float duration, LLUUID id)
 {
     if (ShowEffects)
         Console.WriteLine(
         "ViewerEffect [LookAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}",
         sourceID.ToStringHyphenated(), targetID.ToStringHyphenated(), targetPos, lookType, duration,
         id.ToStringHyphenated());
 }
Example #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public SecondLife()
 {
     Network = new NetworkManager(this);
     Parcels = new ParcelManager(this);
     Self    = new MainAvatar(this);
     Avatars = new AvatarManager(this);
     Grid    = new GridManager(this);
     Objects = new ObjectManager(this);
     Groups  = new GroupManager(this);
     Debug   = true;
 }
Example #5
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public SecondLife()
 {
     // These are order-dependant
     Network   = new NetworkManager(this);
     Settings  = new Settings(this);
     Parcels   = new ParcelManager(this);
     Self      = new MainAvatar(this);
     Avatars   = new AvatarManager(this);
     Grid      = new GridManager(this);
     Objects   = new ObjectManager(this);
     Groups    = new GroupManager(this);
     Assets    = new AssetManager(this);
     Images    = new ImageManager(this);
     Inventory = new InventoryManager(this);
     Throttle  = new AgentThrottle(this);
 }
Example #6
0
        /// <summary>
        /// A psuedo-realistic chat function that uses the typing sound and
        /// animation, types at a given rate, and randomly pauses. This 
        /// function will block until the message has been sent
        /// </summary>
        /// <param name="client">A reference to the client that will chat</param>
        /// <param name="message">The chat message to send</param>
        /// <param name="type">The chat type (usually Normal, Whisper or Shout)</param>
        /// <param name="cps">Characters per second rate for chatting</param>
        public static void Chat(SecondLife client, string message, MainAvatar.ChatType type, int cps)
        {
            Random rand = new Random();
            int characters = 0;
            bool typing = true;

            // Start typing
            client.Self.Chat(String.Empty, 0, MainAvatar.ChatType.StartTyping);
            client.Self.AnimationStart(TypingAnimation);

            while (characters < message.Length)
            {
                if (!typing)
                {
                    // Start typing again
                    client.Self.Chat(String.Empty, 0, MainAvatar.ChatType.StartTyping);
                    client.Self.AnimationStart(TypingAnimation);
                    typing = true;
                }
                else
                {
                    // Randomly pause typing
                    if (rand.Next(10) >= 9)
                    {
                        client.Self.Chat(String.Empty, 0, MainAvatar.ChatType.StopTyping);
                        client.Self.AnimationStop(TypingAnimation);
                        typing = false;
                    }
                }

                // Sleep for a second and increase the amount of characters we've typed
                System.Threading.Thread.Sleep(1000);
                characters += cps;
            }

            // Send the message
            client.Self.Chat(message, 0, type);

            // Stop typing
            client.Self.Chat(String.Empty, 0, MainAvatar.ChatType.StopTyping);
            client.Self.AnimationStop(TypingAnimation);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public SecondLife()
 {
     Network = new NetworkManager(this);
     Parcels = new ParcelManager(this);
     Self = new MainAvatar(this);
     Avatars = new AvatarManager(this);
     Grid = new GridManager(this);
     Objects = new ObjectManager(this);
     Groups = new GroupManager(this);
     Debug = true;
 }
Example #8
0
 private void SetControlFlag(MainAvatar.ControlFlags flag, bool value)
 {
     if (value) agentControls |= (uint)flag;
     else agentControls &= ~((uint)flag);
 }
Example #9
0
 private bool GetControlFlag(MainAvatar.ControlFlags flag)
 {
     return (agentControls & (uint)flag) != 0;
 }
Example #10
0
 void Avatars_OnPointAt(LLUUID sourceID, LLUUID targetID, LLVector3d targetPos, 
     MainAvatar.PointAtType pointType, float duration, LLUUID id)
 {
     if (sourceID == Client.MasterKey)
     {
         //Client.DebugLog("Master is now selecting " + targetID.ToStringHyphenated());
         SelectedObject = targetID;
     }
 }
Example #11
0
        private void Self_OnInstantMessage(LLUUID fromAgentID, string fromAgentName, LLUUID toAgentID, 
            uint parentEstateID, LLUUID regionID, LLVector3 position, MainAvatar.InstantMessageDialog dialog, 
            bool groupIM, LLUUID imSessionID, DateTime timestamp, string message, 
            MainAvatar.InstantMessageOnline offline, byte[] binaryBucket)
        {
            if (MasterKey != LLUUID.Zero)
            {
                if (fromAgentID != MasterKey)
                {
                    // Received an IM from someone that is not the bot's master, ignore
                    Console.WriteLine("<IM>" + fromAgentName + " (not master): " + message + "@"  + regionID.ToString() + ":" + position.ToString() );
                    return;
                }
            }
            else
            {
                if (GroupMembers != null && !GroupMembers.ContainsKey(fromAgentID))
                {
                    // Received an IM from someone outside the bot's group, ignore
                    Console.WriteLine("<IM>" + fromAgentName + " (not in group): " + message + "@" + regionID.ToString() + ":" + position.ToString());
                    return;
                }
            }

            Console.WriteLine("<IM>" + fromAgentName + ": " + message);

            if (dialog == MainAvatar.InstantMessageDialog.RequestTeleport)
            {
                Console.WriteLine("Accepting teleport lure.");
                Self.TeleportLureRespond(fromAgentID, true);
            }
            else
            {
                if (dialog == MainAvatar.InstantMessageDialog.InventoryOffered)
                {
                    Console.WriteLine("Accepting inventory offer.");

                    Self.InstantMessage(Self.FirstName + " " + Self.LastName, fromAgentID, String.Empty,
                        imSessionID, MainAvatar.InstantMessageDialog.InventoryAccepted,
                        MainAvatar.InstantMessageOnline.Offline, Self.Position, LLUUID.Zero,
                        Self.InventoryRootFolderUUID.GetBytes());
                }
                else
                {
                    DoCommand(message, fromAgentID, imSessionID);
                }
            }
        }
Example #12
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public SecondLife()
 {
     // These are order-dependant
     Network = new NetworkManager(this);
     Settings = new Settings(this);
     Parcels = new ParcelManager(this);
     Self = new MainAvatar(this);
     Avatars = new AvatarManager(this);
     Friends = new FriendManager(this);
     Grid = new GridManager(this);
     Objects = new ObjectManager(this);
     Groups = new GroupManager(this);
     Assets = new libsecondlife.AssetSystem.AssetManager(this);
     Appearance = new libsecondlife.AssetSystem.AppearanceManager(this);
     Images = new ImageManager(this);
     Inventory = new InventoryManager(this);
     Directory = new DirectoryManager(this);
     Terrain = new TerrainManager(this);
     Throttle = new AgentThrottle(this);
 }
Example #13
0
        /// <summary>
        /// Used to track when inventory is dropped onto/into agent
        /// </summary>
        /// <param name="fromAgentID"></param>
        /// <param name="fromAgentName"></param>
        /// <param name="toAgentID"></param>
        /// <param name="parentEstateID"></param>
        /// <param name="regionID"></param>
        /// <param name="position"></param>
        /// <param name="dialog"></param>
        /// <param name="groupIM"></param>
        /// <param name="imSessionID"></param>
        /// <param name="timestamp"></param>
        /// <param name="message"></param>
        /// <param name="offline"></param>
        /// <param name="binaryBucket"></param>
        void Self_OnInstantMessage(LLUUID fromAgentID, string fromAgentName, LLUUID toAgentID, uint parentEstateID, 
            LLUUID regionID, LLVector3 position, MainAvatar.InstantMessageDialog dialog, bool groupIM, 
            LLUUID imSessionID, DateTime timestamp,  string message, MainAvatar.InstantMessageOnline offline, 
            byte[] binaryBucket)
        {
            if ((dialog == MainAvatar.InstantMessageDialog.InventoryOffered) && ((OnInventoryItemReceived != null) || (OnInventoryFolderReceived !=null)))
            {
                sbyte IncomingItemType = (sbyte)binaryBucket[0];
                LLUUID IncomingUUID = new LLUUID(binaryBucket, 1);

                // Update root folders
                InventoryFolder root = GetRootFolder();
                if (root.GetContents().Count == 0)
                {
                    root.RequestDownloadContents(false, true, false).RequestComplete.WaitOne(3000, false);
                }

                // Handle the case of the incoming inventory folder
                if (IncomingItemType == (sbyte)InventoryManager.InventoryType.Folder)
                {
                    if (OnInventoryFolderReceived == null)
                    {
                        // Short-circuit early exit, we're not interested...
                        return;
                    }

                    InventoryFolder iFolder = null;
                    int numAttempts = 6;
                    int timeBetweenAttempts = 500;
                    while( numAttempts-- > 0 )
                    {
                        foreach( InventoryBase ib in root.GetContents() )
                        {
                            if (ib is InventoryFolder)
                            {
                                InventoryFolder tiFolder = (InventoryFolder)ib;
                                if (tiFolder.FolderID == IncomingUUID)
                                {
                                    iFolder = tiFolder;
                                    break;
                                }
                            }
                        }
                        if ( iFolder != null)
                        {
                            try { OnInventoryFolderReceived(fromAgentID, fromAgentName, parentEstateID, regionID, position, timestamp, iFolder); }
                            catch (Exception e) { slClient.Log(e.ToString(), Helpers.LogLevel.Error); }
                            return;
                        } else {
                            Thread.Sleep(timeBetweenAttempts);
                            timeBetweenAttempts *= 2;
                            root.RequestDownloadContents(false, true, false).RequestComplete.WaitOne(3000, false);
                        }
                    }

                    slClient.Log("Incoming folder [" + IncomingUUID.ToStringHyphenated() + "] not found in inventory.", Helpers.LogLevel.Error);
                    return;
                }

                if (OnInventoryItemReceived == null)
                {
                    // Short-circuit, early exit, we're not interested
                    return;
                }

                // Make sure we have a folder lookup by type table ready.
                lock (FolderByType)
                {
                    if (FolderByType.Count == 0)
                    {
                        foreach (InventoryBase ib in root.GetContents())
                        {
                            if (ib is InventoryFolder)
                            {
                                InventoryFolder iFolder = (InventoryFolder)ib;
                                FolderByType[iFolder.Type] = iFolder;
                            }
                        }
                    }
                }

                // Get a reference to the incoming/receiving folder
                if (!FolderByType.ContainsKey(IncomingItemType))
                {
                    slClient.Log("Incoming item specifies type (" + IncomingItemType  + ") with no matching inventory folder found.", Helpers.LogLevel.Error);
                }


                InventoryFolder incomingFolder = FolderByType[IncomingItemType];
                InventoryItem incomingItem = null;

                // lock just incase another item comes into the same directory while processing this one.
                lock (incomingFolder)
                {
                    // Refresh contents of receiving folder
                    incomingFolder.RequestDownloadContents(false, false, true).RequestComplete.WaitOne(3000, false);

                    int numAttempts = 2;
                    while( numAttempts-- > 0 )
                    {
                        // Search folder for incoming item
                        foreach (InventoryBase ib2 in incomingFolder.GetContents())
                        {
                            if (ib2 is InventoryItem)
                            {
                                InventoryItem tiItem = (InventoryItem)ib2;

                                if (tiItem.ItemID == IncomingUUID)
                                {
                                    incomingItem = tiItem;
                                    break;
                                }
                            }
                        }
                        // If found, send out notification
                        if (incomingItem != null)
                        {
                            try { OnInventoryItemReceived(fromAgentID, fromAgentName, parentEstateID, regionID, position, timestamp, incomingItem); }
                            catch (Exception e) { slClient.Log(e.ToString(), Helpers.LogLevel.Error); }
                            return;
                        }
                        else
                        {
                            Thread.Sleep(500);
                            incomingFolder.RequestDownloadContents(false, false, true).RequestComplete.WaitOne(3000, false);
                        }
                    }
                }
                slClient.Log("Incoming item/folder [" + IncomingUUID.ToStringHyphenated() + "] not found in inventory.", Helpers.LogLevel.Error);

            }
        }
        void Self_OnTeleport(Simulator currentSim, string message, MainAvatar.TeleportStatus status)
        {
            Console.WriteLine(message);

            if (status == MainAvatar.TeleportStatus.Finished || status == MainAvatar.TeleportStatus.Failed)
            {
                DoneTeleporting = true;
            }
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 public SecondLife()
 {
     // These are order-dependant
     Network = new NetworkManager(this);
     Settings = new Settings(this);
     Parcels = new ParcelManager(this);
     Self = new MainAvatar(this);
     Avatars = new AvatarManager(this);
     Grid = new GridManager(this);
     Objects = new ObjectManager(this);
     Groups = new GroupManager(this);
     Assets = new AssetManager(this);
     Images = new ImageManager(this);
     Inventory = new InventoryManager(this);
     Throttle = new AgentThrottle(this);
 }
        private void OnTeleportHandler(Simulator currentSim, string message, MainAvatar.TeleportStatus status)
        {
            switch (status)
            {
                case MainAvatar.TeleportStatus.None:
                    break;
                case MainAvatar.TeleportStatus.Start:
                    break;
                case MainAvatar.TeleportStatus.Progress:
                    break;
                case MainAvatar.TeleportStatus.Failed:
                    DoneTeleporting = true;
                    break;
                case MainAvatar.TeleportStatus.Finished:
                    DoneTeleporting = true;
                    break;
            }

            tpMessage = message;
            tpStatus = status;
        }
Example #17
0
        /// <summary>
        /// Sends camera and action updates to the server including the 
        /// position and orientation of our camera, and a ControlFlags field
        /// specifying our current movement actions
        /// </summary>
        /// <param name="controlFlags"></param>
        /// <param name="position"></param>
        /// <param name="forwardAxis"></param>
        /// <param name="leftAxis"></param>
        /// <param name="upAxis"></param>
        /// <param name="bodyRotation"></param>
        /// <param name="headRotation"></param>
        /// <param name="farClip"></param>
        /// <param name="reliable"></param>
        public void UpdateCamera(MainAvatar.ControlFlags controlFlags, LLVector3 position, LLVector3 forwardAxis,
            LLVector3 leftAxis, LLVector3 upAxis, LLQuaternion bodyRotation, LLQuaternion headRotation, float farClip,
            AgentFlags flags, AgentState state, bool reliable)
        {
            AgentUpdatePacket update = new AgentUpdatePacket();

            update.AgentData.AgentID = Client.Network.AgentID;
            update.AgentData.SessionID = Client.Network.SessionID;
            update.AgentData.BodyRotation = bodyRotation;
            update.AgentData.HeadRotation = headRotation;
            update.AgentData.CameraCenter = position;
            update.AgentData.CameraAtAxis = forwardAxis;
            update.AgentData.CameraLeftAxis = leftAxis;
            update.AgentData.CameraUpAxis = upAxis;
            update.AgentData.Far = farClip;
            update.AgentData.ControlFlags = (uint)controlFlags;
            update.AgentData.Flags = (byte)flags;
            update.AgentData.State = (byte)state;
            update.Header.Reliable = reliable;

            Client.Network.SendPacket(update);
        }