コード例 #1
0
 private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     if (e.Item.Type == EntityType.Leader)
     {
         Leader leader = (Leader)e.Item;
         if (leader.Annotation != null)
         {
             this.entities.Add(leader.Annotation);
         }
     }
     else if (e.Item.Type == EntityType.Hatch)
     {
         Hatch hatch = (Hatch)e.Item;
         foreach (HatchBoundaryPath path in hatch.BoundaryPaths)
         {
             foreach (EntityObject entity in path.Entities)
             {
                 this.entities.Add(entity);
             }
         }
     }
     else if (e.Item.Type == EntityType.Viewport)
     {
         Viewport viewport = (Viewport)e.Item;
         if (viewport.ClippingBoundary != null)
         {
             this.entities.Add(viewport.ClippingBoundary);
         }
     }
     this.OnEntityAddedEvent(e.Item);
     e.Item.Owner = this;
 }
コード例 #2
0
 private void Entities_BeforeAddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     // null items, entities already owned by another Block, attribute definitions and attributes are not allowed in the entities list.
     if (e.Item == null)
     {
         e.Cancel = true;
     }
     else if (this.entities.Contains(e.Item))
     {
         e.Cancel = true;
     }
     else if (this.Flags.HasFlag(BlockTypeFlags.ExternallyDependent))
     {
         e.Cancel = true;
     }
     else if (e.Item.Owner != null)
     {
         // if the block does not belong to a document, all entities which owner is not null will be rejected
         if (this.Record.Owner == null)
         {
             e.Cancel = true;
         }
         // if the block belongs to a document, the entity will be added to the block only if both, the block and the entity document, are the same
         // this is handled by the BlocksRecordCollection
     }
     else
     {
         e.Cancel = false;
     }
 }
コード例 #3
0
 private void RemoveParticuleEmitterEntity(EntityCollectionEventArgs e)
 {
     if (e.Entity.Particules == null)
     {
         return;
     }
     EmitterStaticEntities.RemoveAll(x => x.Entity == e.Entity);
 }
コード例 #4
0
 private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     if (this.readOnly)
     {
         return;
     }
     this.OnEntityAddedEvent(e.Item);
     e.Item.Owner = this;
 }
コード例 #5
0
ファイル: MapArea.cs プロジェクト: ErtyHackward/utopia
        public void OnStaticEntityRemoved(EntityCollectionEventArgs e)
        {
            var handler = StaticEntityRemoved;

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #6
0
 private void Entities_RemoveItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     if (this.readOnly)
     {
         return;
     }
     this.OnEntityRemovedEvent(e.Item);
     e.Item.Owner = null;
 }
コード例 #7
0
        private void RemoveOutOfChunkLightSourceStaticEntity(EntityCollectionEventArgs e)
        {
            var item = e.Entity as ILightEmitterEntity;

            if (item == null)
            {
                return;
            }
            OutOfChunkLightSourceStaticEntities.Remove(item);
        }
コード例 #8
0
        private void RemoveSoundEntity(EntityCollectionEventArgs e)
        {
            var item = e.Entity as IItem;

            if (item == null || item.EmittedSound == null || item.EmittedSound.FilePath == null)
            {
                return;
            }
            SoundStaticEntities.Remove(item);
        }
コード例 #9
0
        private void OnEntityRemoved(EntityCollectionEventArgs e)
        {
            e.Chunk = Chunk;
            var handler = EntityRemoved;

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #10
0
ファイル: Block.cs プロジェクト: WKleinschmit/netDxf
 private void Entities_BeforeRemoveItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     if (e.Item.Reactors.Count > 0)
     {
         e.Cancel = true;
     }
     else
     {
         // only items owned by the actual block can be removed
         e.Cancel = !ReferenceEquals(e.Item.Owner, this);
     }
 }
