Madboy James
Member
Hi ,
in the DamageData class, I see there is a "UserData" property. Firstly, I want to say I really like how this is all engineered to be user extendable without needing to copy all the scripts or modifying the source. Second... could someone recommend to me how to properly use the UserData field? I want to have a "UseColliderDamageMultiplier" boolean so certain weapons with a higher weakpoint damage multiplier can override the collider damage multiplier.
Obviously I won't be able to change the type of UserData to one of my own classes, as they exist outside of the Opsive namespace and assembly... nor can I have the DamageData instantiate a new class of my own and assign it to UserData on construction due to the same constraint.
So, what to do?
Currently, I have added a method directly to DamageData (which will be erased if I pull any updates for UCC). It is as follows
which can be called by my other user defined scripts.
I was unable to find documentation on the proper usage of UserData in DamageData, and would like input on my solution/ pointed in the direction of some documentation if I missed it.
Pinging @Sangemdoko as instructed.
in the DamageData class, I see there is a "UserData" property. Firstly, I want to say I really like how this is all engineered to be user extendable without needing to copy all the scripts or modifying the source. Second... could someone recommend to me how to properly use the UserData field? I want to have a "UseColliderDamageMultiplier" boolean so certain weapons with a higher weakpoint damage multiplier can override the collider damage multiplier.
Obviously I won't be able to change the type of UserData to one of my own classes, as they exist outside of the Opsive namespace and assembly... nor can I have the DamageData instantiate a new class of my own and assign it to UserData on construction due to the same constraint.
So, what to do?
Currently, I have added a method directly to DamageData (which will be erased if I pull any updates for UCC). It is as follows
C#:
public virtual T GetUserData<T>() where T : class, new()
{
T returnVal = UserData as T;
if (returnVal == null)
{
returnVal = new T();
UserData = returnVal;
}
return returnVal;
}
which can be called by my other user defined scripts.
C#:
damageData.GetUserData<MyExtraDamageDataFieldsClass>().IsThisFireDamageOrWhatever;
I was unable to find documentation on the proper usage of UserData in DamageData, and would like input on my solution/ pointed in the direction of some documentation if I missed it.
Pinging @Sangemdoko as instructed.