Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 20th Mar 2018 at 11:52 AM
Default C# - issues with enums ?
Hi,

in my mod, I'm creating both new hidden traits and new occult Life States.
In vanilla, they are stored in enums : TraitNames for the Traits, and OccultTypes and OccultTypesAll for the Occults.
In my code, I use
Code:
simDes.TraitManager.RemoveElement((TraitNames)0x7A52783F65933B7E);
(which works) several times, 0x7A52783F65933B7E being my thait's guid, or
Code:
base.Actor.SimDescription.OccultManager.AddOccultType((OccultTypes)0x20000, true, false, false, new OccultArmiseDemon());
(which works too), 0x20000 being my new Occult's ID.
So, to avoid any typing errors, and to make it easier if I had to change the said guid, I wanted to do this
Code:
[Tunable]
public static TraitNames Armise_DemonTraitNames = (TraitNames)0x7A52783F65933B7E;
[Tunable]
public static OccultTypes ArmiseDemon = (OccultTypes)0x20000;

The issue is, it doesn't work . The following test
Code:
(Armise_DemonTraitNames == (TraitNames)0x7A52783F65933B7E)
returns False !

How is it even possible ? How can ArmiseDemon be equal to anything else than (TraitNames)0x7A52783F65933B7E ? Any idea on how to successfully add stuff to an existing enum ?
Advertisement
Scholar
#2 Old 21st Mar 2018 at 8:34 PM
I am not too sure but have you tried (TraitNames)(0x7A52783F65933B7E) instead of (TraitNames)0x7A52783F65933B7E ? That's what I do for custom moodlets. I haven't worked with custom traits so far.
Virtual gardener
staff: administrator
#3 Old 21st Mar 2018 at 10:16 PM
First thing I'd do first is delete the Tunable for the traitsNames mention. That could use some issues

Then, make sure to use Public const instead. Not static! Hope that helps! Else it should work
Test Subject
Original Poster
#4 Old 21st Mar 2018 at 11:32 PM
skydome yup, I tried.
Lyralei what does Tunable even mean ? And I can't remove the static tag, I get "An object reference is required for the not static property, method or field".
(It worked btw thanks a lot)
Inventor
#5 Old 22nd Mar 2018 at 12:44 AM
You could try to remove the "[Tunable]"
Scholar
#6 Old 22nd Mar 2018 at 4:11 AM
Quote: Originally posted by Armise
skydome yup, I tried.
Lyralei what does Tunable even mean ? And I can't remove the static tag, I get "An object reference is required for the not static property, method or field".
(It worked btw thanks a lot)

I think tunable is when you want to make it XML tunable. I may be wrong though.
Space Pony
#7 Old 23rd Mar 2018 at 3:46 PM
Quote: Originally posted by Armise
skydome yup, I tried.
Lyralei what does Tunable even mean ? And I can't remove the static tag, I get "An object reference is required for the not static property, method or field".
(It worked btw thanks a lot)


Static simply seaking menas that this variable/method/class is global so it cant be instanced.

if you remove the static keyword you need to tell the compiler which instance to reference.

eg.

public class myclass
{
public traitnames mTraitnames;
}


myclass refclass = new myclass(); // instance the class
refclass.mTraitnames = Yourtraitname; // assign a trait

but tbh it can remain static there should be no problem with it...
Virtual gardener
staff: administrator
#8 Old 25th Mar 2018 at 7:01 PM
Quote: Originally posted by skydome
I think tunable is when you want to make it XML tunable. I may be wrong though.

Skydome is right! if you look at EA's tunables and compare the XML files in the gameplay.package, You'll see that they're equal to each other I'd recommend using those in your mod so people can modify the durage of something! (which they usually do *points at tuning mods*)
Back to top