コード例 #11
0
        private void AddOutOfChunkLightSourceStaticEntity(EntityCollectionEventArgs e)
        {
            var item = e.Entity as ILightEmitterEntity;

            if (item == null)
            {
                return;
            }
            if (this.CubeRange.Contains(item.Position.ToCubePosition()) == false)
            {
                OutOfChunkLightSourceStaticEntities.Add(item);
            }
        }
コード例 #12
0
 private void AddParticuleEmitterEntity(EntityCollectionEventArgs e)
 {
     if (e.Entity.Particules == null)
     {
         return;
     }
     foreach (var entityParticules in e.Entity.Particules)
     {
         EmitterStaticEntities.Add(new EntityMetaData()
         {
             Entity = e.Entity, Particule = entityParticules, EntityLastEmitTime = DateTime.Now
         });
     }
 }
コード例 #13
0
ファイル: Group.cs プロジェクト: NTUST-PTL/PTL-Project
 private void Entities_BeforeAddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     // null or duplicate items are not allowed in the entities list.
     if (e.Item == null)
     {
         e.Cancel = true;
     }
     else if (this.entities.Contains(e.Item))
     {
         e.Cancel = true;
     }
     else
     {
         e.Cancel = false;
     }
 }
コード例 #14
0
ファイル: Block.cs プロジェクト: gorangrubic/netDxf
 private void Entities_RemoveItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     if (this.readOnly)
     {
         return;
     }
     if (e.Item.Type == EntityType.Hatch)
     {
         Hatch hatch = (Hatch)e.Item;
         foreach (HatchBoundaryPath path in hatch.BoundaryPaths)
         {
             this.Hatch_BoundaryPathRemoved(hatch, new ObservableCollectionEventArgs <HatchBoundaryPath>(path));
         }
         hatch.HatchBoundaryPathAdded   -= this.Hatch_BoundaryPathAdded;
         hatch.HatchBoundaryPathRemoved -= this.Hatch_BoundaryPathRemoved;
     }
     this.OnEntityRemovedEvent(e.Item);
     e.Item.Owner = null;
 }
コード例 #15
0
ファイル: Block.cs プロジェクト: gorangrubic/netDxf
 private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     if (this.readOnly)
     {
         return;
     }
     // if the entity is a hatch we will also add the boundary entities to the block
     if (e.Item.Type == EntityType.Hatch)
     {
         Hatch hatch = (Hatch)e.Item;
         foreach (HatchBoundaryPath path in hatch.BoundaryPaths)
         {
             this.Hatch_BoundaryPathAdded(hatch, new ObservableCollectionEventArgs <HatchBoundaryPath>(path));
         }
         hatch.HatchBoundaryPathAdded   += this.Hatch_BoundaryPathAdded;
         hatch.HatchBoundaryPathRemoved += this.Hatch_BoundaryPathRemoved;
     }
     this.OnEntityAddedEvent(e.Item);
     e.Item.Owner = this;
 }
コード例 #16
0
ファイル: Block.cs プロジェクト: selenur/netDxf-1
 private void Entities_BeforeAddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     // null items, entities already owned by another Block, attribute definitions and attributes are not allowed in the entities list.
     if (e.Item == null)
     {
         e.Cancel = true;
     }
     else if (this.Flags.HasFlag(BlockTypeFlags.ExternallyDependent))
     {
         e.Cancel = true;
     }
     else if (e.Item.Owner != null)
     {
         e.Cancel = true;
     }
     else
     {
         e.Cancel = false;
     }
 }
コード例 #17
0
ファイル: Block.cs プロジェクト: xiaodelea/SvgConverter
 private void Entities_BeforeAddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     // null items, entities already owned by another Block, attribute definitions and attributes are not allowed in the entities list.
     if (e.Item == null)
     {
         e.Cancel = true;
     }
     else if (e.Item is AttributeDefinition)
     {
         e.Cancel = true;
     }
     else if (e.Item is Attribute)
     {
         e.Cancel = true;
     }
     else if (e.Item.Owner != null)
     {
         e.Cancel = true;
     }
     else
     {
         e.Cancel = false;
     }
 }
