private void GrabMovement(IAgent agent, Object.ObjectGroup grp, ObjectPart part, Quaternion newrot) { if (grp.IsAttached) { return; } else if (grp.IsBlockGrab && grp.RootPart == part) { return; } else if ((grp.RootPart.Flags & PrimitiveFlags.Touch) != 0 && part.PassTouchMode != PassEventMode.Never) { return; } else if (grp.IsBlockGrabObject) { return; } else if (!CanMove(agent, grp, grp.GlobalPosition)) { return; } if (grp.IsPhysics) { /* TODO: implement logic for physical input */ } else { grp.GlobalRotation = newrot; } }
public bool Run() { m_Log.Info("Create test object"); var grp = new ObjectGroup(); var part = new ObjectPart(); grp.Add(1, part.ID, part); var item = new ObjectPartInventoryItem { Name = "Test Item" }; if (item.ParentFolderID != UUID.Zero) { m_Log.Info("Test item cannot have valid PartID yet"); return(false); } part.Inventory.Add(item.ID, item.Name, item); if (part.Inventory.PartID != part.ID) { m_Log.Error("part.Inventory.PartID != part.ParentFolderID (A)"); return(false); } if (part.Inventory.PartID != item.ParentFolderID) { m_Log.Error("part.Inventory.PartID != item.ParentFolderID (A)"); return(false); } return(true); }
private void RezActualScript(AgentCircuit circuit, ObjectPart part, RezScript req, AssetData data) { if (!part.CheckPermissions(Owner, Group, InventoryPermissionsMask.Modify)) { var res = new AlertMessage { Message = "ALERT: NoPermModifyObject" }; circuit.SendMessage(res); return; } var item = new ObjectPartInventoryItem { Name = req.InventoryBlock.Name, AssetID = data.ID, Description = req.InventoryBlock.Description, AssetType = AssetType.LSLText, Creator = Owner, Owner = Owner, Flags = 0, Group = Group, IsGroupOwned = false, InventoryType = InventoryType.LSL, LastOwner = Owner, ParentFolderID = part.ID }; item.Permissions.Base = req.InventoryBlock.BaseMask; item.Permissions.Current = req.InventoryBlock.OwnerMask; item.Permissions.EveryOne = req.InventoryBlock.EveryoneMask; item.Permissions.Group = req.InventoryBlock.GroupMask; item.Permissions.NextOwner = req.InventoryBlock.NextOwnerMask; item.SaleInfo.Price = req.InventoryBlock.SalePrice; item.SaleInfo.Type = req.InventoryBlock.SaleType; part.Inventory.Add(item); part.SendObjectUpdate(); ScriptInstance instance; try { SceneInterface scene = part.ObjectGroup.Scene; instance = ScriptLoader.Load(part, item, item.Owner, data, CurrentCulture, openInclude: part.OpenScriptInclude); item.ScriptInstance = instance; item.ScriptInstance.IsRunningAllowed = scene.CanRunScript(item.Owner, part.ObjectGroup.GlobalPosition, item.AssetID); item.ScriptInstance.IsRunning = true; item.ScriptInstance.Reset(); part.ObjectGroup.Scene.SendObjectPropertiesToAgent(this, part); } catch { var res = new AlertMessage { Message = this.GetLanguageString(circuit.Agent.CurrentCulture, "CouldNotCompileScript", "Could not compile script") }; circuit.SendMessage(res); return; } }
public void SendAttachedSoundGainChange(ObjectPart objpart, double gain, double soundradius) { var req = new AttachedSoundGainChange { ObjectID = objpart.ID, Gain = gain.Clamp(0, 1) }; if (objpart.ObjectGroup.IsAttachedToPrivate) { IAgent agent; if (Agents.TryGetValue(objpart.ObjectGroup.Owner.ID, out agent) && (agent.GlobalPosition - objpart.GlobalPosition).Length <= soundradius) { agent.SendMessageAlways(req, ID); } } else { foreach (IAgent agent in Agents) { if ((agent.GlobalPosition - objpart.GlobalPosition).Length <= soundradius) { agent.SendMessageAlways(req, ID); } } } }
private void ApplyPermissions(ObjectPart prim, ObjectPermissions.Data d, InventoryPermissionsMask setmask, InventoryPermissionsMask clrmask, ObjectPropertiesSendHandler propHandler) { if ((d.Field & ObjectPermissions.ChangeFieldMask.Base) != 0) { prim.SetClrBaseMask(setmask, clrmask); } if ((d.Field & ObjectPermissions.ChangeFieldMask.Everyone) != 0) { prim.SetClrEveryoneMask(setmask, clrmask); } if ((d.Field & ObjectPermissions.ChangeFieldMask.Group) != 0) { prim.SetClrGroupMask(setmask, clrmask); } if ((d.Field & ObjectPermissions.ChangeFieldMask.NextOwner) != 0) { prim.SetClrNextOwnerMask(setmask, clrmask); } if ((d.Field & ObjectPermissions.ChangeFieldMask.Owner) != 0) { prim.SetClrOwnerMask(setmask, clrmask); } propHandler.Send(prim); }
protected ObjectController(ObjectPart part, UUID sceneID, SceneInterface.LocationInfoProvider locInfoProvider) { SceneID = sceneID; m_StateData = new PhysicsStateData(part, sceneID); m_Part = part; m_Vehicle = part.VehicleParams.GetMotor(); LocationInfoProvider = locInfoProvider; }
public void SendObjectPropertiesToAgent(IAgent agent, ObjectPart part) { if (agent.SelectedObjects(ID).Contains(part.ID)) { using (var propHandler = new ObjectPropertiesSendHandler(agent, ID)) { propHandler.Send(part); } } }
private void UpdateTaskInventoryItem(UpdateTaskInventory req, IAgent agent, ObjectPart part) { ObjectPartInventoryItem item; if (!CanEdit(agent, part.ObjectGroup, part.ObjectGroup.GlobalPosition)) { return; } if (!part.Inventory.TryGetValue(req.ItemID, out item)) { return; } if (req.TransactionID != UUID.Zero) { if (item.AssetType == AssetType.LSLText || item.AssetType == AssetType.LSLBytecode || item.InventoryType == InventoryType.LSL) { /* do not allow editing scripts through this */ return; } /* asset upload follows */ agent.SetAssetUploadAsCompletionAction(req.TransactionID, req.CircuitSceneID, new UpdateTaskInventoryItemHandler { Agent = agent, ItemID = req.ItemID, Part = part, Scene = this }.OnCompletion); } else { /* no asset upload */ part.Inventory.Rename(req.Name, item.ID); item.Description = req.Description; if (agent.IsActiveGod) { item.Permissions.Base = req.BaseMask | InventoryPermissionsMask.Move; item.Permissions.Current = req.OwnerMask; item.Permissions.EveryOne = req.EveryoneMask; item.Permissions.Group = req.GroupMask; item.Permissions.NextOwner = req.NextOwnerMask; } else if (part.Owner.EqualsGrid(agent.Owner)) { item.Permissions.EveryOne = req.EveryoneMask & item.Permissions.Base; item.Permissions.Group = req.GroupMask & item.Permissions.Base; item.Permissions.Current = req.OwnerMask & item.Permissions.Base; item.Permissions.NextOwner = req.OwnerMask & item.Permissions.Base; } Interlocked.Increment(ref part.Inventory.InventorySerial); part.SendObjectUpdate(); SendObjectPropertiesToAgent(agent, part); } }
public static void LoadFromVehicleSerialization(this ObjectPart part, byte[] data) { if (data == null || data.Length == 0) { return; } Map m; using (var ms = new MemoryStream(data)) { m = (Map)LlsdBinary.Deserialize(ms); } int i; double f; Vector3 v; Quaternion q; if (m.TryGetValue("Type", out i)) { part.VehicleType = (VehicleType)i; } if (m.TryGetValue("Flags", out i)) { part.ClearVehicleFlags(~(VehicleFlags)i); part.SetVehicleFlags((VehicleFlags)i); } foreach (KeyValuePair <string, VehicleFloatParamId> kvp in m_FloatParams) { if (m.TryGetValue(kvp.Key, out f)) { part.VehicleParams[kvp.Value] = f; } } foreach (KeyValuePair <string, VehicleVectorParamId> kvp in m_VectorParams) { if (m.TryGetValue(kvp.Key, out v)) { part.VehicleParams[kvp.Value] = v; } } foreach (KeyValuePair <string, VehicleRotationParamId> kvp in m_RotationParams) { if (m.TryGetValue(kvp.Key, out q)) { part.VehicleParams[kvp.Value] = q; } } }
public void RemoveObjectBuyListen(ScriptInstance instance) { ObjectPart part = instance.Part; ObjectPartInventoryItem item = instance.Item; if (part != null && item != null) { UUID partID = part.ID; UUID itemID = item.ID; m_ObjectBuyListeners.Remove(ObjectBuyListen.GetKey(partID, itemID)); } }
private void HandleDualTouch() { Touch firstTouch = Input.GetTouch(0); Touch secondTouch = Input.GetTouch(1); float touchLength = 100f; RaycastHit hit; if (secondTouch.phase == TouchPhase.Began) { if (IsHitObjectPart(secondTouch, out hit)) { dualTouchOffset = Vector2.Distance(firstTouch.position, secondTouch.position); part = hit.transform.gameObject.GetComponent <ObjectPart>(); partTouched = true; } else { partTouched = false; } //Debug.Log("Touch #" + touch.fingerId + " start pos: " + deltaTouch); //CalculateMovingPartPosition(SecondTouch, part.transform); //offset = part.transform.position - newPos; } if (partTouched) { if (secondTouch.phase == TouchPhase.Ended) { //Debug.Log("Touch #" + touch.fingerId + " last pos: " + touch.position); //Debug.Log("Delta Touch: " + deltaTouch); //tapCount++; touchLength = Vector2.Distance(firstTouch.position, secondTouch.position) - dualTouchOffset; Debug.Log("2nd touch movement length: " + touchLength); if (touchLength >= UIManager.ins.DualTouchLength) { if (part.Selected) { part.SendMessage("SubDisassemble"); //Debug.Log("SUB-DISASSEMBLE"); } } partTouched = false; //Debug.Log("2nd Touch: " + SecondTouch.position); } } }
private IDataObject ToDataObject(ObjectPart message) { var dataObject = new DataObject { Data = message.Data, Resource = new Resource { Uri = EtpUri.RootUri } }; return(dataObject); }
public bool TryGetValueByName(string name, out ObjectPart part) { part = null; foreach (ObjectPart p in this) { if (p.Name == name) { part = p; return(true); } } return(false); }
private ViewerConnection AddAgent(ScriptInstance instance, UUID agentId) { ViewerConnection vc; ObjectPart part = instance.Part; SceneInterface scene = part.ObjectGroup.Scene; if (!m_Clients.TryGetValue(agentId, out vc)) { vc = new ViewerConnection(m_Scenes, agentId, scene.ID, part.ID, instance.Item.ID); m_Clients.Add(agentId, vc); } return(vc); }
public AddToObjectTransferItem( IAgent agent, SceneInterface scene, UUID assetid, ObjectPart part, ObjectPartInventoryItem item) : base(scene.AssetService, agent.AssetService, assetid, ReferenceSource.Source) { m_Part = part; m_Item = item; m_Part = part; m_SceneID = scene.ID; }
public void SendPreloadSound(ObjectPart objpart, UUID sound) { var req = new PreloadSound { OwnerID = objpart.ObjectGroup.Owner.ID, SoundID = sound, ObjectID = objpart.ID }; foreach (IAgent agent in Agents) { agent.SendMessageAlways(req, ID); } }
public void AddObjectBuyListen(ScriptInstance instance) { ObjectPart part = instance.Part; ObjectPartInventoryItem item = instance.Item; if (part != null && item != null) { var listen = new ObjectBuyListen { PrimitiveID = part.ID, ItemID = item.ID }; m_ObjectBuyListeners.Add(listen.Key, listen); } }
public override bool WaitsForExperienceResponse(ObjectPart part, UUID itemID) { SceneInterface scene = part.ObjectGroup?.Scene; if (scene == null) { return(false); } AgentCircuit circuit; if (!Circuits.TryGetValue(scene.ID, out circuit)) { return(false); } return(circuit.WaitsForExperienceResponse(part.ID, itemID)); }
private int CompareParts(ObjectPart a, ObjectPart b) { if (a.Z != b.Z) { return(a.Z - b.Z); } if (a.Y != b.Y) { return(a.Y - b.Y); } if (a.SubZ != b.SubZ) { return(a.SubZ - b.SubZ); } return(a.Sprite.GetHashCode() - b.Sprite.GetHashCode()); }
public static ScriptInstance Load(ObjectPart part, ObjectPartInventoryItem item, UGUI user, AssetData data, CultureInfo currentCulture, byte[] serializedState = null, Func <string, TextReader> openInclude = null) { return(m_CompilerLock.AcquireReaderLock(() => { IScriptAssembly assembly = m_LoadedAssemblies.GetOrAddIfNotExists(data.ID, () => { using (var reader = new StreamReader(data.InputStream)) { return CompilerRegistry.ScriptCompilers.Compile(AppDomain.CurrentDomain, user, data.ID, reader, currentCulture, openInclude); } }); ScriptInstance instance = assembly.Instantiate(part, item, serializedState); m_LoadedInstances.GetOrAddIfNotExists(data.ID, () => new RwLockedList <ScriptInstance>()).Add(instance); return instance; })); }
public AnArray GetEstateManagersList(ScriptInstance instance) { var res = new AnArray(); lock (instance) { ObjectPart part = instance.Part; ObjectGroup grp = part.ObjectGroup; SceneInterface scene = grp.Scene; EstateServiceInterface estateService = scene.EstateService; foreach (UGUI agent in estateService.EstateManager.All[scene.ParentEstateID]) { res.Add(new LSLKey(agent.ID)); res.Add(agent.HomeURI?.ToString() ?? string.Empty); } } return(res); }
public override ScriptPermissions RequestPermissions(ObjectPart part, UUID itemID, ScriptPermissions permissions, UUID experienceID) { var autoGrant = ScriptPermissions.None; ObjectGroup sitOn = SittingOnObject; if ((sitOn != null && sitOn.ID == itemID) || part.ObjectGroup.AttachPoint != Types.Agent.AttachmentPoint.NotAttached) { autoGrant |= ScriptPermissions.ControlCamera; autoGrant |= ScriptPermissions.TakeControls; autoGrant |= ScriptPermissions.TrackCamera; autoGrant |= ScriptPermissions.TriggerAnimation; } if (part.ObjectGroup.AttachPoint != Types.Agent.AttachmentPoint.NotAttached) { autoGrant |= ScriptPermissions.OverrideAnimations; autoGrant |= ScriptPermissions.Attach; } if ((permissions & autoGrant) == permissions) { return(permissions); } AgentCircuit circuit; SceneInterface scene = part.ObjectGroup.Scene; if (experienceID != UUID.Zero && Circuits.TryGetValue(scene.ID, out circuit) && !circuit.AddExperienceTimeout(part.ID, itemID)) { return(ScriptPermissions.None); } var m = new ScriptQuestion { ExperienceID = experienceID, ItemID = itemID, ObjectName = part.ObjectGroup.Name, ObjectOwner = scene.AvatarNameService.ResolveName(part.Owner).FullName, Questions = permissions, TaskID = part.ID }; SendMessageAlways(m, part.ObjectGroup.Scene.ID); return(ScriptPermissions.None); }
private void AddAdditionalInventory(ObjectPart part, string sectionName) { IConfig config = m_Loader.Config.Configs[sectionName]; var creator = new UGUIWithName(config.GetString("Creator", m_ObjectCreator.ToString())) { IsAuthoritative = true }; var owner = new UGUIWithName(config.GetString("Owner", m_ObjectOwner.ToString())) { IsAuthoritative = true }; var lastOwner = new UGUIWithName(config.GetString("LastOwner", m_ObjectLastOwner.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(creator); m_AvatarNameService.Store(owner); m_AvatarNameService.Store(lastOwner); var item = new ObjectPartInventoryItem(new UUID(config.GetString("ItemID", UUID.Random.ToString()))) { Name = config.GetString("Name"), Description = config.GetString("Description", string.Empty), AssetID = new UUID(config.GetString("AssetID", UUID.Random.ToString())), AssetTypeName = config.GetString("AssetType"), Creator = creator, Owner = owner, LastOwner = lastOwner, InventoryTypeName = config.GetString("InventoryType"), Flags = (InventoryFlags)config.GetInt("Flags", 0), IsGroupOwned = config.GetBoolean("IsGroupOwned", false) }; item.Permissions.Base = (InventoryPermissionsMask)config.GetInt("BasePermissions", (int)InventoryPermissionsMask.Every); item.Permissions.Current = (InventoryPermissionsMask)config.GetInt("CurrentPermissions", (int)InventoryPermissionsMask.Every); item.Permissions.EveryOne = (InventoryPermissionsMask)config.GetInt("EveryOnePermissions", (int)InventoryPermissionsMask.Every); item.Permissions.Group = (InventoryPermissionsMask)config.GetInt("GroupPermissions", (int)InventoryPermissionsMask.Every); item.Permissions.NextOwner = (InventoryPermissionsMask)config.GetInt("NextOwnerPermissions", (int)InventoryPermissionsMask.Every); part.Inventory.Add(item); }
public void SendAttachedSound(ObjectPart objpart, UUID sound, double gain, double soundradius, PrimitiveSoundFlags flags) { var req = new AttachedSound { OwnerID = objpart.ObjectGroup.Owner.ID, SoundID = sound, ObjectID = objpart.ID, Flags = flags }; if (gain < 0) { gain = 0; } else if (gain > 1) { gain = 1; } req.Gain = gain; if (objpart.ObjectGroup.IsAttachedToPrivate) { IAgent agent; if (Agents.TryGetValue(objpart.ObjectGroup.Owner.ID, out agent) && (agent.GlobalPosition - objpart.GlobalPosition).Length <= soundradius) { agent.SendMessageAlways(req, ID); } } else { foreach (IAgent agent in Agents) { if ((agent.GlobalPosition - objpart.GlobalPosition).Length <= soundradius) { agent.SendMessageAlways(req, ID); } } } }
private void RezNewScript(AgentCircuit circuit, ObjectPart part, RezScript req) { AssetData data; try { /* this is the KAN-Ed llSay script */ data = circuit.Scene.AssetService["366ac8e9-b391-11dc-8314-0800200c9a66"]; } catch { var res = new AlertMessage { Message = "ALERT: ScriptMissing" }; circuit.SendMessage(res); return; } RezActualScript(circuit, part, req, data); }
protected void RemoveAllScripts(ScriptInstance instance, ObjectPart part) { foreach (ObjectPartInventoryItem item in part.Inventory.Values) { if (item.AssetType == AssetType.LSLText) { ScriptInstance script = item.ScriptInstance; if (script != instance && script != null) { script = item.RemoveScriptInstance; if (script != null) { ScriptThreadPool.AbortScript(script); script.Abort(); script.Remove(); ScriptLoader.Remove(item.AssetID, script); } } } } }
public AnArray GetLandBanList(ScriptInstance instance) { var res = new AnArray(); lock (instance) { ObjectPart part = instance.Part; ObjectGroup grp = part.ObjectGroup; SceneInterface scene = grp.Scene; ParcelInfo pInfo; if (scene.Parcels.TryGetValue(grp.GlobalPosition, out pInfo)) { foreach (ParcelAccessEntry pae in scene.Parcels.BlackList[scene.ID, pInfo.ID]) { res.Add(new LSLKey(pae.Accessor.ID)); res.Add(pae.Accessor.HomeURI?.ToString() ?? string.Empty); res.Add(new LongInteger(pae.ExpiresAt?.AsLong ?? 0)); } } } return(res); }
public ICollection <TextureEntryFace> GetFaces(int face) { if (m_ParentInfo != null && m_TextureEntry == null) { TextureEntry te = m_ParentInfo.TextureEntry; m_TextureEntryLock.AcquireWriterLock(() => { m_TextureEntry = te; m_TextureEntryBytes = te.GetBytes(); ObjectPart part = m_Part; if (part != null) { m_TextureEntryBytes_LimitsEnabled = te.GetBytes(part.IsFullbrightDisabled, (float)part.GlowLimitIntensity); } else { m_TextureEntryBytes_LimitsEnabled = m_TextureEntryBytes; } }); } if (face == ALL_SIDES) { var list = new List <TextureEntryFace>(); for (uint i = 0; i < m_Part.NumberOfSides; ++i) { list.Add(m_TextureEntry[i]); } return(list); } else { return(new List <TextureEntryFace> { m_TextureEntry[(uint)face] }); } }
public void Send(ObjectPart part) { var propUpdate = part.GetPropertiesUpdateData(m_Agent.CurrentCulture); if (propUpdate == null) { return; } if (m_Bytelen + propUpdate.Length > 1400) { m_Agent.SendMessageAlways(m_Props, m_SceneID); m_Bytelen = 0; m_Props = null; } if (m_Props == null) { m_Props = new ObjectProperties(); } m_Props.ObjectData.Add(propUpdate); m_Bytelen += propUpdate.Length; }
public void SendTriggerSound(ObjectPart objpart, UUID sound, double gain, double soundradius, Vector3 top_north_east, Vector3 bottom_south_west) { var req = new SoundTrigger { OwnerID = objpart.ObjectGroup.Owner.ID, SoundID = sound, ObjectID = objpart.ID, GridPosition = GridPosition, ParentID = (objpart.LinkNumber != 1) ? objpart.ObjectGroup.ID : UUID.Zero, Position = objpart.GlobalPosition, Gain = gain.Clamp(0, 1) }; if (objpart.ObjectGroup.IsAttachedToPrivate) { IAgent agent; if (Agents.TryGetValue(objpart.ObjectGroup.Owner.ID, out agent) && (agent.GlobalPosition - req.Position).Length <= soundradius) { agent.SendMessageAlways(req, ID); } } else { foreach (IAgent agent in Agents) { if ((agent.GlobalPosition - req.Position).Length <= soundradius) { agent.SendMessageAlways(req, ID); } } } }