コード例 #1
0
        public void RenderTile(ITileEntity entity, IRenderContext renderContext)
        {
            if (!entity.Tileset.IsReady)
            {
                return;
            }

            var tileset = entity.Tileset.Asset;

            if (!entity.AppliedTilesetSettings)
            {
                entity.Transform.LocalScale *= new Vector3(tileset.CellWidth, tileset.CellHeight, 1);
                entity.Width  = tileset.CellWidth;
                entity.Height = tileset.CellHeight;
                entity.AppliedTilesetSettings = true;
            }

            _renderUtilities.RenderTexture(
                renderContext,
                new Vector2(entity.Transform.LocalPosition.X * tileset.CellWidth, entity.Transform.LocalPosition.Y * tileset.CellHeight),
                tileset.Texture,
                new Vector2(entity.Width, entity.Height),
                sourceArea:
                new Rectangle(
                    entity.TX * tileset.CellWidth,
                    entity.TY * tileset.CellHeight,
                    tileset.CellWidth,
                    tileset.CellHeight));
        }
コード例 #2
0
 /// <summary>
 /// The initialize tile.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 /// <param name="tilesetAssetName">
 /// The tileset asset name.
 /// </param>
 public void InitializeTile(ITileEntity entity, string tilesetAssetName)
 {
     entity.Tileset      = this.m_AssetManager.Get <TilesetAsset>(tilesetAssetName);
     entity.LocalMatrix *= Matrix.CreateScale(entity.Tileset.CellWidth, entity.Tileset.CellHeight, 1);
     entity.Width        = entity.Tileset.CellWidth;
     entity.Height       = entity.Tileset.CellHeight;
 }
コード例 #3
0
ファイル: OTAPIWorld.cs プロジェクト: tanpro260196/WorldEdit
        /// <inheritdoc />
        public override bool RemoveTileEntity(ITileEntity tileEntity)
        {
            switch (tileEntity)
            {
            case Chest chest:
                return(RemoveChest(chest));

            case Sign sign:
                return(RemoveSign(sign));

            default:
                lock (_tileEntityLock)
                {
                    var point16 = new Point16(tileEntity.Position.X, tileEntity.Position.Y);
                    if (!TileEntity.ByPosition.TryGetValue(point16, out var ttileEntity))
                    {
                        return(false);
                    }

                    TileEntity.ByID.Remove(ttileEntity.ID);
                    TileEntity.ByPosition.Remove(point16);
                }
                return(true);
            }
        }
コード例 #4
0
 public void InitializeTile(ITileEntity entity, string tilesetAssetName)
 {
     entity.Tileset = _assetManager.Get <TilesetAsset>(tilesetAssetName);
     entity.Transform.LocalScale *= new Vector3(entity.Tileset.CellWidth, entity.Tileset.CellHeight, 1);
     entity.Width  = entity.Tileset.CellWidth;
     entity.Height = entity.Tileset.CellHeight;
 }
コード例 #5
0
ファイル: OTAPIWorld.cs プロジェクト: tanpro260196/WorldEdit
        private void AddTerrariaTileEntity(ITileEntity tileEntity)
        {
            int id;
            var x = tileEntity.Position.X;
            var y = tileEntity.Position.Y;

            lock (_tileEntityLock)
            {
                switch (tileEntity)
                {
                case ItemFrame itemFrame:
                    var item = itemFrame.Item;
                    id = TEItemFrame.Place(x, y);
                    TEItemFrame.TryPlacing(x, y, item.Type, item.Prefix, item.StackSize);
                    break;

                case LogicSensor logicSensor:
                    id = TELogicSensor.Place(x, y);
                    var terrariaLogicSensor = (TELogicSensor)TileEntity.ByID[id];
                    terrariaLogicSensor.CountedData = logicSensor.Data;
                    terrariaLogicSensor.logicCheck  = (TELogicSensor.LogicCheckType)logicSensor.Type;
                    terrariaLogicSensor.On          = logicSensor.IsEnabled;
                    break;

                case TrainingDummy _:
                    id = TETrainingDummy.Place(x, y);
                    ((TETrainingDummy)TileEntity.ByID[id]).Activate();
                    break;

                default:
                    return;
                }
            }
            NetMessage.SendData(86, -1, -1, null, id, x, y);
        }