コード例 #18
0
ファイル: Block.cs プロジェクト: WKleinschmit/netDxf
 private void Entities_RemoveItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     OnEntityRemovedEvent(e.Item);
     e.Item.Owner = null;
 }
コード例 #19
0
 private void EntitiesEntityRemoved(object sender, EntityCollectionEventArgs e)
 {
     RemoveVoxelEntity(e);
     RemoveParticuleEmitterEntity(e);
     RemoveSoundEntity(e);
 }
コード例 #20
0
        private void AddVoxelEntity(EntityCollectionEventArgs e)
        {
            var voxelEntity = e.Entity as IVoxelEntity;

            if (voxelEntity == null)
            {
                return; //My static entity is not a Voxel Entity => Not possible to render it so !!!
            }
            //Create the Voxel Model Instance for the Item
            VisualVoxelModel model = null;

            if (!string.IsNullOrEmpty(voxelEntity.ModelName))
            {
                model = _voxelModelManager.GetModel(voxelEntity.ModelName, false);
            }
            if (model != null && voxelEntity.ModelInstance == null) //The model blueprint is existing, and I need to create an instance of it !
            {
                var treeGrowing = e.Entity as TreeGrowingEntity;
                if (treeGrowing != null)
                {
                    if (treeGrowing.Scale > 0)
                    {
                        // we need to use generated voxel model
                        TreeBpSeed key;
                        key.TreeTypeId = treeGrowing.TreeTypeId;
                        key.TreeSeed   = treeGrowing.TreeRndSeed;

                        VisualVoxelModel treeModel;

                        if (_cachedTrees.TryGetValue(key, out treeModel))
                        {
                            model = treeModel;
                        }
                        else
                        {
                            var voxelModel = VoxelModel.GenerateTreeModel(treeGrowing.TreeRndSeed,
                                                                          _visualWorldParameters.WorldParameters.Configuration.TreeBluePrintsDico[
                                                                              treeGrowing.TreeTypeId]);

                            model = new VisualVoxelModel(voxelModel, _voxelModelManager.VoxelMeshFactory);
                            model.BuildMesh();

                            _cachedTrees.Add(key, model);
                        }
                    }
                }

                var treeSoul = e.Entity as TreeSoul;
                if (treeSoul != null)
                {
                    TreeBpSeed key;
                    key.TreeTypeId = treeSoul.TreeTypeId;
                    key.TreeSeed   = treeSoul.TreeRndSeed;

                    _cachedTrees.Remove(key);
                }


                voxelEntity.ModelInstance = new VoxelModelInstance(model.VoxelModel);

                //Assign state in case of growing entity !
                var growingEntity = e.Entity as PlantGrowingEntity;
                if (growingEntity != null)
                {
                    voxelEntity.ModelInstance.SetState(growingEntity.GrowLevels[growingEntity.CurrentGrowLevelIndex].ModelState);
                }

                var visualVoxelEntity = new VisualVoxelEntity(voxelEntity, _voxelModelManager);
                //Get default world translation
                Matrix instanceTranslation = Matrix.Translation(voxelEntity.Position.AsVector3());

                //Apply special rotation to the creation instance
                Quaternion instanceRotation = Quaternion.Identity;
                if (voxelEntity is IRndYRotation && ((IRndYRotation)voxelEntity).RndRotationAroundY)
                {
                    instanceRotation = Quaternion.RotationAxis(Vector3.UnitY, (float)(_rnd.NextDouble() * MathHelper.TwoPi));
                }
                else if (voxelEntity is IItem)
                {
                    var item = voxelEntity as IItem;
                    instanceRotation = item.Rotation;
                }

                //Apply special scaling to created entity (By default all blue print are 16 times too big.
                Matrix instanceScaling = Matrix.Scaling(1.0f / 16.0f);

                if (treeGrowing != null && treeGrowing.Scale > 0)
                {
                    instanceScaling = Matrix.Scaling(treeGrowing.Scale);
                }

                //Create the World transformation matrix for the instance.
                //We take the Model instance world matrix where we add a Rotation and scaling proper to the instance
                visualVoxelEntity.VoxelEntity.ModelInstance.World    = instanceScaling * instanceTranslation;
                visualVoxelEntity.VoxelEntity.ModelInstance.Rotation = instanceRotation;

                var result = GetCube(visualVoxelEntity.VoxelEntity.Position.ToCubePosition());


                if (result.IsValid)
                {
                    visualVoxelEntity.BlockLight = result.Cube.EmissiveColor;
                }
                else
                {
                    visualVoxelEntity.BlockLight = new ByteColor(255, 255, 255, 255);
                }


                if (visualVoxelEntity.VisualVoxelModel.Initialized == false)
                {
                    visualVoxelEntity.VisualVoxelModel.BuildMesh();
                }

                if (voxelEntity.ModelInstance.CanPlay("Idle"))
                {
                    voxelEntity.ModelInstance.Play("Idle", true);
                }

                lock (_syncRoot)
                {
                    List <VisualVoxelEntity> list;
                    if (_visualVoxelEntities.TryGetValue(voxelEntity.ModelName, out list))
                    {
                        list.Add(visualVoxelEntity);
                    }
                    else
                    {
                        _visualVoxelEntities.Add(voxelEntity.ModelName, new List <VisualVoxelEntity> {
                            visualVoxelEntity
                        });
                    }
                }

                var lightEntity = e.Entity as ILightEmitterEntity;
                if (e.AtChunkCreationTime == false && lightEntity != null)
                {
                    //Get the Cube where is located the entity
                    var entityWorldPosition = lightEntity.Position;
                    var entityBlockPosition = new Vector3I(MathHelper.Floor(entityWorldPosition.X),
                                                           MathHelper.Floor(entityWorldPosition.Y),
                                                           MathHelper.Floor(entityWorldPosition.Z));
                    //new TerraCubeWithPosition(entityBlockPosition, WorldConfiguration.CubeId.Air, _visualWorldParameters.WorldParameters.Configuration),
                    this.UpdateOrder = 1;
                    var cubeRange = new Range3I
                    {
                        Position = new Vector3I(entityBlockPosition.X, 0, entityBlockPosition.Z),
                        Size     = Vector3I.One
                    };
                    _chunkEntityImpactManager.CheckImpact(this, cubeRange);
                }
            }
        }
