public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) { try { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this); prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount); PhysicsVector pVec = new PhysicsVector(prim.Pos.X, prim.Pos.Y, prim.Pos.Z); PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f); if (OpenSim.world.Avatar.PhysicsEngineFlying) { lock (this.LockPhysicsEngine) { prim.PhysActor = this.phyScene.AddPrim(pVec, pSize); } } this.Entities.Add(prim.uuid, prim); this._primCount++; } catch (Exception e) { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Failed with exception " + e.ToString()); } }
/// <summary> /// /// </summary> /// <param name="prim"></param> /// <param name="position"></param> /// <param name="avatarPosition"></param> public void RezObject(PrimObject prim, LLVector3 position, LLVector3 rayStart, LLUUID groupID) { ObjectAddPacket add = new ObjectAddPacket(); add.AgentData.AgentID = Client.Network.AgentID; add.AgentData.SessionID = Client.Network.SessionID; add.AgentData.GroupID = groupID; // TODO: Why 2? add.ObjectData.AddFlags = 2; add.ObjectData.BypassRaycast = 1; add.ObjectData.Material = (byte)prim.Material; add.ObjectData.PathBegin = PrimObject.PathBeginByte(prim.PathBegin); add.ObjectData.PathCurve = (byte)prim.PathCurve; add.ObjectData.PathEnd = PrimObject.PathEndByte(prim.PathEnd); add.ObjectData.PathRadiusOffset = PrimObject.PathRadiusOffsetByte(prim.PathRadiusOffset); add.ObjectData.PathRevolutions = PrimObject.PathRevolutionsByte(prim.PathRevolutions); add.ObjectData.PathScaleX = PrimObject.PathScaleByte(prim.PathScaleX); add.ObjectData.PathScaleY = PrimObject.PathScaleByte(prim.PathScaleY); add.ObjectData.PathShearX = PrimObject.PathShearByte(prim.PathShearX); add.ObjectData.PathShearY = PrimObject.PathShearByte(prim.PathShearY); add.ObjectData.PathSkew = PrimObject.PathSkewByte(prim.PathSkew); add.ObjectData.PathTaperX = PrimObject.PathTaperByte(prim.PathTaperX); add.ObjectData.PathTaperY = PrimObject.PathTaperByte(prim.PathTaperY); add.ObjectData.PathTwist = PrimObject.PathTwistByte(prim.PathTwist); add.ObjectData.PathTwistBegin = PrimObject.PathTwistByte(prim.PathTwistBegin); add.ObjectData.PCode = (byte)prim.PCode; add.ObjectData.ProfileBegin = PrimObject.ProfileBeginByte(prim.ProfileBegin); add.ObjectData.ProfileCurve = (byte)prim.ProfileCurve; add.ObjectData.ProfileEnd = PrimObject.ProfileEndByte(prim.ProfileEnd); add.ObjectData.ProfileHollow = (byte)prim.ProfileHollow; add.ObjectData.RayEnd = position; add.ObjectData.RayEndIsIntersection = 0; add.ObjectData.RayStart = rayStart; add.ObjectData.RayTargetID = LLUUID.GenerateUUID(); add.ObjectData.Rotation = prim.Rotation; add.ObjectData.Scale = prim.Scale; add.ObjectData.State = (byte)prim.State; if (prim.Textures != null) { add.ObjectData.TextureEntry = prim.Textures.ToBytes(); } else { add.ObjectData.TextureEntry = new byte[0]; } Client.Network.SendPacket(add); }
/// <summary> /// Rez grass and ground cover /// </summary> /// <param name="simulator">A reference to the <seealso cref="OpenMetaverse.Simulator"/> object where the object resides</param> /// <param name="scale">The size of the grass</param> /// <param name="rotation">The rotation of the grass</param> /// <param name="position">The position of the grass</param> /// <param name="grassType">The type of grass from the <seealso cref="Grass"/> enum</param> /// <param name="groupOwner">The <seealso cref="UUID"/> of the group to set the tree to, /// or UUID.Zero if no group is to be set</param> public void AddGrass(Simulator simulator, Vector3 scale, Quaternion rotation, Vector3 position, Grass grassType, UUID groupOwner) { ObjectAddPacket add = new ObjectAddPacket(); add.AgentData.AgentID = Client.Self.AgentID; add.AgentData.SessionID = Client.Self.SessionID; add.AgentData.GroupID = groupOwner; add.ObjectData.BypassRaycast = 1; add.ObjectData.Material = 3; add.ObjectData.PathCurve = 16; add.ObjectData.PCode = (byte)PCode.Grass; add.ObjectData.RayEnd = position; add.ObjectData.RayStart = position; add.ObjectData.RayTargetID = UUID.Zero; add.ObjectData.Rotation = rotation; add.ObjectData.Scale = scale; add.ObjectData.State = (byte)grassType; Client.Network.SendPacket(add, simulator); }
/// <summary> /// Create (rez) a new prim object in a simulator /// </summary> /// <param name="simulator">A reference to the <seealso cref="Simulator"/> object to place the object in</param> /// <param name="prim">Data describing the prim object to rez</param> /// <param name="groupID">Group ID that this prim will be set to, or UUID.Zero if you /// do not want the object to be associated with a specific group</param> /// <param name="position">An approximation of the position at which to rez the prim</param> /// <param name="scale">Scale vector to size this prim</param> /// <param name="rotation">Rotation quaternion to rotate this prim</param> /// <param name="createFlags">Specify the <seealso cref="PrimFlags"/></param> /// <remarks>Due to the way client prim rezzing is done on the server, /// the requested position for an object is only close to where the prim /// actually ends up. If you desire exact placement you'll need to /// follow up by moving the object after it has been created. This /// function will not set textures, light and flexible data, or other /// extended primitive properties</remarks> public void AddPrim(Simulator simulator, Primitive.ConstructionData prim, UUID groupID, Vector3 position, Vector3 scale, Quaternion rotation, PrimFlags createFlags) { ObjectAddPacket packet = new ObjectAddPacket(); packet.AgentData.AgentID = Client.Self.AgentID; packet.AgentData.SessionID = Client.Self.SessionID; packet.AgentData.GroupID = groupID; packet.ObjectData.State = prim.State; packet.ObjectData.AddFlags = (uint)createFlags; packet.ObjectData.PCode = (byte)PCode.Prim; packet.ObjectData.Material = (byte)prim.Material; packet.ObjectData.Scale = scale; packet.ObjectData.Rotation = rotation; packet.ObjectData.PathCurve = (byte)prim.PathCurve; packet.ObjectData.PathBegin = Primitive.PackBeginCut(prim.PathBegin); packet.ObjectData.PathEnd = Primitive.PackEndCut(prim.PathEnd); packet.ObjectData.PathRadiusOffset = Primitive.PackPathTwist(prim.PathRadiusOffset); packet.ObjectData.PathRevolutions = Primitive.PackPathRevolutions(prim.PathRevolutions); packet.ObjectData.PathScaleX = Primitive.PackPathScale(prim.PathScaleX); packet.ObjectData.PathScaleY = Primitive.PackPathScale(prim.PathScaleY); packet.ObjectData.PathShearX = (byte)Primitive.PackPathShear(prim.PathShearX); packet.ObjectData.PathShearY = (byte)Primitive.PackPathShear(prim.PathShearY); packet.ObjectData.PathSkew = Primitive.PackPathTwist(prim.PathSkew); packet.ObjectData.PathTaperX = Primitive.PackPathTaper(prim.PathTaperX); packet.ObjectData.PathTaperY = Primitive.PackPathTaper(prim.PathTaperY); packet.ObjectData.PathTwist = Primitive.PackPathTwist(prim.PathTwist); packet.ObjectData.PathTwistBegin = Primitive.PackPathTwist(prim.PathTwistBegin); packet.ObjectData.ProfileCurve = prim.profileCurve; packet.ObjectData.ProfileBegin = Primitive.PackBeginCut(prim.ProfileBegin); packet.ObjectData.ProfileEnd = Primitive.PackEndCut(prim.ProfileEnd); packet.ObjectData.ProfileHollow = Primitive.PackProfileHollow(prim.ProfileHollow); packet.ObjectData.RayStart = position; packet.ObjectData.RayEnd = position; packet.ObjectData.RayEndIsIntersection = 0; packet.ObjectData.RayTargetID = UUID.Zero; packet.ObjectData.BypassRaycast = 1; Client.Network.SendPacket(packet, simulator); }
public void platHigh(int c) { Vector3 where = new Vector3(shared.CameraPosition.X, shared.CameraPosition.Y, (float)(c - 5)); System.Timers.Timer myTimer = new System.Timers.Timer(10000); PacketDelegate replyCallback = delegate(Packet p, IPEndPoint s) { return null; }; System.Timers.ElapsedEventHandler timerCallback = delegate(object sender, System.Timers.ElapsedEventArgs e) { proxy.RemoveDelegate(PacketType.ObjectSelect, Direction.Outgoing, replyCallback); proxy.RemoveDelegate(PacketType.ObjectDeselect, Direction.Outgoing, replyCallback); myTimer.Stop(); }; proxy.AddDelegate(PacketType.ObjectDeselect, Direction.Outgoing, replyCallback); proxy.AddDelegate(PacketType.ObjectSelect, Direction.Outgoing, replyCallback); myTimer.Elapsed += timerCallback; myTimer.Start(); ObjectAddPacket a = new ObjectAddPacket(); a.Type = PacketType.ObjectAdd; a.AgentData = new ObjectAddPacket.AgentDataBlock(); a.AgentData.AgentID = frame.AgentID; a.AgentData.GroupID = UUID.Zero; a.AgentData.SessionID = frame.SessionID; a.ObjectData = new ObjectAddPacket.ObjectDataBlock(); a.ObjectData.PCode = 9; a.ObjectData.Material = 4; a.ObjectData.AddFlags = 2; a.ObjectData.PathCurve = 48; a.ObjectData.ProfileCurve = 1; a.ObjectData.PathBegin = 0; a.ObjectData.PathEnd = 0; a.ObjectData.PathScaleX = 0; a.ObjectData.PathScaleY = 0; a.ObjectData.PathShearX = 0; a.ObjectData.PathShearY = 0; a.ObjectData.PathTwist = 0; a.ObjectData.PathTwistBegin = 0; a.ObjectData.PathRadiusOffset = 0; a.ObjectData.PathTaperX = 0; a.ObjectData.PathTaperY = 0; a.ObjectData.PathRevolutions = 0; a.ObjectData.PathSkew = 0; a.ObjectData.ProfileBegin = 0; a.ObjectData.ProfileEnd = 0; a.ObjectData.ProfileHollow = 0; a.ObjectData.BypassRaycast = 1; a.ObjectData.RayStart = where; a.ObjectData.RayEnd = where; a.ObjectData.RayTargetID = UUID.Zero; a.ObjectData.RayEndIsIntersection = 0; a.ObjectData.Scale = new Vector3((float)0.01, (float)10, (float)10); a.ObjectData.Rotation = new Quaternion((float)0, (float)0.70711, (float)0, (float)0.70711); a.ObjectData.State = 0; a.Header.Reliable = true; proxy.InjectPacket(a, Direction.Outgoing); }
public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) { ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); objupdate.RegionData.RegionHandle = m_regionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; PrimData PData = new PrimData(); this.primData = PData; this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); objupdate.ObjectData[0].PSBlock = new byte[0]; objupdate.ObjectData[0].ExtraParams = new byte[1]; objupdate.ObjectData[0].MediaURL = new byte[0]; objupdate.ObjectData[0].NameValue = new byte[0]; objupdate.ObjectData[0].Text = new byte[0]; objupdate.ObjectData[0].TextColor = new byte[4]; objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0); objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0); objupdate.ObjectData[0].Material = 3; objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456; objupdate.ObjectData[0].TextureAnim = new byte[0]; objupdate.ObjectData[0].Sound = LLUUID.Zero; LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); this.primData.Texture = objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); objupdate.ObjectData[0].State = 0; objupdate.ObjectData[0].Data = new byte[0]; PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID; PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode; PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin; PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd; PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX; PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY; PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX; PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY; PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew; PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin; PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd; PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale; PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve; PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve; PData.ParentID = objupdate.ObjectData[0].ParentID = 0; PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow; PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions; PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX; PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY; PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist; PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin; objupdate.ObjectData[0].ID = (uint)(localID); objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000")); objupdate.ObjectData[0].ObjectData = new byte[60]; objupdate.ObjectData[0].ObjectData[46] = 128; objupdate.ObjectData[0].ObjectData[47] = 63; LLVector3 pos1 = addPacket.ObjectData.RayEnd; //update position byte[] pb = pos1.GetBytes(); Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); this.newPrimFlag = true; this.primData.FullID = this.uuid = objupdate.ObjectData[0].FullID; this.localid = objupdate.ObjectData[0].ID; this.primData.Position = this.Pos = pos1; this.OurPacket = objupdate; }
/// <summary> /// /// </summary> /// <param name="simulator"></param> /// <param name="scale"></param> /// <param name="rotation"></param> /// <param name="position"></param> /// <param name="treeType"></param> /// <param name="groupOwner"></param> /// <param name="newTree"></param> public void AddTree(Simulator simulator, LLVector3 scale, LLQuaternion rotation, LLVector3 position, Tree treeType, LLUUID groupOwner, bool newTree) { ObjectAddPacket add = new ObjectAddPacket(); add.AgentData.AgentID = Client.Network.AgentID; add.AgentData.SessionID = Client.Network.SessionID; add.AgentData.GroupID = groupOwner; add.ObjectData.BypassRaycast = 1; add.ObjectData.Material = 3; add.ObjectData.PathCurve = 16; add.ObjectData.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree; add.ObjectData.RayEnd = position; add.ObjectData.RayStart = position; add.ObjectData.RayTargetID = LLUUID.Zero; add.ObjectData.Rotation = rotation; add.ObjectData.Scale = scale; add.ObjectData.State = (byte)treeType; Client.Network.SendPacket(add, simulator); }
/// <summary> /// Create, or "rez" a new prim object in a simulator /// </summary> /// <param name="simulator">The target simulator</param> /// <param name="prim">The prim object to rez</param> /// <param name="position">An approximation of the position at which to rez the prim</param> /// <remarks>Due to the way client prim rezzing is done on the server, /// the requested position for an object is only close to where the prim /// actually ends up. If you desire exact placement you'll need to /// follow up by moving the object after it has been created.</remarks> public void AddPrim(Simulator simulator, PrimObject prim, LLVector3 position) { ObjectAddPacket packet = new ObjectAddPacket(); packet.AgentData.AgentID = Client.Network.AgentID; packet.AgentData.SessionID = Client.Network.SessionID; packet.AgentData.GroupID = prim.GroupID; packet.ObjectData.State = (byte)prim.State; packet.ObjectData.AddFlags = (uint)ObjectFlags.CreateSelected; packet.ObjectData.PCode = (byte)PCode.Prim; packet.ObjectData.Material = (byte)prim.Material; packet.ObjectData.Scale = prim.Scale; packet.ObjectData.Rotation = prim.Rotation; packet.ObjectData.PathBegin = PrimObject.PathBeginByte(prim.PathBegin); packet.ObjectData.PathCurve = (byte)prim.PathCurve; packet.ObjectData.PathEnd = PrimObject.PathEndByte(prim.PathEnd); packet.ObjectData.PathRadiusOffset = PrimObject.PathRadiusOffsetByte(prim.PathRadiusOffset); packet.ObjectData.PathRevolutions = PrimObject.PathRevolutionsByte(prim.PathRevolutions); packet.ObjectData.PathScaleX = PrimObject.PathScaleByte(prim.PathScaleX); packet.ObjectData.PathScaleY = PrimObject.PathScaleByte(prim.PathScaleY); packet.ObjectData.PathShearX = PrimObject.PathShearByte(prim.PathShearX); packet.ObjectData.PathShearY = PrimObject.PathShearByte(prim.PathShearY); packet.ObjectData.PathSkew = PrimObject.PathSkewByte(prim.PathSkew); packet.ObjectData.PathTaperX = PrimObject.PathTaperByte(prim.PathTaperX); packet.ObjectData.PathTaperY = PrimObject.PathTaperByte(prim.PathTaperY); packet.ObjectData.PathTwist = (sbyte)prim.PathTwist; packet.ObjectData.PathTwistBegin = (sbyte)prim.PathTwistBegin; packet.ObjectData.ProfileCurve = (byte)prim.ProfileCurve; packet.ObjectData.ProfileBegin = PrimObject.ProfileBeginByte(prim.ProfileBegin); packet.ObjectData.ProfileEnd = PrimObject.ProfileEndByte(prim.ProfileEnd); packet.ObjectData.ProfileHollow = (byte)prim.ProfileHollow; packet.ObjectData.RayStart = position; packet.ObjectData.RayEnd = position; packet.ObjectData.RayEndIsIntersection = 0; packet.ObjectData.RayTargetID = LLUUID.Zero; packet.ObjectData.BypassRaycast = 1; // TODO: This is no longer a field in ObjectAdd. Detect if there actually is // texture information for this prim and send an ObjectUpdate //packet.ObjectData.TextureEntry = prim.Textures.GetBytes(); Client.Network.SendPacket(packet, simulator); }
/// <summary> /// Create, or "rez" a new prim object in a simulator /// </summary> /// <param name="simulator">The target simulator</param> /// <param name="prim">Data describing the prim object to rez</param> /// <param name="groupID">Group ID that this prim is set to, or LLUUID.Zero</param> /// <param name="position">An approximation of the position at which to rez the prim</param> /// <param name="scale">Scale vector to size this prim</param> /// <param name="rotation">Rotation quaternion to rotate this prim</param> /// <remarks>Due to the way client prim rezzing is done on the server, /// the requested position for an object is only close to where the prim /// actually ends up. If you desire exact placement you'll need to /// follow up by moving the object after it has been created. This /// function will not set textures, light and flexible data, or other /// extended primitive properties</remarks> public void AddPrim(Simulator simulator, LLObject.ObjectData prim, LLUUID groupID, LLVector3 position, LLVector3 scale, LLQuaternion rotation) { ObjectAddPacket packet = new ObjectAddPacket(); packet.AgentData.AgentID = Client.Self.AgentID; packet.AgentData.SessionID = Client.Self.SessionID; packet.AgentData.GroupID = groupID; packet.ObjectData.State = (byte)prim.State; packet.ObjectData.AddFlags = (uint)LLObject.ObjectFlags.CreateSelected; packet.ObjectData.PCode = (byte)PCode.Prim; packet.ObjectData.Material = (byte)prim.Material; packet.ObjectData.Scale = scale; packet.ObjectData.Rotation = rotation; packet.ObjectData.PathCurve = (byte)prim.PathCurve; packet.ObjectData.PathBegin = LLObject.PathBeginUInt16(prim.PathBegin); packet.ObjectData.PathEnd = LLObject.PathEndUInt16(prim.PathEnd); packet.ObjectData.PathRadiusOffset = LLObject.PathRadiusOffsetByte(prim.PathRadiusOffset); packet.ObjectData.PathRevolutions = LLObject.PathRevolutionsByte(prim.PathRevolutions); packet.ObjectData.PathScaleX = LLObject.PathScaleByte(prim.PathScaleX); packet.ObjectData.PathScaleY = LLObject.PathScaleByte(prim.PathScaleY); packet.ObjectData.PathShearX = LLObject.PathShearByte(prim.PathShearX); packet.ObjectData.PathShearY = LLObject.PathShearByte(prim.PathShearY); packet.ObjectData.PathSkew = LLObject.PathSkewByte(prim.PathSkew); packet.ObjectData.PathTaperX = LLObject.PathTaperByte(prim.PathTaperX); packet.ObjectData.PathTaperY = LLObject.PathTaperByte(prim.PathTaperY); packet.ObjectData.PathTwist = (sbyte)prim.PathTwist; packet.ObjectData.PathTwistBegin = (sbyte)prim.PathTwistBegin; packet.ObjectData.ProfileCurve = (byte)prim.ProfileCurve; packet.ObjectData.ProfileBegin = LLObject.ProfileBeginUInt16(prim.ProfileBegin); packet.ObjectData.ProfileEnd = LLObject.ProfileEndUInt16(prim.ProfileEnd); packet.ObjectData.ProfileHollow = LLObject.ProfileHollowUInt16(prim.ProfileHollow); packet.ObjectData.RayStart = position; packet.ObjectData.RayEnd = position; packet.ObjectData.RayEndIsIntersection = 0; packet.ObjectData.RayTargetID = LLUUID.Zero; packet.ObjectData.BypassRaycast = 1; Client.Network.SendPacket(packet, simulator); }
void ObjectAddHandler(Packet packet, Agent agent) { ObjectAddPacket add = (ObjectAddPacket)packet; Vector3 position = Vector3.Zero; Vector3 scale = add.ObjectData.Scale; PCode pcode = (PCode)add.ObjectData.PCode; PrimFlags flags = (PrimFlags)add.ObjectData.AddFlags; bool bypassRaycast = (add.ObjectData.BypassRaycast == 1); bool rayEndIsIntersection = (add.ObjectData.RayEndIsIntersection == 1); #region Position Calculation if (rayEndIsIntersection) { // HACK: Blindly trust where the client tells us to place position = add.ObjectData.RayEnd; } else { if (add.ObjectData.RayTargetID != UUID.Zero) { SimulationObject obj; if (server.Scene.TryGetObject(add.ObjectData.RayTargetID, out obj)) { // Test for a collision with the specified object position = ObjectCollisionTest(add.ObjectData.RayStart, add.ObjectData.RayEnd, obj); } } if (position == Vector3.Zero) { // Test for a collision with the entire scene position = FullSceneCollisionTest(add.ObjectData.RayStart, add.ObjectData.RayEnd); } } // Position lies on the face of another surface, either terrain of an object. // Back up along the ray so we are not colliding with the mesh. // HACK: This is really cheesy and should be done by a collision system Vector3 rayDir = Vector3.Normalize(add.ObjectData.RayEnd - add.ObjectData.RayStart); position -= rayDir * scale; #endregion Position Calculation #region Foliage Handling // Set all foliage to phantom if (pcode == PCode.Grass || pcode == PCode.Tree || pcode == PCode.NewTree) { flags |= PrimFlags.Phantom; if (pcode != PCode.Grass) { // Resize based on the foliage type Tree tree = (Tree)add.ObjectData.State; switch (tree) { case Tree.Cypress1: case Tree.Cypress2: scale = new Vector3(4f, 4f, 10f); break; default: scale = new Vector3(4f, 4f, 4f); break; } } } #endregion Foliage Handling // Create an object Primitive prim = new Primitive(); prim.Flags = PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner | PrimFlags.ObjectMove | PrimFlags.ObjectTransfer | PrimFlags.ObjectOwnerModify; // TODO: Security check prim.GroupID = add.AgentData.GroupID; prim.ID = UUID.Random(); prim.MediaURL = String.Empty; prim.OwnerID = agent.AgentID; prim.Position = position; prim.PrimData.Material = (Material)add.ObjectData.Material; prim.PrimData.PathCurve = (PathCurve)add.ObjectData.PathCurve; prim.PrimData.ProfileCurve = (ProfileCurve)add.ObjectData.ProfileCurve; prim.PrimData.PathBegin = Primitive.UnpackBeginCut(add.ObjectData.PathBegin); prim.PrimData.PathEnd = Primitive.UnpackEndCut(add.ObjectData.PathEnd); prim.PrimData.PathScaleX = Primitive.UnpackPathScale(add.ObjectData.PathScaleX); prim.PrimData.PathScaleY = Primitive.UnpackPathScale(add.ObjectData.PathScaleY); prim.PrimData.PathShearX = Primitive.UnpackPathShear((sbyte)add.ObjectData.PathShearX); prim.PrimData.PathShearY = Primitive.UnpackPathShear((sbyte)add.ObjectData.PathShearY); prim.PrimData.PathTwist = Primitive.UnpackPathTwist(add.ObjectData.PathTwist); prim.PrimData.PathTwistBegin = Primitive.UnpackPathTwist(add.ObjectData.PathTwistBegin); prim.PrimData.PathRadiusOffset = Primitive.UnpackPathTwist(add.ObjectData.PathRadiusOffset); prim.PrimData.PathTaperX = Primitive.UnpackPathTaper(add.ObjectData.PathTaperX); prim.PrimData.PathTaperY = Primitive.UnpackPathTaper(add.ObjectData.PathTaperY); prim.PrimData.PathRevolutions = Primitive.UnpackPathRevolutions(add.ObjectData.PathRevolutions); prim.PrimData.PathSkew = Primitive.UnpackPathTwist(add.ObjectData.PathSkew); prim.PrimData.ProfileBegin = Primitive.UnpackBeginCut(add.ObjectData.ProfileBegin); prim.PrimData.ProfileEnd = Primitive.UnpackEndCut(add.ObjectData.ProfileEnd); prim.PrimData.ProfileHollow = Primitive.UnpackProfileHollow(add.ObjectData.ProfileHollow); prim.PrimData.PCode = pcode; prim.Properties.CreationDate = DateTime.Now; prim.Properties.CreatorID = agent.AgentID; prim.Properties.Description = String.Empty; prim.Properties.GroupID = add.AgentData.GroupID; prim.Properties.LastOwnerID = agent.AgentID; prim.Properties.Name = "New Object"; prim.Properties.ObjectID = prim.ID; prim.Properties.OwnerID = prim.OwnerID; prim.Properties.Permissions = Permissions.FullPermissions; prim.Properties.SalePrice = 10; prim.RegionHandle = server.RegionHandle; prim.Rotation = add.ObjectData.Rotation; prim.Scale = scale; prim.Textures = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); prim.TextColor = Color4.Black; // Add this prim to the object database SimulationObject simObj = new SimulationObject(prim, server); server.Scene.ObjectAdd(this, agent, simObj, flags); }
public void platHigh(int c) { Vector3 where = new Vector3(shared.CameraPosition.X, shared.CameraPosition.Y, (float)(c - 5)); System.Timers.Timer myTimer = new System.Timers.Timer(10000); PacketDelegate replyCallback = delegate(Packet p, IPEndPoint s) { return(null); }; System.Timers.ElapsedEventHandler timerCallback = delegate(object sender, System.Timers.ElapsedEventArgs e) { proxy.RemoveDelegate(PacketType.ObjectSelect, Direction.Outgoing, replyCallback); proxy.RemoveDelegate(PacketType.ObjectDeselect, Direction.Outgoing, replyCallback); myTimer.Stop(); }; proxy.AddDelegate(PacketType.ObjectDeselect, Direction.Outgoing, replyCallback); proxy.AddDelegate(PacketType.ObjectSelect, Direction.Outgoing, replyCallback); myTimer.Elapsed += timerCallback; myTimer.Start(); ObjectAddPacket a = new ObjectAddPacket(); a.Type = PacketType.ObjectAdd; a.AgentData = new ObjectAddPacket.AgentDataBlock(); a.AgentData.AgentID = frame.AgentID; a.AgentData.GroupID = UUID.Zero; a.AgentData.SessionID = frame.SessionID; a.ObjectData = new ObjectAddPacket.ObjectDataBlock(); a.ObjectData.PCode = 9; a.ObjectData.Material = 4; a.ObjectData.AddFlags = 2; a.ObjectData.PathCurve = 48; a.ObjectData.ProfileCurve = 1; a.ObjectData.PathBegin = 0; a.ObjectData.PathEnd = 0; a.ObjectData.PathScaleX = 0; a.ObjectData.PathScaleY = 0; a.ObjectData.PathShearX = 0; a.ObjectData.PathShearY = 0; a.ObjectData.PathTwist = 0; a.ObjectData.PathTwistBegin = 0; a.ObjectData.PathRadiusOffset = 0; a.ObjectData.PathTaperX = 0; a.ObjectData.PathTaperY = 0; a.ObjectData.PathRevolutions = 0; a.ObjectData.PathSkew = 0; a.ObjectData.ProfileBegin = 0; a.ObjectData.ProfileEnd = 0; a.ObjectData.ProfileHollow = 0; a.ObjectData.BypassRaycast = 1; a.ObjectData.RayStart = where; a.ObjectData.RayEnd = where; a.ObjectData.RayTargetID = UUID.Zero; a.ObjectData.RayEndIsIntersection = 0; a.ObjectData.Scale = new Vector3((float)0.01, (float)10, (float)10); a.ObjectData.Rotation = new Quaternion((float)0, (float)0.70711, (float)0, (float)0.70711); a.ObjectData.State = 0; a.Header.Reliable = true; proxy.InjectPacket(a, Direction.Outgoing); }
public static ScriptSystem.CommandResult Command(uint sessionNum, string scriptName, string commandString, bool parseVariables, bool fromMasterIM) { //DEBUG - testing scriptName value //if (scriptName != "") Console.WriteLine("({0}) [{1}] SCRIPTED COMMAND: {2}", sessionNum, scriptName, commandString); //FIXME - change display output if fromMasterIM == true GhettoSL.UserSession Session = Interface.Sessions[sessionNum]; if (scriptName != "" && !Interface.Scripts.ContainsKey(scriptName)) return ScriptSystem.CommandResult.UnexpectedError; //invalid or unloaded script //First we clean up the original command string, removing whitespace and command slashes string commandToParse = commandString.Trim(); while (commandToParse.Length > 0 && commandToParse.Substring(0, 1) == "/") { commandToParse = commandToParse.Substring(1).Trim(); if (commandToParse.Length == 0) return ScriptSystem.CommandResult.NoError; } //Next we save the unparsed command, split it by spaces, for commands like /set and /inc char[] splitChar = { ' ' }; string[] unparsedCommand = commandToParse.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); //Now we parse the variables if (parseVariables) { commandToParse = Variables(sessionNum, commandString, scriptName); } //Next we split again. This time everthing is parsed. string[] cmd = commandToParse.Trim().Split(splitChar); string command = cmd[0].ToLower(); int commandStart = 0; //Time to check for IF statements and check for validity and pass/fail //If they are invalid, the entire function will return false, halting a parent script. //If they are valid but just fail, the command will halt, but it returns true. //FIXME - add "else" and multi-line "if/end if" routines if (command == "if" || command == "elseif") { string conditions = ""; string[] ifCmd = new string[0]; for (int i = 1; i < cmd.Length; i++) { if (commandStart > 0) //already found THEN statement, adding to command string { Array.Resize(ref ifCmd, ifCmd.Length + 1); ifCmd[ifCmd.Length - 1] = cmd[i]; } else if (cmd[i].ToLower() == "then") //this is our THEN statement { if (i >= cmd.Length - 1) { Display.Error(sessionNum, "Script error: Missing statement after THEN"); return ScriptSystem.CommandResult.InvalidUsage; } commandStart = i + 1; } else if (i >= cmd.Length - 1) { Display.Error(sessionNum, "Script error: IF without THEN"); return ScriptSystem.CommandResult.InvalidUsage; } else { if (conditions != "") conditions += " "; conditions += cmd[i]; } } if (!Conditions(sessionNum, conditions)) return ScriptSystem.CommandResult.ConditionFailed; //condition failed, but no errors cmd = ifCmd; command = cmd[0].ToLower(); } else if (command == "else") { string c = ""; for (int i = 1; i < cmd.Length; i++) { if (c != "") c += " "; c += cmd[i]; } cmd = c.Split(splitChar); if (cmd.Length > 0) command = cmd[0]; else return ScriptSystem.CommandResult.InvalidUsage; } //The purpose of this part is to separate the message from the rest of the command. //For example, in the command "im some-uuid-here Hi there!", details = "Hi there!" string details = ""; int detailsStart = 1; if (command == "cam" || command == "estate" || command == "popup" || command == "busyim" || command == "im" || command == "lure" || command == "re" || command == "s" || command == "session" || command == "paybytext" || command == "paybyname") detailsStart++; else if (command == "dialog") detailsStart += 2; else if (command == "timer" && cmd.Length > 1) { if (cmd.Length > 1) { if (cmd[1].Substring(0, 1) == "-") detailsStart += 4; else detailsStart += 3; } } while (detailsStart < cmd.Length) { if (details != "") details += " "; details += cmd[detailsStart]; detailsStart++; } //Check for user-defined aliases lock (Interface.Scripts) { foreach (ScriptSystem.UserScript s in Interface.Scripts.Values) { foreach (KeyValuePair<string, string[]> pair in s.Aliases) { if (command == pair.Key.ToLower()) { //ScriptSystem.CommandResult result = ScriptSystem.CommandResult.NoError; Dictionary<string, string> identifiers = new Dictionary<string, string>(); identifiers.Add("$message", details); Parse.CommandArray(sessionNum, s.ScriptName, pair.Value, identifiers); //foreach (string c in pair.Value) //{ // string ctok = Tokens(c, details); // ScriptSystem.CommandResult aResult = Command(sessionNum, s.ScriptName, ctok, true, fromMasterIM); // if (aResult != ScriptSystem.CommandResult.NoError && aResult != ScriptSystem.CommandResult.ConditionFailed) return result; //} return ScriptSystem.CommandResult.NoError; //FIXME - make Parse.CommandArray return a CommandResult } } } } if (!Session.Client.Network.Connected) { string[] okIfNotConnected = { "clear", "debug", "echo", "exit", "help", "http", "login", "inc", "quit", "relog", "return", "s", "session", "sessions", "set", "script", "scripts", "stats", "timer", "timers" }; int ok; for (ok = 0; ok < okIfNotConnected.Length; ok++) { if (okIfNotConnected[ok] == command) break; } if (ok == okIfNotConnected.Length) { Display.Error(sessionNum, "/" + command + ": Not connected"); return ScriptSystem.CommandResult.UnexpectedError; } } //Check for "/1 text" for channel 1, etc int chatChannel; if (int.TryParse(cmd[0], out chatChannel)) { Session.Client.Self.Chat(details, chatChannel, ChatType.Normal); Display.SendMessage(sessionNum, chatChannel, UUID.Zero, details); } //And on to the actual commands... else if (command == "anim") { UUID anim; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out anim)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.AnimationStart(anim, false); } else if (command == "answer") { int channel = Session.LastDialogChannel; UUID id = Session.LastDialogID; if (cmd.Length < 2) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } else if (channel < 0 || id == UUID.Zero) Display.Error(sessionNum, "No dialogs received. Try /dialog <channel> <id> <message>."); else if (Command(sessionNum, scriptName, "dialog " + channel + " " + id + " " + details, parseVariables, fromMasterIM) == ScriptSystem.CommandResult.NoError) { Display.InfoResponse(sessionNum, "Dialog reply sent."); } } else if (command == "balance") { Session.Client.Self.RequestBalance(); } else if (command == "restartsim") { Session.Client.Network.CurrentSim.Estate.RestartRegion(); } else if (command == "cancelrestart") { Session.Client.Network.CurrentSim.Estate.CancelRestart(); } else if (command == "debug") { int mode = Session.Debug; if (!int.TryParse(cmd[1], out mode)) { if (cmd[1].ToLower() == "on") mode = 1; else if (cmd[1].ToLower() == "off") mode = 0; } Session.Debug = mode; Display.InfoResponse(sessionNum, "Debug level: " + mode); } else if (command == "detachall") { //FIXME - detach all worn objects List<uint> attachments = new List<uint>(); foreach (KeyValuePair<uint, Primitive> pair in Session.Prims) { if (pair.Value.ParentID == Session.Client.Self.LocalID) attachments.Add(pair.Value.LocalID); } Session.Client.Objects.DetachObjects(Session.Client.Network.CurrentSim, attachments); Display.InfoResponse(sessionNum, "Detached " + attachments.Count + " objects"); } else if (command == "return") { return ScriptSystem.CommandResult.Return; } else if (command == "paybytext" || command == "paybyname") { int amount; if (cmd.Length < 3 || !int.TryParse(cmd[1], out amount)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } uint localID = 0; UUID uuid = UUID.Zero; Console.WriteLine(command + " " + details); if (command == "paybytext") { localID = Session.FindObjectByText(details.ToLower()); if (!Session.Prims.ContainsKey(localID)) { Display.Error(sessionNum, "Missing info for local ID " + localID); return ScriptSystem.CommandResult.UnexpectedError; //FIXME - should this return false and stop scripts? } uuid = Session.Prims[localID].ID; } else if (command == "paybyname") { localID = Session.FindAgentByName(details.ToLower()); if (!Session.Avatars.ContainsKey(localID)) { Display.Error(sessionNum, "Missing info for local ID " + localID); return ScriptSystem.CommandResult.UnexpectedError; //FIXME - should this return false and stop scripts? } uuid = Session.Avatars[localID].ID; } else return ScriptSystem.CommandResult.UnexpectedError; //this should never happen if (localID > 0) { Session.Client.Self.GiveMoney(uuid, amount, "", MoneyTransactionType.Gift, TransactionFlags.None); Display.InfoResponse(sessionNum, "Paid L$" + amount + " to " + uuid); } } else if (command == "setmaster") { UUID master; if (cmd.Length != 2 || UUID.TryParse(cmd[1], out master)) return ScriptSystem.CommandResult.InvalidUsage; Session.Settings.MasterID = master; Display.InfoResponse(sessionNum, "Set master to " + cmd[1]); } else if (command == "settarget" && scriptName != "") { Vector3 target; if (cmd.Length < 2 || !Vector3.TryParse(details, out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } else Interface.Scripts[scriptName].SetTarget = target; } else if (command == "settime" && scriptName != "") { Interface.Scripts[scriptName].SetTime = Utils.GetUnixTime(); } else if (command == "sitbytext") { if (cmd.Length < 2) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } uint localID = Session.FindObjectByText(details.ToLower()); if (localID > 0) { Display.InfoResponse(sessionNum, "Match found. Sitting..."); Session.Client.Self.RequestSit(Session.Prims[localID].ID, Vector3.Zero); Session.Client.Self.Sit(); //Session.Client.Self.Movement.Controls.FinishAnim = false; Session.Client.Self.Movement.SitOnGround = false; Session.Client.Self.Movement.StandUp = false; Session.Client.Self.Movement.SendUpdate(); } else Display.InfoResponse(sessionNum, "No matching objects found."); } else if (command == "touchbytext") { if (cmd.Length < 2) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } uint localID = Session.FindObjectByText(details.ToLower()); if (localID > 0) { Display.InfoResponse(sessionNum, "Match found. Touching..."); Session.Client.Self.Touch(localID); } else Display.InfoResponse(sessionNum, "No matching objects found."); } else if (command == "clear") { Console.Clear(); } else if (command == "crouch") { if (cmd.Length == 1 || cmd[1].ToLower() == "on") { Session.Client.Self.Movement.UpNeg = true; Session.Client.Self.Movement.SendUpdate(); } else if (cmd.Length > 1 && cmd[1].ToLower() == "off") { Session.Client.Self.Movement.UpNeg = false; Session.Client.Self.Movement.FinishAnim = true; Session.Client.Self.Movement.SendUpdate(); Session.Client.Self.Movement.FinishAnim = false; } else { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } } else if (command == "delete") { UUID itemid; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out itemid)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } if (!Session.Client.Inventory.Store.Contains(itemid)) { Display.Error(sessionNum, "Asset id not found in inventory cache"); return ScriptSystem.CommandResult.UnexpectedError; } InventoryBase item = Session.Client.Inventory.Store[itemid]; string name = item.Name; //FIXME - reimplement //Session.Client.Inventory.Remove(item); Display.InfoResponse(sessionNum, "Deleted item \"" + name + "\"."); } else if (command == "detach") { UUID itemid; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out itemid)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } if (!Session.Client.Inventory.Store.Contains(itemid)) { Display.Error(sessionNum, "Asset id not found in inventory cache"); return ScriptSystem.CommandResult.UnexpectedError; } InventoryItem item = (InventoryItem)Session.Client.Inventory.Store[itemid]; string name = item.Name; Session.Client.Appearance.Detach(item); Display.InfoResponse(sessionNum, "Detached item \"" + name + "\"."); } else if (command == "dialog") { int channel; UUID objectid; if (cmd.Length <= 3 || !int.TryParse(cmd[1], out channel) || !UUID.TryParse(cmd[2], out objectid)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Display.SendMessage(sessionNum, channel, objectid, details); Session.ScriptDialogReply(channel, objectid, details); } else if (command == "dir" || command == "ls") { //FIXME - remember folder and allow dir/ls without args //FIXME - move DirList function to UserSession and move output to Display class UUID folder; if (cmd.Length == 1) ScriptSystem.DirList(sessionNum, Session.Client.Inventory.Store.RootFolder.UUID); else if (!UUID.TryParse(cmd[1], out folder)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } else ScriptSystem.DirList(sessionNum, folder); } else if (command == "dwell") { } else if (command == "echo") { //FIXME - move to Display.Echo if (cmd.Length < 1) return ScriptSystem.CommandResult.NoError; Console.WriteLine(details); } else if (command == "eban") { UUID target; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } //FIXME - add display Session.Client.Network.CurrentSim.Estate.BanUser(target, false); } else if (command == "eunban") { UUID target; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } //FIXME - add display Session.Client.Network.CurrentSim.Estate.UnbanUser(target, false); } else if (command == "ekick") { UUID target; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } //FIXME - add display Session.Client.Network.CurrentSim.Estate.KickUser(target); } else if (command == "ekill") { UUID target; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Network.CurrentSim.Estate.TeleportHomeUser(target); } else if (command == "estate") { if (cmd.Length < 2) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Network.CurrentSim.Estate.EstateOwnerMessage(cmd[1], details); } else if (command == "events") { if (cmd.Length == 1) Display.EventList(sessionNum); } else if (command == "exit") { Command(sessionNum, scriptName, "s -a quit", false, fromMasterIM); Interface.Exit = true; } else if (command == "fly") { if (cmd.Length == 1 || cmd[1].ToLower() == "on") { if (Session.Client.Self.Movement.Fly) { Display.InfoResponse(sessionNum, "You are already flying."); } else { Session.Client.Self.Movement.Fly = true; Display.InfoResponse(sessionNum, "Suddenly, you feel weightless..."); } } else if (cmd[1].ToLower() == "off") { if (Session.Client.Self.Movement.Fly) { Session.Client.Self.Movement.Fly = false; Display.InfoResponse(sessionNum, "You drop to the ground."); } else { Display.InfoResponse(sessionNum, "You are not flying."); } } //Send either way, for good measure Session.Client.Self.Movement.SendUpdate(); } else if (command == "follow") { if (cmd.Length < 2) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } if (cmd.Length == 1 || cmd[1].ToLower() == "on") { if (Session.FollowName == "") { Display.InfoResponse(sessionNum, "You are not following anyone."); } else { Session.Follow(Session.FollowName); } } else if (cmd[1].ToLower() == "off") { if (Session.FollowTimer.Enabled == true) { Session.FollowTimer.Stop(); Display.InfoResponse(sessionNum, "You stopped following " + Session.FollowName + "."); Session.Client.Self.Movement.SendUpdate(); } else { Display.InfoResponse(sessionNum, "You are not following."); } } else Session.Follow(details); } else if (command == "friend") { UUID targetID; if (cmd.Length > 1 && cmd[1] == "-r") { if (cmd.Length < 3 || !UUID.TryParse(cmd[2], out targetID)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Friends.TerminateFriendship(targetID); } else { if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out targetID)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Friends.OfferFriendship(targetID); } } else if (command == "go") { Vector3 target; if (cmd.Length < 2 || !Vector3.TryParse(details, out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.AutoPilotLocal((int)target.X, (int)target.Y, target.Z); } else if (command == "fixme") { Session.UpdateAppearance(); Session.Client.Self.Movement.FinishAnim = true; Session.Client.Self.Movement.SendUpdate(); Session.Client.Self.Movement.FinishAnim = false; Session.Client.Self.Movement.SendUpdate(); } else if (command == "gc") { Display.InfoResponse(sessionNum, "Performing garbage collection..."); GC.Collect(); GC.WaitForPendingFinalizers(); } else if (command == "groups") { Display.GroupList(sessionNum); } else if (command == "roles") { UUID groupID; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out groupID)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Groups.RequestGroupRoles(groupID); } else if (command == "groupinvite") { UUID inviteeID; UUID groupID; UUID roleID; if (cmd.Length < 4 || !UUID.TryParse(cmd[1], out inviteeID) || !UUID.TryParse(cmd[2], out groupID) || !UUID.TryParse(cmd[3], out roleID)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Display.InfoResponse(sessionNum, "Inviting user " + inviteeID + " to group " + groupID + " with the role " + roleID + "."); Session.Client.Groups.AddToRole(groupID, roleID, inviteeID); } else if (command == "help") { string topic = ""; if (cmd.Length > 1) topic = cmd[1]; Display.Help(topic); } else if (command == "home") { Session.Client.Self.Teleport(UUID.Zero); } else if (command == "http") { if (cmd.Length < 2) { if (!Interface.HTTPServer.Server.Listening) Display.InfoResponse(0, "HTTPServer is disabled (" + Interface.HTTPServer.Server.Clients.Count + " client(s) connected)"); else Display.InfoResponse(0, "HTTPServer is enabled (" + Interface.HTTPServer.Server.Clients.Count + " client(s) connected)"); } else { string flag = cmd[1].ToLower(); if (flag == "off") { Interface.HTTPServer.Server.StopListening(); Display.InfoResponse(0, "HTTP server disabled (" + Interface.HTTPServer.Server.Clients.Count + " client(s) remaining)"); } else if (flag == "on") { int port; if (cmd.Length < 3 || !int.TryParse(cmd[2], out port)) port = 8066; Interface.HTTPServer.Server.Listen(port); Display.InfoResponse(0, "HTTP server enabled on port " + port); } else { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } } } else if (command == "im") { UUID target; if (cmd.Length < 3 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } if (Session.IMSessions.ContainsKey(target)) { Session.Client.Self.InstantMessage(target, details, Session.IMSessions[target].IMSessionID); } else Session.Client.Self.InstantMessage(target, details); } else if (command == "busyim") { UUID target; if (cmd.Length < 3 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } if (Session.IMSessions.ContainsKey(target)) { Session.Client.Self.InstantMessage(Session.Client.Self.Name, target, details, Session.IMSessions[target].IMSessionID, InstantMessageDialog.BusyAutoResponse, InstantMessageOnline.Online, Vector3.Zero, UUID.Zero, new byte[0]); } else Session.Client.Self.InstantMessage(Session.Client.Self.Name, target, details, UUID.Random(), InstantMessageDialog.BusyAutoResponse, InstantMessageOnline.Online, Vector3.Zero, UUID.Zero, new byte[0]); } else if (command == "forcefriend") { UUID target; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.InstantMessage(Session.Client.Self.Name, target, "", UUID.Random(), InstantMessageDialog.FriendshipAccepted, InstantMessageOnline.Online, Vector3.Zero, UUID.Zero, new byte[0] { }); } else if (command == "popup") { UUID target; if (cmd.Length < 3 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } if (Session.IMSessions.ContainsKey(target)) { Session.Client.Self.InstantMessage(Session.Client.Self.Name, target, details, Session.IMSessions[target].IMSessionID, InstantMessageDialog.ConsoleAndChatHistory, InstantMessageOnline.Online, Vector3.Zero, UUID.Zero, new byte[0]); } else Session.Client.Self.InstantMessage(Session.Client.Self.Name, target, details, UUID.Random(), InstantMessageDialog.ConsoleAndChatHistory, InstantMessageOnline.Online, Vector3.Zero, UUID.Zero, new byte[0]); } else if (command == "jump") { if (cmd.Length == 1 || cmd[1].ToLower() == "on") { Session.Client.Self.Jump(true); } else if (cmd.Length > 1 && cmd[1].ToLower() == "off") { Session.Client.Self.Jump(false); } else { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } } else if (command == "crouch") { if (cmd.Length == 1 || cmd[1].ToLower() == "on") { Session.Client.Self.Crouch(true); } else if (cmd.Length > 1 && cmd[1].ToLower() == "off") { Session.Client.Self.Crouch(false); } else { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } } else if (command == "land") { Session.Client.Self.Movement.Fly = false; Session.Client.Self.Movement.FinishAnim = true; Session.Client.Self.Movement.SendUpdate(); Session.Client.Self.Movement.FinishAnim = false; //Session.Client.Self.Movement.SendUpdate(); } else if (command == "listen") { Session.Settings.DisplayChat = true; } else if (command == "login") { if (!LoginCommand(sessionNum, cmd)) { Display.InfoResponse(sessionNum, "Invalid login parameters"); } } else if (command == "look") { int countText = 0; if (cmd.Length == 1) { Vector3 sunDirection = Session.Client.Grid.SunDirection; string simName = Session.Client.Network.CurrentSim.Name; string weather = Display.RPGWeather(sessionNum, simName, sunDirection); if (simName != "" && sunDirection != Vector3.Zero) { Display.InfoResponse(sessionNum, weather); } lock (Session.Prims) { foreach (KeyValuePair<uint, Primitive> pair in Session.Prims) { if (pair.Value.Text != "") countText++; } } Display.InfoResponse(sessionNum, "There are " + countText + " objects with text nearby."); } else { lock (Session.Prims) { foreach (KeyValuePair<uint, Primitive> pair in Session.Prims) { try { if (Regex.IsMatch(pair.Value.Text, details, RegexOptions.IgnoreCase)) { //FIXME - move to Display Console.WriteLine(pair.Value.LocalID + " " + pair.Value.ID + " " + pair.Value.Text); countText++; } } catch { Display.Error(sessionNum, "/look: invalid regular expression"); return ScriptSystem.CommandResult.InvalidUsage; } } } Display.InfoResponse(sessionNum, "There are " + countText + " objects matching your query."); } } else if (command == "lure") { UUID target; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } string reason; if (cmd.Length > 2) reason = details; else reason = "Join me in " + Session.Client.Network.CurrentSim.Name + "!"; Session.Client.Self.SendTeleportLure(target, reason); } else if (command == "mlook") { if (cmd.Length < 2 || cmd[1].ToLower() == "on") { Session.Client.Self.Movement.Mouselook = true; Display.InfoResponse(sessionNum, "Mouselook enabled"); } else if (cmd[1].ToLower() == "off") { Session.Client.Self.Movement.Mouselook = false; Display.InfoResponse(sessionNum, "Mouselook disabled"); } else { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } } //TODO: reimplement /* else if (command == "shoot") { Vector3 target; if (cmd.Length == 1) Session.Client.Self.Movement.Shoot(); else if (Vector3.TryParse(cmd[1], out target)) { Session.Client.Self.Movement.Shoot(target); } } */ else if (command == "particles") { lock (Session.Prims) { foreach (KeyValuePair<uint, Primitive> obj in Session.Prims) { if (obj.Value.ParticleSys.Pattern != Primitive.ParticleSystem.SourcePattern.None) { Console.WriteLine(obj.Value.ID.ToString() + " " + Display.VectorString(obj.Value.Position) + " " + obj.Value.ParentID ); } } } } else if (command == "pay") { UUID id; int amount; if (cmd.Length < 3 || !int.TryParse(cmd[1], out amount) || !UUID.TryParse(cmd[2], out id)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.GiveMoney(id, amount, "", MoneyTransactionType.Gift, TransactionFlags.None); } else if (command == "payme") { int amount; if (cmd.Length < 2 || !int.TryParse(cmd[1], out amount)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } else if (Session.Settings.MasterID == UUID.Zero) { Display.Error(sessionNum, "MasterID not defined"); return ScriptSystem.CommandResult.UnexpectedError; } else { Session.Client.Self.GiveMoney(Session.Settings.MasterID, amount, "Payment to master", MoneyTransactionType.Gift, TransactionFlags.None); } } else if (command == "quiet") { if (cmd.Length == 1 || cmd[1].ToLower() == "on") { Session.Settings.DisplayChat = false; Display.InfoResponse(sessionNum, "Hiding chat from objects/avatars."); } else if (cmd[1].ToLower() == "off") { Session.Settings.DisplayChat = true; Display.InfoResponse(sessionNum, "Showing chat from objects/avatars."); } else { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } } else if (command == "quit") { Display.InfoResponse(sessionNum, "Disconnecting " + Session.Name + "..."); Session.Client.Network.Logout(); } else if (command == "re") { if (cmd.Length == 1) { if (Session.IMSessions.Count == 0) Display.InfoResponse(sessionNum, "No active IM sessions"); else Display.IMSessions(sessionNum); } else if (cmd.Length < 3) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } else { UUID match = UUID.Zero; foreach (KeyValuePair<UUID, GhettoSL.IMSession> pair in Session.IMSessions) { if (pair.Value.Name.Length < cmd[1].Length) continue; //too short to be a match else if (pair.Value.Name.Substring(0, cmd[1].Length).ToLower() == cmd[1].ToLower()) { if (match != UUID.Zero) { Display.Error(sessionNum, "\"" + cmd[1] + "\" could refer to more than one active IM session."); return ScriptSystem.CommandResult.InvalidUsage; } match = pair.Key; } } if (match != UUID.Zero) { Display.SendMessage(sessionNum, 0, match, details); Session.Client.Self.InstantMessage(match, details, Session.IMSessions[match].IMSessionID); } } } else if (command == "relog") { if (Session.Client.Network.Connected) { //FIXME - Add RelogTimer to UserSession, in place of this Session.Client.Network.Logout(); Thread.Sleep(1000); } Session.Login(); } else if (command == "reseturi") { Session.Settings.StartLocation = "last"; } else if (command == "rez") { Console.WriteLine("FIXME"); } else if (command == "addprim") { Vector3 scale; if (Vector3.TryParse(details, out scale)) { ObjectAddPacket add = new ObjectAddPacket(); add.AgentData = new ObjectAddPacket.AgentDataBlock(); add.AgentData.AgentID = Session.Client.Self.AgentID; add.AgentData.GroupID = Session.Client.Self.ActiveGroup; add.AgentData.SessionID = Session.Client.Self.SessionID; add.ObjectData = new ObjectAddPacket.ObjectDataBlock(); add.ObjectData.AddFlags = 2; add.ObjectData.BypassRaycast = 1; add.ObjectData.PathBegin = 0; add.ObjectData.PathCurve = 16; add.ObjectData.PathEnd = 0; add.ObjectData.PathRadiusOffset = 0; add.ObjectData.PathRevolutions = 0; add.ObjectData.PathScaleX = 100; add.ObjectData.PathScaleY = 100; add.ObjectData.PathShearX = 0; add.ObjectData.PathShearY = 0; add.ObjectData.PathSkew = 0; add.ObjectData.PathTaperX = 0; add.ObjectData.PathTaperY = 0; add.ObjectData.PathTwist = 0; add.ObjectData.PathTwistBegin = 0; add.ObjectData.PCode = 9; add.ObjectData.ProfileBegin = 0; add.ObjectData.ProfileCurve = 1; add.ObjectData.ProfileEnd = 0; add.ObjectData.ProfileHollow = 0; add.ObjectData.RayEnd = Session.Client.Self.SimPosition; add.ObjectData.RayEndIsIntersection = 0; add.ObjectData.RayStart = Session.Client.Self.SimPosition; add.ObjectData.RayTargetID = UUID.Zero; add.ObjectData.Rotation = Quaternion.Identity; add.ObjectData.Scale = scale; add.ObjectData.State = 0; Session.Client.Network.SendPacket(add); //LLObject.ObjectData prim = new LLObject.ObjectData(); //prim.PCode = PCode.Prim; //prim.ProfileCurve = (LLObject.ProfileCurve)1; //Session.Client.Objects.AddPrim(Session.Client.Network.CurrentSim, prim, UUID.Zero, Session.Client.Self.SimPosition, scale, LLQuaternion.Identity); } } else if (command == "ride") { Session.RideWith(details); } else if (command == "rotto") { Vector3 target; if (cmd.Length < 2 || !Vector3.TryParse(details, out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.Movement.TurnToward(target); } else if (command == "brot") { Vector3 target; if (cmd.Length < 2 || !Vector3.TryParse(details, out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.Movement.TurnToward(target); } /* else if (command == "hrot") { Vector3 target; if (cmd.Length < 2 || !Vector3.TryParse(details, out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.Movement.HeadRotation = Vector3.Axis2Rot(target); Session.Client.Self.Movement.SendUpdate(); } */ else if (command == "cam") { Vector3 target; if (cmd.Length < 3 || !Vector3.TryParse(details, out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } string arg = cmd[1].ToLower(); if (arg != "center" && arg != "left" && arg != "up" && arg != "at") { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } char[] space = { ' ' }; string vString = details.Replace("<", "").Replace(">", "").Replace(",", " "); string[] v = vString.Split(space, StringSplitOptions.RemoveEmptyEntries); if (arg == "center") Session.Client.Self.Movement.Camera.Position = target; else if (arg == "at") Session.Client.Self.Movement.Camera.AtAxis = target; else if (arg == "left") Session.Client.Self.Movement.Camera.LeftAxis = target; else if (arg == "up") Session.Client.Self.Movement.Camera.UpAxis = target; Session.Client.Self.Movement.SendUpdate(); Display.InfoResponse(sessionNum, "Camera settings updated"); } else if (command == "run" || command == "running") { if (cmd.Length == 1 || cmd[1].ToLower() == "on") { Session.Client.Self.Movement.AlwaysRun = true; Display.InfoResponse(sessionNum, "Running enabled."); } else if (cmd[1].ToLower() == "off") { Session.Client.Self.Movement.AlwaysRun = false; Display.InfoResponse(sessionNum, "Running disabled."); } else { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } } else if (command == "say") { Session.Client.Self.Chat(details, 0, ChatType.Normal); } else if (command == "script") { if (!LoadScriptCommand(sessionNum, cmd)) return ScriptSystem.CommandResult.UnexpectedError; } else if (command == "scripts") { Display.ScriptList(); } else if (command == "s" || command == "session") { if (cmd.Length > 1) { if (cmd[1] == "-a" || cmd[1] == "*") { foreach (KeyValuePair<uint, GhettoSL.UserSession> pair in Interface.Sessions) { Command(pair.Key, scriptName, details, parseVariables, fromMasterIM); } return ScriptSystem.CommandResult.NoError; } uint switchTo; if (!uint.TryParse(cmd[1], out switchTo) || switchTo < 1 || !Interface.Sessions.ContainsKey(switchTo)) { Display.Error(sessionNum, "Invalid session number"); return ScriptSystem.CommandResult.InvalidUsage; } else if (cmd.Length == 2) { Interface.CurrentSession = switchTo; string name = Interface.Sessions[switchTo].Name; Display.InfoResponse(switchTo, "Switched to " + name); Console.Title = name + " @ " + Session.Client.Network.CurrentSim.Name + " - GhettoSL"; } else { Command(switchTo, scriptName, details, parseVariables, fromMasterIM); } } else Display.SessionList(); } else if (command == "whois") { //FIXME - add group, land, etc searching if (cmd.Length < 2) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } UUID targetID; bool isID = UUID.TryParse(cmd[1], out targetID); if (isID) Session.Client.Avatars.RequestAvatarName(targetID); else Session.Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, details, 0); } else if (command == "inc" && scriptName != "") { int amount = 1; if (unparsedCommand.Length < 2 || (unparsedCommand.Length > 2 && !int.TryParse(Variables(sessionNum, unparsedCommand[2], scriptName), out amount))) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } ScriptSystem.UserScript Script = Interface.Scripts[scriptName]; int value = 0; string variableName = unparsedCommand[1]; if (Script.Variables.ContainsKey(variableName) && !int.TryParse(Script.Variables[variableName], out value)) return ScriptSystem.CommandResult.InvalidUsage; //FIXME - change in the following code, int + "" to a proper string-to-int conversion else if (Script.Variables.ContainsKey(variableName)) Script.Variables[variableName] = "" + (value + amount); else Script.Variables.Add(variableName, "" + amount); //QUESTION - Right now, inc creates a new %var if the specified one doesn't exist. Should it? } else if (command == "set" && scriptName != "") { if (unparsedCommand.Length < 3 || unparsedCommand[1].Substring(0, 1) != "%") { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } details = ""; for (int d = 2; d < unparsedCommand.Length; d++) { if (details != "") details += " "; details += unparsedCommand[d]; } string variableName = unparsedCommand[1]; ScriptSystem.UserScript Script = Interface.Scripts[scriptName]; if (Script.Variables.ContainsKey(variableName)) Script.Variables[variableName] = Variables(sessionNum, details, scriptName); else Script.Variables.Add(variableName, Variables(sessionNum, details, scriptName)); } else if (command == "sethome") { Session.Client.Self.SetHome(); } else if (command == "shout") { Session.Client.Self.Chat(details, 0, ChatType.Shout); } else if (command == "simmessage") { Session.Client.Network.CurrentSim.Estate.SimulatorMessage(details); } else if (command == "sit") { UUID target; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.Movement.SitOnGround = false; Session.Client.Self.Movement.StandUp = false; Session.Client.Self.RequestSit(target, Vector3.Zero); Session.Client.Self.Sit(); Session.Client.Self.Movement.SendUpdate(); } else if (command == "sitg") { Session.Client.Self.SitOnGround(); } /* else if (command == "sleep") { float interval; if (cmd.Length < 2 || scriptName == "" || !float.TryParse(cmd[1], out interval)) { Display.Help(command); return false; } Interface.Scripts[scriptName].Sleep(interval); return false; //pause script } */ else if (command == "spoofim") { UUID target; if (cmd.Length < 4 || !UUID.TryParse(cmd[1], out target)) { return ScriptSystem.CommandResult.InvalidUsage; } string fromName = cmd[2] + " " + cmd[3]; Session.Client.Self.InstantMessage(fromName, target, cmd[4], UUID.Random(), new UUID[0]); } else if (command == "stand") { Session.Client.Self.Movement.SitOnGround = false; Session.Client.Self.Movement.StandUp = true; Session.Client.Self.Movement.SendUpdate(); Session.Client.Self.Movement.StandUp = false; } else if (command == "stats") { Display.Stats(sessionNum); } else if (command == "stopanim") { UUID anim; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out anim)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.AnimationStop(anim, false); } else if (command == "teleport" || command == "tp") { if (!Session.Client.Network.Connected) { Display.Error(sessionNum, "Not connected"); return ScriptSystem.CommandResult.UnexpectedError; } if (cmd.Length < 2) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } //assumed values string simName = ScriptSystem.QuoteArg(cmd, 1); Vector3 target = new Vector3(128, 128, 0); //assumed wrong if (cmd.Length > 2) { //find what pos the vector starts at and how many tokens it is int start = simName.Split(splitChar).Length + 1; int len = cmd.Length - start; if (len > 0) { string[] v = new string[len]; Array.Copy(cmd, start, v, 0, len); if (!Vector3.TryParse(String.Join(" ", v), out target)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } } } Display.Teleporting(sessionNum, simName); Session.Client.Self.Teleport(simName, target); } //FIXME - move to /teleport and just check for ulong else if (command == "teleporth") { ulong handle; if (cmd.Length < 2 || !ulong.TryParse(cmd[1], out handle)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } Session.Client.Self.Teleport(handle, new Vector3(128, 128, 0)); } else if (command == "timer") { if (cmd.Length < 3) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } else if (cmd[2] == "off") { if (Session.Timers.ContainsKey(cmd[1])) { Session.Timers[cmd[1]].Dispose(); Session.Timers.Remove(cmd[1]); } } else { string flags = ""; int start = 1; if (cmd[1].Substring(0, 1) == "-") { flags = cmd[1]; start++; } string name = cmd[start]; int repeats; int interval; bool milliseconds = false; foreach (char f in flags.ToCharArray()) { if (f == 'm') milliseconds = true; } if (!int.TryParse(cmd[start + 1], out repeats) || !int.TryParse(cmd[start + 2], out interval)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } string m; if (milliseconds) m = "ms"; else m = "sec"; Display.InfoResponse(sessionNum, "Timer \"" + name + "\" activated (Repeat: " + repeats + ", Interval: " + interval + m + ")"); ScriptSystem.UserTimer timer = new ScriptSystem.UserTimer(sessionNum, name, interval, milliseconds, repeats, details); if (!Session.Timers.ContainsKey(name)) Session.Timers.Add(name, timer); else Session.Timers[name] = timer; } } else if (command == "timers") { string arg = ""; if (cmd.Length > 1) arg = cmd[1].ToLower(); if (Session.Timers.Count == 0) { Display.InfoResponse(sessionNum, "No active timers for this session"); } else { foreach (KeyValuePair<string, ScriptSystem.UserTimer> pair in Session.Timers) { //FIXME - move to Display if (arg == "off") pair.Value.Dispose(); else Display.InfoResponse(sessionNum, Display.Pad(pair.Key, 15) + " " + Display.Pad(pair.Value.RepeatsRemaining.ToString(), 3) + " " + pair.Value.Command); } } } else if (command == "topscripts") { Session.Client.Network.CurrentSim.Estate.GetTopScripts(); } else if (command == "topcolliders") { Session.Client.Network.CurrentSim.Estate.GetTopColliders(); } else if (command == "touch") { UUID findID; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out findID)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } lock (Session.Prims) { foreach (Primitive prim in Session.Prims.Values) { if (prim.ID != findID) continue; Session.Client.Self.Touch(prim.LocalID); Display.InfoResponse(sessionNum, "You touch an object..."); return ScriptSystem.CommandResult.NoError; } } Display.Error(sessionNum, "Object not found"); } else if (command == "touchid") { if (cmd.Length < 2) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } uint touchid; if (uint.TryParse(cmd[1], out touchid)) Session.Client.Self.Touch(touchid); } else if (command == "updates") { if (cmd.Length < 2) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } string toggle = cmd[1].ToLower(); if (toggle == "on") { Session.Client.Settings.SEND_AGENT_UPDATES = true; Display.InfoResponse(sessionNum, "Update timer ON"); } else if (toggle == "off") { Session.Client.Settings.SEND_AGENT_UPDATES = false; Display.InfoResponse(sessionNum, "Update timer OFF"); } else { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } } else if (command == "walk") { Session.Client.Self.Movement.AlwaysRun = false; } else if (command == "wear") { UUID itemid; if (cmd.Length < 2 || !UUID.TryParse(cmd[1], out itemid)) { Display.Help(command); return ScriptSystem.CommandResult.InvalidUsage; } if (!Session.Client.Inventory.Store.Contains(itemid)) { Display.Error(sessionNum, "Asset id not found in inventory cache"); return ScriptSystem.CommandResult.UnexpectedError; } InventoryItem item = (InventoryItem)Session.Client.Inventory.Store[itemid]; AttachmentPoint point = AttachmentPoint.Default; if (cmd.Length > 2) { string p = cmd[2].ToLower(); if (p == "skull") point = AttachmentPoint.Skull; else if (p == "chest") point = AttachmentPoint.Chest; else if (p == "lhand") point = AttachmentPoint.LeftHand; else if (p == "lhip") point = AttachmentPoint.LeftHip; else if (p == "llleg") point = AttachmentPoint.LeftLowerLeg; else if (p == "mouth") point = AttachmentPoint.Mouth; else if (p == "nose") point = AttachmentPoint.Nose; else if (p == "pelvis") point = AttachmentPoint.Pelvis; else if (p == "rhand") point = AttachmentPoint.RightHand; else if (p == "rhip") point = AttachmentPoint.RightHip; else if (p == "rlleg") point = AttachmentPoint.RightLowerLeg; else if (p == "spine") point = AttachmentPoint.Spine; else if (p == "hudtop") point = AttachmentPoint.HUDTop; else if (p == "hudbottom") point = AttachmentPoint.HUDBottom; //FIXME - support all other points else { Display.InfoResponse(sessionNum, "Unknown attachment point \"" + p + "\" - using object default"); } } Session.Client.Appearance.Attach(item, point); Display.InfoResponse(sessionNum, "Attached: " + item.Name + " (" + item.Description + ")"); } else if (command == "whisper") { Session.Client.Self.Chat(details, 0, ChatType.Whisper); } else if (command == "who") { Display.Who(sessionNum); } else if (command == "whois") { //FIXME - add whois } else { Display.InfoResponse(sessionNum, "Unknown command: " + command.ToUpper()); return ScriptSystem.CommandResult.InvalidUsage; } return ScriptSystem.CommandResult.NoError; }
public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) { PrimData PData = new PrimData(); this.primData = PData; this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; PData.OwnerID = agentID; PData.PCode = addPacket.ObjectData.PCode; PData.PathBegin = addPacket.ObjectData.PathBegin; PData.PathEnd = addPacket.ObjectData.PathEnd; PData.PathScaleX = addPacket.ObjectData.PathScaleX; PData.PathScaleY = addPacket.ObjectData.PathScaleY; PData.PathShearX = addPacket.ObjectData.PathShearX; PData.PathShearY = addPacket.ObjectData.PathShearY; PData.PathSkew = addPacket.ObjectData.PathSkew; PData.ProfileBegin = addPacket.ObjectData.ProfileBegin; PData.ProfileEnd = addPacket.ObjectData.ProfileEnd; PData.Scale = addPacket.ObjectData.Scale; PData.PathCurve = addPacket.ObjectData.PathCurve; PData.ProfileCurve = addPacket.ObjectData.ProfileCurve; PData.ParentID = 0; PData.ProfileHollow = addPacket.ObjectData.ProfileHollow; PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; PData.PathRevolutions = addPacket.ObjectData.PathRevolutions; PData.PathTaperX = addPacket.ObjectData.PathTaperX; PData.PathTaperY = addPacket.ObjectData.PathTaperY; PData.PathTwist = addPacket.ObjectData.PathTwist; PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; LLVector3 pos1 = addPacket.ObjectData.RayEnd; this.primData.FullID = this.uuid = LLUUID.Random(); this.localid = (uint)(localID); this.primData.Position = this.Pos = pos1; }