コード例 #6
0
 public void InitializeTile(ITileEntity entity, string tilesetAssetName)
 {
     entity.Tileset = _assetManager.Get <TilesetAsset>(tilesetAssetName);
     // TODO: Figure out how to do this with delayed assets.
     //entity.Transform.LocalScale *= new Vector3(entity.Tileset.CellWidth, entity.Tileset.CellHeight, 1);
     //entity.Width = entity.Tileset.CellWidth;
     //entity.Height = entity.Tileset.CellHeight;
 }
コード例 #7
0
 /// <summary>
 /// The initialize tile.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 /// <param name="tilesetAssetName">
 /// The tileset asset name.
 /// </param>
 public void InitializeTile(ITileEntity entity, string tilesetAssetName)
 {
     entity.Tileset = this.m_AssetManager.Get <TilesetAsset>(tilesetAssetName);
     entity.X      *= entity.Tileset.CellWidth;
     entity.Y      *= entity.Tileset.CellHeight;
     entity.Width   = entity.Tileset.CellWidth;
     entity.Height  = entity.Tileset.CellHeight;
 }
コード例 #8
0
 /// <inheritdoc />
 public override bool AddTileEntity(ITileEntity tileEntity)
 {
     if (Extent.AddTileEntity(tileEntity))
     {
         _changeSet.Add(new TileEntityAddition(tileEntity));
         return(true);
     }
     return(false);
 }
コード例 #9
0
 /// <inheritdoc />
 public override bool RemoveTileEntity(ITileEntity tileEntity)
 {
     if (Extent.RemoveTileEntity(tileEntity))
     {
         _changeSet.Add(new TileEntityRemoval(tileEntity));
         return(true);
     }
     return(false);
 }
コード例 #10
0
        /// <summary>
        /// Returns a value indicating whether the tile entity is concrete: i.e., whether the tile entity <i>can</i>
        /// exist in the world.
        /// </summary>
        /// <param name="tileEntity">The tile entity.</param>
        /// <returns>
        /// <see langword="true"/> if the tile entity is concrete; otherwise, <see langword="false"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="tileEntity"/> is <see langword="null"/>.</exception>
        public static bool IsConcrete(this ITileEntity tileEntity)
        {
            if (tileEntity is null)
            {
                throw new ArgumentNullException(nameof(tileEntity));
            }

            return(tileEntity.Index >= 0);
        }
コード例 #11
0
ファイル: ChunkRenderer.cs プロジェクト: Xeltica/UniCraft
 public LocationInfo(string id, Vector3Int location, GameObject actualObject)
 {
     BlockId      = id;
     Location     = location;
     ActualObject = actualObject;
     renderer     = null;
     TileEntity   = null;
     Meta         = 0;
 }
コード例 #12
0
        /// <inheritdoc />
        public override bool AddTileEntity(ITileEntity tileEntity)
        {
            if (!IsInBounds(tileEntity.Position))
            {
                return(false);
            }

            _tileEntities.Add(tileEntity);
            return(true);
        }
コード例 #13
0
 public void RenderTile(ITileEntity entity, IRenderContext renderContext)
 {
     _renderUtilities.RenderTexture(
         renderContext,
         new Vector2(entity.Transform.LocalPosition.X * entity.Tileset.CellWidth, entity.Transform.LocalPosition.Y * entity.Tileset.CellHeight),
         entity.Tileset.Texture,
         new Vector2(entity.Width, entity.Height),
         sourceArea:
         new Rectangle(
             entity.TX * entity.Tileset.CellWidth,
             entity.TY * entity.Tileset.CellHeight,
             entity.Tileset.CellWidth,
             entity.Tileset.CellHeight));
 }
