private IEnumerable <IUpdatable> EnumerateUpdatables() { foreach (IAttachable attachable in AttachedObjects.Where(attachable => attachable is IUpdatable)) { if (attachable is IUpdatable) { yield return((IUpdatable)attachable); } } }
public void Attach(IAttachable attachable) { if (!AttachedObjects.Contains(attachable)) { AttachedObjects.Add(attachable); } if (attachable is ICollider) { _physicsFlag = true; } }
public IEnumerable <IAttachable> GetAttachables(string typeName) { foreach (IAttachable attachable in AttachedObjects.Where(obj => obj.AttachableType.Name.Equals(typeName))) { yield return(attachable); } foreach (IAttachable attachable in AttachedObjects) { if (attachable.Interfaces.Count(type => type.Name.Equals(typeName)) > 0) { yield return(attachable); } } }
/// <summary> /// Checks if the given Object is already in that Context. /// </summary> /// <param baseDir="type">Type of Object</param> /// <param baseDir="ID">ID</param> /// <returns>If ID is InvalidID (Object is not inititalized) then an Exception will be thrown. /// If the Object is already in that Context, the Object Instace is returned. /// If the Object is not in that Context, null is returned.</returns> public override IPersistenceObject ContainsObject(InterfaceType type, int ID) { CheckDisposed(); return(AttachedObjects.Where(obj => GetInterfaceType(obj) == type && obj.ID == ID).SingleOrDefault()); }
public IAttachable GetAttachableByName(string name) { return(AttachedObjects.Where(obj => obj.Name == name).FirstOrDefault()); }
public void Detach(IAttachable attachable) { AttachedObjects.Remove(attachable); }