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 6130349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:50:53+00:00 2026-05-23T16:50:53+00:00

I have a bunch of different npcs. They all have different properties and different

  • 0

I have a bunch of different npcs. They all have different properties and different AI, so I have made a separate class for each type, and derive it from a base class Entity. I want to make it so that I can assign an ID to each type of Entity, so I can just call CreateNewEntity(int id, Vector2 position). How would I do this? I also have a feeling that I’m designing this badly. Is that true

  • 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-23T16:50:54+00:00Added an answer on May 23, 2026 at 4:50 pm

    There are a couple of ways you could do this.
    You could create an Attribute that will give the type some metadata such as ID
    e.g.

    public class RenderableEntity{
    }
    
    [EntityTypeAttribute(Name = "Wizard"]
    public class Wizard : RenderableEntity{
    }
    

    you could then bundle them all in a namespace or a logical container and create the type as follows
    pseudo:

    //Create Entity
    //Type Name
    string entityName = "Wizard";
    
    //Get the Type
    from the namespace where the type has the custom attribute applied to it. Get the type
    
    //Activator.Create(typeof(TheWizardType))
    

    The other is that you could just get the Type where the name matches the string you passed into your create method.

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

Sidebar

Related Questions

I have a bunch of simple data objects of different types (all properties are
Let's say that I have a bunch of class instances that serve different purposes,
I have a bunch of images with different sizes. Each of them should be
I have a bunch of courses and each course has a different number of
I have a bunch of different tables each of which have an ID column
I have a bunch of different DTO classes. They are being serialized into an
i have a page that loads a bunch of different windows which each come
I have in my Rails application a bunch of different providers that each have
I have a bunch of different audio recordings in WAV format (all different instruments
I have a bunch of different objects that are commonly edited in the same

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.