コード例 #21
0
 private void Entities_BeforeRemoveItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     // only items owned by the actual block can be removed
     e.Cancel = !ReferenceEquals(e.Item.Owner, this) || this.readOnly;
 }
コード例 #22
0
 private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     e.Item.AddReactor(this);
     this.OnEntityAddedEvent(e.Item);
 }
コード例 #23
0
ファイル: Block.cs プロジェクト: xiaodelea/SvgConverter
 private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     e.Item.Owner = this;
 }
コード例 #24
0
ファイル: Group.cs プロジェクト: NTUST-PTL/PTL-Project
 private void Entities_RemoveItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     this.OnEntityRemovedEvent(e.Item);
 }
コード例 #25
0
ファイル: Group.cs プロジェクト: NTUST-PTL/PTL-Project
 private void Entities_BeforeRemoveItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
 }
コード例 #26
0
ファイル: Group.cs プロジェクト: NTUST-PTL/PTL-Project
 private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     this.OnEntityAddedEvent(e.Item);
 }
コード例 #27
0
 private void Entities_RemoveItem(EntityCollection sender, EntityCollectionEventArgs e)
 {
     e.Item.RemoveReactor(this);
     this.OnEntityRemovedEvent(e.Item);
 }
コード例 #28
0
 void EntitiesEntityAdded(object sender, EntityCollectionEventArgs e)
 {
     GetArea(e.Entity.Position).OnStaticEntityAdded(e);
 }