public IEnumerable SubSet(IEnumerable guids) { if (guids == null) { throw new ArgumentNullException("guids", "Cannot obtain a null item or subset from " + GhPython.Component.ScriptingAncestorComponent.DOCUMENT_NAME); } foreach (var obj in guids) { if (obj is Guid) { var id = (Guid)obj; if (Objects.Contains(id)) { yield return(Objects.Find(id).Geometry); } else { yield return(null); } } else { yield return(null); } } }
public object this[Guid id] { get { return(Objects.Contains(id) ? Objects.Find(id).Geometry : null); } }
public bool NeedsUpdateRecursive(IBoundedObject component) { lock (ObjectLock) { if (Objects.Contains(component)) { return(!component.GetBoundingBox().Intersects(Bounds)); } else if (HasChildren()) { bool shouldUpdate = false; for (int i = 0; i < 8; i++) { OctreeNode node = Children[i]; if (node == null) { continue; } if (node.NeedsUpdateRecursive(component)) { shouldUpdate = true; } } return(shouldUpdate); } else { return(false); } } }
public bool ContainsObjectRecursive(IBoundedObject component) { lock (ObjectLock) { if (Objects.Contains(component)) { return(true); } else { for (int i = 0; i < 8; i++) { OctreeNode node = Children[i]; if (node == null) { continue; } if (node.ContainsObjectRecursive(component)) { return(true); } } } return(false); } }
public bool RemoveObjectRecursive(IBoundedObject component) { lock (ObjectLock) { if (Objects.Contains(component)) { return(RemoveObject(component)); } else { bool toReturn = false; for (int i = 0; i < 8; i++) { OctreeNode node = Children[i]; if (node != null) { toReturn = node.RemoveObjectRecursive(component) || toReturn; } } Objects.Remove(component); if (Tree.ObjectsToNodes.ContainsKey(component) && Tree.ObjectsToNodes[component] == this) { Tree.ObjectsToNodes.Remove(component); } return(toReturn); } } }
/// <summary> /// Remove the specified bound. /// </summary> /// <param name="Obj">Object.</param> public virtual void Remove(T Obj) { if (Objects.Contains(Obj)) { Objects.Remove(Obj); } }
public override void Update(GameTime gameTime) { if (((humanity && otherNature) || (otherHumanity && nature)) && !Objects.Contains(startButton)) { this.Add(startButton); } else if (Objects.Contains(startButton) && !((humanity && otherNature) || (otherHumanity && nature))) { startButton.Text = "Start"; Remove(startButton); timer = null; } if (timer != null) { timer.Update(gameTime); startButton.Text = ((int)timer.TimeLeft).ToString(); if (timer.TimeLeft <= 0) { if (humanity) { GameData.player.GetFaction = Player.Faction.humanity; } else { GameData.player.GetFaction = Player.Faction.nature; } GameWorld.GameStateManager.SwitchTo("hud"); } } }
public void Append(User aSemantic) { if (Objects.Contains(aSemantic)) { return; } Objects.Add(aSemantic); }
public void Remove(User aSemantic) { if (!Objects.Contains(aSemantic)) { return; } Objects.Remove(aSemantic); }
/// <summary> /// Contains the specified obj. /// </summary> /// <param name="obj">The obj.</param> /// <returns></returns> public virtual bool ContainsObject(IObject obj) { if (obj == null) { ActiveLogger.LogMessage("Cant compare with null obj", LogLevel.RecoverableError); return(false); } return(Objects.Contains(obj)); }
/// <summary> /// Adds the object to the fit list. /// </summary> /// <param name="Obj">Object.</param> public virtual void AddObjects(params T[] objs) { foreach (var obj in objs) { if (!Objects.Contains(obj)) { Objects.Add(obj); } } }
public void AddObject(GeoObject obj) { if (!Objects.Contains(obj)) { Objects.Add(obj); if (ObjectIsInViewRegion(obj)) { ObjectsInView.Add(obj); } } }
public void Leave(WorldObject obj) { if (!Objects.Contains(obj)) { return; } if (obj is Character) { Clients.Remove((obj as Character).Client); } Objects.Add(obj); }
public async Task AddObject(ObjectGraph obj) { if (Objects.Contains(obj)) //TODO: Way better compare needed { Text.DarkYellowLine($"{obj.Name} exists, not adding."); return; } Objects.Add(obj); Text.White($"Adding Object '"); Text.DarkMagenta(obj.Name); Text.WhiteLine("'"); await Task.CompletedTask; }
public List <IBoundedObject> MergeRecursive() { List <IBoundedObject> toReturn = new List <IBoundedObject>(); for (int i = 0; i < 8; i++) { OctreeNode node = Children[i]; if (node != null) { toReturn.AddRange(node.MergeRecursive()); } } for (int i = 0; i < 8; i++) { if (Children[i] != null) { lock (Children[i].ObjectLock) { Children[i].Objects.Clear(); } } Children[i] = null; } List <IBoundedObject> toAdd = new List <IBoundedObject>(); toAdd.AddRange(toReturn); lock (ObjectLock) { toReturn.AddRange(Objects); } foreach (IBoundedObject component in toAdd) { lock (ObjectLock) { if (!Objects.Contains(component)) { Objects.Add(component); Tree.ObjectsToNodes[component] = this; } } } return(toReturn); }
/// <summary> /// UIのオブジェクトを削除する /// </summary> /// <param name="ui">削除するUIのオブジェクト</param> /// <exception cref="ArgumentException"><paramref name="ui"/>が登録されていない</exception> /// <exception cref="ArgumentNullException"><paramref name="ui"/>がnull</exception> public void RemoveUIObject <T>(T ui) where T : Object2D, IUIElements { if (ui == null) { throw new ArgumentNullException(); } if (!infos.Contains(ui) || !Objects.Contains(ui)) { throw new ArgumentException(); } if (ui.Layer == this) { RemoveObject(ui); } infos.Remove(ui); }
public void Add(CSharpConstruct construct) { if (construct is Namespace @namespace) { if (!Childs.Contains(@namespace)) { Childs.Add(@namespace); } } else if (construct is Type @object) { if (!Objects.Contains(@object)) { Objects.Add(@object); } } }
public void Leave(WorldObject obj) { if (!Objects.Contains(obj)) { return; } if (obj is Character) { Clients.Remove((obj as Character).Client); } Objects.Remove(obj); foreach (SimpleClient client in Clients) { ContextRoleplayHandler.SendSnapshotMessage(client, new Snapshot[] { new RemoveObjectSnapshot((uint)obj.GetHashCode()) }); } }
public bool AddShip(Ship ship) { if (GameStatus == GameProcessStatus.Battle) { return(false); } if (Objects.Contains(ship)) { throw new ArgumentException("This ship already in battlleground"); } //check if (!CanPlace(ship)) { return(false); } ship.Parent = this; ship.Status = ShipStatus.Full; return(Objects.Add(ship)); }
public void AddObjectRecursive(IBoundedObject component) { if (Parent == null && !component.GetBoundingBox().Intersects(Bounds)) { Tree.ExpandAndRebuild(); return; } if (component.GetBoundingBox().Intersects(Bounds) && !HasChildren()) { lock (ObjectLock) { if (!Objects.Contains(component)) { Objects.Add(component); } Tree.ObjectsToNodes[component] = this; if (Objects.Count > Tree.MaxObjectsPerNode && Depth < Tree.MaxDepth) { Split(); } } } else { for (int i = 0; i < 8; i++) { OctreeNode node = Children[i]; if (node != null) { node.AddObjectRecursive(component); } } } }
public bool Contains(T item) { return(Objects.Contains(item)); }
private BoundList( StorageObjectID storageobjectID, EditorFile file, FactorySet <T> factoryset, ViewerSet <T> viewerset, BoundList <T> master ) : base( storageobjectID, file, null //TODO ) { this.factoryset = factoryset; this.viewerset = viewerset; this.master = master; hub_obj = File.Storage[StorageObjectID]; var propertybinders = new Dictionary <string, PropertyBinder <string> >(); listener_add = hub_obj.CreateListen( IOEvent.ChildAdded, (key, objID) => { int i = int.Parse(key); if (Objects.Count > i && Objects.HasItemAt(i) && Objects[i].StorageObjectID == objID) { return; } var obj = master == null ? FactorySet.Load(objID, File) : master[objID]; var namedobj = obj as INamedObject; if (namedobj != null) { if (master == null) { var name_obj = File .Storage [objID] .GetOrMake("name"); var name_val = name_obj.ReadAllString(); if (map_name.ContainsKey(name_val)) { if (master == null) { if (AutomaticallyAvoidNameCollisionsWithUnderlines) { name_val += "_"; } else { throw new ArgumentException($"Name \"{name_val}\" already in use."); } } } name_obj.WriteAllString(name_val); var binder = namedobj.Name.Bind(name_obj); namedobj.Name.AfterChange += propertybinders.Rename; propertybinders.Add(binder.Property.Value, binder); } } if (Objects.Contains(obj)) { throw new InvalidOperationException(); } Objects.Insert(i, obj); if (master == null) { if (isallowedtobindobjects) { obj.Bind(); } } } ); listener_remove = hub_obj.CreateListen( IOEvent.ChildRemoved, (key, objID) => { var i = int.Parse(key); var obj = Objects.FirstOrDefault(_ => _.StorageObjectID == objID); if (obj != null) { var namedobj = obj as INamedObject; if (namedobj != null) { if (master == null) { namedobj.Name.AfterChange -= propertybinders.Rename; propertybinders[namedobj.Name.Value].Dispose(); propertybinders.Remove(namedobj.Name.Value); } } if (master == null) { obj.Unbind(); } Objects.Remove(obj); } } ); listener_move = hub_obj .Graph .CreateListen( msg => { var old_i = int.Parse(msg.Relation); var new_i = int.Parse(msg.NewRelation); Objects.Move(old_i, new_i); }, hub_obj.ID, IOEvent.ChildRekeyed ); Objects.ItemInserted += (obj, i) => { if (!hub_obj.HasChild(obj.StorageObjectID)) { if (master == null) { throw new InvalidOperationException(); } hub_obj.Add(i.ToString(), obj.StorageObjectID); } var namedobj = obj as INamedObject; if (namedobj != null) { namedobj.Name.BeforeChange += Object_Renaming; namedobj.Name.AfterChange += Object_Renamed; map_name.Add(namedobj.Name.Value, obj); map_name_inverse.Add(obj, namedobj.Name.Value); } map_storageobjectID.Add(obj.StorageObjectID, obj); map_storageobjectID_inverse.Add(obj, obj.StorageObjectID); }; Objects.ItemWithdrawn += (obj, i) => { if (hub_obj.HasChild(obj.StorageObjectID)) { hub_obj.Remove(obj.StorageObjectID); } var namedobj = obj as INamedObject; if (namedobj != null) { namedobj.Name.BeforeChange -= Object_Renaming; namedobj.Name.AfterChange -= Object_Renamed; namedobj.Name.AfterChange -= propertybinders.Rename; map_name.Remove(namedobj.Name.Value); map_name_inverse.Remove(obj); } map_storageobjectID.Remove(obj.StorageObjectID); map_storageobjectID_inverse.Remove(obj); }; Objects.ItemMoved += (item, oldindex, newindex) => { var sign = Math.Sign(newindex - oldindex); for (int i = oldindex; i != newindex; i += sign) { if (isallowedtobindobjects) { throw new NotImplementedException(); } else { // The bound list is still loading items from storage. // The 'moving' is really just initialization to sync with // the back-end store, if the code ran this else clause. } } }; }
public bool Contains(T t) { return(Objects.Contains(t)); }
public bool Contains(StackItem item) { return(Objects.Contains(item)); }
public bool Contains(KeyValuePair <string, object> item) { return(Objects.Contains(item)); }
// FIRST STEP: NO CONSTRAINTS private static void WriteObject(object input, object key = null) { // TODO: 1. Null -> escape // Not null -> get type of input: inputType // TODO: 1.1 Comparer, Enum -> escape (CHECK LATER) // TODO: 2. if inputType is NOT primatives/string/collections, (mean RefType) // TODO: 3. get serialized fields // TODO: 4. if serializedType IS primatives/string -> create column for inputType-> insert data // Create Table (id) // If input.Parent is NOT null // create ref column ParentId -> constraint to parent // TODO: 5. if serializedType IS RefType -> create ref column for inputType, set serializeType.Parent = input -> goto WriteObject(serializedType) // TODO: 6. if serializedType IS collections // looping collections: collectionItem->, collectionItem.Parent = input, goto WriteObject(collectionItem) // create table serializedType (id, ref table = input) // looping collection: collectionItem // collectionItem.Parent = serializedType // CODES // 1. if (input == null) { return; } var type = input.GetType(); // 1.1 if (type == typeof(Comparer) || type.IsEnum) { return; } if (Objects.Contains(input)) { return; } Measure(); Objects.Add(input); if (input is IEnumerable) { WriteEnumerable((IEnumerable)input); return; } // 2. if (SerializeInfo.PrimativeValueTypes.Contains(type)) { // CHECK LATER return; } // 3. var fields = SerializeInfo.GetSerializableFieldInfo(input).ToList(); // 4. var primativeAndTextFields = fields.GetOut(f => SerializeInfo.PrimativeValueTypes.Contains(f.FieldType) || (Type)f.FieldType == typeof(string)); //CreateTableColumn(tName, primativeAndTextFields); CreateAndInsertObjToDb(input, primativeAndTextFields, key); // 5. var refTypes = fields.GetOut(f => { if (SerializeInfo.PrimativeValueTypes.Contains(f.FieldType)) { return(false); } if (typeof(string).IsAssignableFrom(f.FieldType)) { return(false); } if (SerializeInfo.TreatedCollectionTypes.Exists(t => t.IsAssignableFrom(f.FieldType))) { return(false); } return(true); }); foreach (var field in refTypes) { var val = field.GetValue(input); if (val == null) { continue; } val.SetParent(input); //val.SetName(field.FieldType.Name); WriteObject(val); } // 6. var enumerables = fields.GetOut(f => typeof(IEnumerable).IsAssignableFrom(f.FieldType)); foreach (var enumerable in enumerables) { var d = enumerable.GetValue(input) as IEnumerable; if (d == null) { continue; } d.SetParent(input); WriteEnumerable(d); } }