Generic Enum as Type [closed]

Are generic types of enum possible in C#? I’m trying to do something like this:

// in LevelManager.cs script public class LevelManager<T>  where T : struct {     public T something; }  // in enum script (name to be changed accordingly) public enum Level { A,B,C }  // in LevelManager2.cs public class LevelManager2<Level> : LevelManager<Level>{} 

I’m asking this question mainly because the implementation for the generic class LevelManager will be hidden away in an assembly. Hence, I have to rely on something the next person would code the enum Level in. I also get this error in my test script: pic

Alternatively, I could opt for a string based method where the string is the key and I’ll have a Dictionary<string,int>. But that would require a rewriting of my entire script

Any help on how to retain an enum like structure?

Ability system in Unity: Scriptable objects and collections of generic types

I’ve decided to implement an ability system for my game and set the following requirements:

  • Abilities must be MonoBehaviors, that-is, components of Player/NPC gameobjects
  • Abilities must be able to be added/removed at runtime. Instead of all entites having all abilities on their gameobjects that are disabled/enabled, I’d like to dynamically add/remove abilities using AddComponent/Destroy(component)

Given these I’ve implemented the following:

  • Settings classes which inherit from a base AbilitySettings class which is a ScriptableObject. These contain configurable ability settings as well as an enum called AbilityIdentifier which identifies the ability (for example a jump ability would have the identifier AbilityIdentifier.JUMP)

  • IAbility non-generic interface containing a few common ability methods (such as TriggerAbility and CanTrigger)

  • AbstractAbility<T> class which implements IAbility and T is a type that extends AbilitySettings. It implements some of the IAbility methods and defines others as abstract. Actual abilities extend this class.

  • AbilityManager is a MonoBehavior which contains an array of all possible settings for that entity (added through unity editor) and internally contains a dictionary of <AbilityIdentifier, IAbility>. All of the entities abilities are added/removed using the AbilityManager

It looks something like this:

public class AbilityManager : MonoBehavior {     [SerializeField] private AbstractAbilitySettings[] allAbilitiesSettings = { };          private readonly Dictionary<AbilityIdentifier, IAbility> abilities = new Dictionary<AbilityIdentifier, IAbility>();      // Add/remove ability methods } 

For example, a jump ability pickup gameobject is set somewhere in the world as a trigger. When the player moves over the pick-up object and OnTriggerEnter is executed. The script on the pick-up object gets the AbilityManager and calls AddAbility(AbilityIdentifier.JUMP)

This sounds good but It’s far from perfect. First of all, I couldn’t figure out an elegant way of creating/removing a component when given the settings class so I’ve added the creation/destruction code to the settings class itself. That-is I’ve added the following abstract methods to AbilitySettings

public abstract IAbility InstantiateAbility(GameObject gameObject);  public abstract void RemoveAbility(GameObject gameObject); 

which are then implemented in each of the concrete settings classes like this:

public override IAbility InstantiateAbility(GameObject gameObject) {     JumpAbility ability = gameObject.AddComponent<JumpAbility>();     ability.Settings = this;     return ability; }  public override void RemoveAbility(GameObject gameObject) {     JumpAbility ability = gameObject.GetComponent<JumpAbility>();     Destroy(ability); } 

And these methods are called in the AbilityManager like this

public void AddAbility(AbilityIdentifier identifier) {     AbilitySettings abilitySettings = Array.Find(allAbilitiesSettings, s => s.Identifier == identifier);      abilitySettings.InstantiateAbility(gameObject); } 

The implementation of InstantiateAbility and RemoveAbility is the same for every single ability, the only difference being the ability type. This is a big smell for me. I can’t make AbilitySettings generic and generify the two methods as these settings are in an array.

My questions are:

  • Adding methods such as InstantiateAbility and RemoveAbility to a scriptable object seems like a code smell to me. Take into account that I’m using the AbilityIdentifier to specify to the manager which ability I want to create. I have thought of perhaps creating an AbilityFactory<T> but since it’s a generic class it can’t be a part of an array/list so I’m facing the same problem I did with the settings. Is there a different way I could handle this without having the code in the scriptable object?

