public virtual void ScheduledUpdate(Chunk chunk, BlockPos pos, Block block)
 {
     if (BlockOverride.GetBlockOverride(block.type) != null)
     {
         BlockOverride.GetBlockOverride(block.type).ScheduledUpdate(chunk, pos, block);
     }
 }
 public virtual void OnDestroy(Chunk chunk, BlockPos pos, Block block)
 {
     if (BlockOverride.GetBlockOverride(block.type) != null)
     {
         BlockOverride.GetBlockOverride(block.type).OnDestroy(chunk, pos, block);
     }
 }
 public virtual void PostRender(Chunk chunk, BlockPos pos, Block block)
 {
     if (BlockOverride.GetBlockOverride(block.type) != null)
     {
         BlockOverride.GetBlockOverride(block.type).PostRender(chunk, pos, block);
     }
 }
Exemple #4
0
    /// <summary>
    /// Adds a block type to the index and adds it's name to a dictionary for quick lookup
    /// </summary>
    /// <param name="controller">The controller object for this block</param>
    /// <returns>The index of the block</returns>
    public int AddBlockType(BlockController controller)
    {
        int index = controllers.Count;

        if (index == ushort.MaxValue)
        {
            Debug.LogError("Too many block types!");
            return(-1);
        }

        if (names.ContainsKey(controller.Name()))
        {
            Debug.LogError("Two blocks with the name " + controller.Name() + " are defined");
        }

        controllers.Add(controller);
        BlockOverride blockOverride = GetBlockOverride(controller.Name());

        if (blockOverride != null)
        {
            blockOverride.controller = controller;
        }

        blockOverrides.Add(blockOverride);

        names.Add(controller.Name().ToLower().Replace(" ", ""), index);
        return(index);
    }
    public virtual Block OnCreate(Chunk chunk, BlockPos pos, Block block)
    {
        if (BlockOverride.GetBlockOverride(block.type) == null)
        {
            return(block);
        }

        return(BlockOverride.GetBlockOverride(block.type).OnCreate(chunk, pos, block));
    }
    public virtual T GetFlagOrOverride <T>(Object key, Chunk chunk, BlockPos pos, Block block) where T : new()
    {
        if (BlockOverride.GetBlockOverride(block.type) != null)
        {
            System.Object overridenReturn = BlockOverride.GetBlockOverride(block.type).GetFlagIntercept(key, chunk, pos, block);
            if (overridenReturn != null)
            {
                return((T)overridenReturn);
            }
        }

        return(GetFlag <T>(key));
    }