private void AddNewCreatures() { foreach (var newSimObject in NewSimObjects) { SimObjects.Add(newSimObject); } NewSimObjects.Clear(); }
/// <summary> /// Delete all the dead creatures from the context /// </summary> private void RemoveDeadCreatures() { var dc = GetDeadCreatures(); if (!dc.Any()) { return; } foreach (var deadCreature in GetDeadCreatures()) { SimObjects.Remove(deadCreature); } }
public void DeletePrim(Primitive thePrim) { if (thePrim is Avatar) { return; } SimObject O = GetSimObject(thePrim); if (O != null) { SimObjects.Remove(O); SimRootObjects.Remove(O); SimChildObjects.Remove(O); SimAttachmentObjects.Remove(O); SimAvatars.Remove(O); SendOnRemoveSimObject(O); } uint objectLocalID = thePrim.LocalID; client.Inventory.RequestDeRezToInventory(objectLocalID, DeRezDestination.AgentInventoryTake, client.Inventory.FindFolderForType(AssetType.TrashFolder), UUID.Random()); }
public void RemoveSimObject(SimObject simObject) => SimObjects.Remove(simObject);
public void AddObstacle(int xPos, int yPos) { SimObjects.Add(new Obstacle(xPos, yPos, this)); }
/// <summary> /// Add a new obstacle to the SimObjects list /// </summary> /// <param name="obstacle">Obstacle object</param> public void AddObstacle(Obstacle obstacle) => SimObjects.Add(obstacle);
public void AddPlant(int energy, int xPos, int yPos) { SimObjects.Add(new Plant(energy, xPos, yPos, this)); }
/// <summary> /// Add a new plant to the SimObjects list /// </summary> /// <param name="plant">Plant object</param> public void AddPlant(Plant plant) => SimObjects.Add(plant);
/// <summary> /// Add a new creature to the SimObjects list /// </summary> /// <param name="creature">Creature object</param> public void AddCreature(Creature creature) => SimObjects.Add(creature);
/// <summary> /// Check if the location contains any SimObjects /// </summary> /// <param name="xPos">The x position to look on the grid</param> /// <param name="yPos">The Y position to look on the grid</param> /// <returns>True if the location contains a SimObject, else False</returns> public bool HasSimObjects(int xPos, int yPos) { return(SimObjects.Any(s => s.XPos == xPos && s.YPos == yPos)); }
/// <summary> /// Get all the dead creatures in the context. /// /// A creature is dead when the energy is equal to or lower then 0. /// </summary> /// <returns>List of all the dead creatures in the context</returns> public ReadOnlyCollection <Creature> GetDeadCreatures() => SimObjects.OfType <Creature>().Where(c => c.IsAlive == false).ToList().AsReadOnly();
/// <summary> /// get all simobjects of a certain SimObject type /// </summary> /// <typeparam name="TSimObject">A type of SimObject</typeparam> /// <returns></returns> public ReadOnlyCollection <TSimObject> GetSimObjects <TSimObject>() where TSimObject : SimObject { var so = SimObjects.OfType <TSimObject>().ToList(); return(new ReadOnlyCollection <TSimObject>(so)); }