  • Having the implementation of these two methods InstantiateAbility and RemoveAbility be the same for every implementation with the only difference being the type is also a big code smell. Is there any way I can generify this but at the same time avoid problems with the inability of having an array or list of those generic classes?

Are there rules for combining generic variant magic items?

For example: Adamantine armor is an uncommon generic armor variant. +1 armor is a rare variant. Is there such a thing as +1 adamantine plate armor? What’s its rarity?

Does the situation change when one of the item "bases" is a generic variant, but the other isn’t? For example, javelin of lightning is a specific uncommon magic weapon. +1 is a generic uncommon modifier to weapons. What about a +1 javelin of lightning?

Does the Sneak Attack class feature of the Generic Classes stack with the improved and greater versions of it?

Generic Classes have the possibility to gain different class features in exchange of a bonus feat:

For the purposes of these classes, the following class features can be selected in place of bonus feats (unless noted, each may only be selected once).

The Sneak Attack class features that can be selected are:

Sneak Attack (Ex)

As the rogue ability, but +2d6 on damage rolls. Prerequisites: Hide 4 ranks, Move Silently 4 ranks.

Improved Sneak Attack (Ex)

Add +3d6 to your sneak attack damage. Prerequisites: Hide 11 ranks, Move Silently 11 ranks, sneak attack.

Greater Sneak Attack (Ex)

Add +4d6 to your sneak attack damage. Prerequisites: Hide 18 ranks, Move Silently 18 ranks, sneak attack, improved sneak attack.

Do these three class features stack together?

Do you have to use a skill from the KRB when a character doesn’t have it or should you use a generic characteristic?

Let’s say a player wants to use a sword to fight an enemy in Call of Cthulhu 7e but didn’t pick that specific skill for the character, should you as a keeper make the player roll a sword skill (20%) from the Keeper Rulebook (p. 64) against a difficulty of the base 20% (with penalty?) or should the player make a general DEX role with penalty die?

Basically, should you pick a skill on character creation to be able to use it or can you use any skill with base difficulty if your character doesn’t have it?

Are there stats for a generic fish creature?

I’ve been looking everywhere for stats for generic fish stats. Fish like trout, bass, carps, and ones of the like. I don’t know if there are any already out there and I can’t seem to find any in the Monster Manual. I only have the 3 core rulebooks so I’m not sure if there are other stats out there in the many campaign books out there.

My question is: Are there monster/creature stats for a generic fish creature in 5e

Why does a generic google search produce such a specific result?

I recently made what I thought would be a very generic search on Google for

church “statement of beliefs” – Google Search

Not surprisingly it produced “About 375,000 results”.

The top entry was:

What We Believe | About – Hillsong Church

which seems an as arbitrary top result as any. The following entries seemed just as random, and everything was just as I would expect it to be.

But at the bottom of Google’s search results page was: Hillsong writers

and this list:

  • hillsong church beliefs on homosexuality
  • hillsong church lgbt beliefs
  • church statement of faith examples
  • hillsong church pastor
  • hillsong church controversy
  • is hillsong catholic
  • statement of beliefs definition
  • australian church

where surprisingly, five out of eight related searches contain the word “hillsong”. (Actually 6, Hillsong is an Australian church.)

church statement of faith examples” and “statement of beliefs definition” are what I would expect as searches that are similar to mine. But the others really don’t belong in the list at all.

So either Google is doing something wrong, or Hillsong Church is doing some incredible SEO. Not only are they in the number one position for the search, they appear in 75% of the related searches and 100% of the related images.

What is so special about this organization’s site? Baptist churches have a thousand times as many members, and the Catholic church more than ten times that.

(Note that this is the first time I’ve heard of Hillsong; I have no connection with their organization or any of its members. This question isn’t about them, but about why a Google search treated them so specially.)

Is it possible to differentiate generic and targeted infection?

Details: my USB stick got infected and probably my computer too. I suspect that the person I asked to transfer the file did it intentionally. But the problem is I don’t know what is their intention. Avast found bunch of malware, Trojan, worm. I researched a bit and came to conclusion that it’s not possible to be sure that AV got all harmful stuff and that it’s not possible to know my files are not infected so I can’t back them up.

This is a public place so I can compare with other people or go back there and plug my USB in, and compare the results with previous infection. But how do I do that or is that possible?

Also would my IT department take me seriously or they’ll think I’m nuts?