コード例 #14
0
 /// <summary>
 /// The render tile.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 /// <param name="renderContext">
 /// The render context.
 /// </param>
 public void RenderTile(ITileEntity entity, IRenderContext renderContext)
 {
     this.m_RenderUtilities.RenderTexture(
         renderContext,
         new Vector2(entity.X, entity.Y),
         entity.Tileset.Texture,
         new Vector2(entity.Width, entity.Height),
         sourceArea:
         new Rectangle(
             entity.TX * entity.Tileset.CellWidth,
             entity.TY * entity.Tileset.CellHeight,
             entity.Tileset.CellWidth,
             entity.Tileset.CellHeight));
 }
コード例 #15
0
        public void RenderTile(ITileEntity entity, IRenderContext renderContext)
        {
            if (!entity.Tileset.IsReady)
            {
                return;
            }

            var tileset = entity.Tileset.Asset;

            _renderUtilities.RenderTexture(
                renderContext,
                new Vector2(entity.Transform.LocalPosition.X * tileset.CellWidth, entity.Transform.LocalPosition.Y * tileset.CellHeight),
                tileset.Texture,
                new Vector2(entity.Width, entity.Height),
                sourceArea:
                new Rectangle(
                    entity.TX * tileset.CellWidth,
                    entity.TY * tileset.CellHeight,
                    tileset.CellWidth,
                    tileset.CellHeight));
        }
コード例 #16
0
ファイル: OTAPIWorld.cs プロジェクト: tanpro260196/WorldEdit
        /// <inheritdoc />
        public override bool AddTileEntity(ITileEntity tileEntity)
        {
            switch (tileEntity)
            {
            case Chest chest:
                return(AddChest(chest));

            case Sign sign:
                return(AddSign(sign));

            default:
                var point16 = new Point16(tileEntity.Position.X, tileEntity.Position.Y);
                if (TileEntity.ByPosition.ContainsKey(point16))
                {
                    return(false);
                }

                AddTerrariaTileEntity(tileEntity);
                return(true);
            }
        }
コード例 #17
0
 public void InitializeTile(ITileEntity entity, string tilesetAssetName)
 {
     entity.Tileset = _assetManager.Get <TilesetAsset>(tilesetAssetName);
 }
コード例 #18
0
 /// <inheritdoc />
 public override bool RemoveTileEntity(ITileEntity tileEntity) => _tileEntities.Remove(tileEntity);
コード例 #19
0
ファイル: Extent.cs プロジェクト: tanpro260196/WorldEdit
 /// <summary>
 ///     Adds the specified tile entity.
 /// </summary>
 /// <param name="tileEntity">The tile entity to add, which must not be <c>null</c>.</param>
 /// <returns><c>true</c> if the operation succeeded; otherwise, <c>false</c>.</returns>
 /// <remarks>
 ///     The extent is not guaranteed to perform the addition. For example, there may be too many tile entities in a
 ///     section.
 /// </remarks>
 public abstract bool AddTileEntity([NotNull] ITileEntity tileEntity);
コード例 #20
0
ファイル: Extent.cs プロジェクト: tanpro260196/WorldEdit
 /// <summary>
 ///     Removes the specified tile entity.
 /// </summary>
 /// <param name="tileEntity">The tile entity to remove, which must not be <c>null</c>.</param>
 /// <returns><c>true</c> if the operation succeeded; otherwise, <c>false</c>.</returns>
 /// <remarks>
 ///     The extent is not guaranteed to perform the removal.
 /// </remarks>
 public abstract bool RemoveTileEntity([NotNull] ITileEntity tileEntity);
コード例 #21
0
 /// <inheritdoc />
 public override bool RemoveTileEntity(ITileEntity tileEntity) => Extent.RemoveTileEntity(tileEntity);
コード例 #22
0
 /// <inheritdoc />
 public override bool AddTileEntity(ITileEntity tileEntity) => Extent.AddTileEntity(tileEntity);
コード例 #23
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TileEntityRemoval" /> class with the specified tile entity.
 /// </summary>
 /// <param name="tileEntity">The tile entity, which must not be <c>null</c>.</param>
 /// <exception cref="ArgumentNullException"><paramref name="tileEntity" /> is <c>null</c>.</exception>
 public TileEntityRemoval([NotNull] ITileEntity tileEntity)
 {
     TileEntity = tileEntity ?? throw new ArgumentNullException(nameof(tileEntity));
 }