Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1046853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:12:39+00:00 2026-05-16T16:12:39+00:00

I’m stuck on creating a class architecture to do this: I have very many

  • 0

I’m stuck on creating a class architecture to do this:

I have very many (About 78) types of block.
The level for the game is made of these blocks.
In the level’s ByteArray, there are simply numbers, denoting the type of block.
So for collision handling, I can just retrieve the number at the wanted position and get that block’s properties. (Solid, selectable, visible, texture).
BUT.
I’ll be reordering this list of blocks, and so, also need a way to access a block’s properties by name.

So, I’d like to be able to access a block’s properties via

Blocks[5].Properties

&

Blocks.Rock.Properties

Be aware that these are NOT instances, and I shouldn’t have to instantiate them to access their properties.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:12:39+00:00Added an answer on May 16, 2026 at 4:12 pm

    If you want Blocks[5].Properties as well as Blocks.Rock.Properties, Blocks must be a custom class with an indexer. The setup is similar to an operation:

    public Block this[] (int index) 
    {
       //getter logic here
    }
    

    Indexers can take integral types or strings, so you could use Blocks to wrap a dictionary and access values by key: Blocks["Rock"].Properties. That does involve “magic strings”, which the compiler will not catch if you misspell.

    The named getters are simple read-only properties:

    public Block Rock { get{//getter logic here} }
    

    If this were my application, I would create a singleton Blocks class. The blocks are integral to the game, used throughout its lifetime and you don’t want to explicitly instantiate them; definition of a singleton scenario (and easier to change to a normally-scoped instance than if it were all static). That Blocks class would wrap a collection of Block objects, and that implementation is then hidden behind the Blocks accessors. You can use a List and search through their Properties using Linq (I assume the properties of a Block would include the BlockID as well as its name), or you can choose the index or name of a block to be the key of a Dictionary of Blocks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.