BannerlordCE / CEEvents

Captivity Events Source Code
https://www.nexusmods.com/mountandblade2bannerlord/mods/1226
MIT License
4 stars 6 forks source link

New Efficient and Readable Coding Structure #7

Closed TheBadListener closed 4 years ago

TheBadListener commented 4 years ago

Further testing is needed for now, will be able to do more testing tomorrow.

LogRaam commented 4 years ago

IsStringNoneOrEmpty() is a custom method from TaleWorlds. string.IsNullOrEmpty() on the other hand is directly from the .Net. If I choose between them, probably my choice goes to IsStringNoneOrEmpty().

TheBadListener commented 4 years ago

IsStringNoneOrEmpty() is a custom method from TaleWorlds. string.IsNullOrEmpty() on the other hand is directly from the .Net. If I choose between them, probably my choice goes to IsStringNoneOrEmpty().

Sounds good, we will go through that later then.

LogRaam commented 4 years ago

Ok, here is the diference between IsStringNullOrEmpty($) and $.IsStringNoneOrEmpty() .. The first one is a method so it can evaluate if an string is empty or if its pointer ref is null. The second one is an extension method and the object it extends cannot be null.

TheBadListener commented 4 years ago

image

image

Some ProceedToSharedCallBacks are not actually shared, and refer to different things ConsequenceSlavery, ConsequenceChangeHealth, ConsequenceLeaveSpouse, ConsequenceProstitute, ConsequenceRenown, ConsequenceChangeTrait, ConsequenceChangeSkill, ConsequenceGold refer to captives, when a captor. Seems like ProceedToSharedCallBacks is only used in captive and random events.

ChangeMorale should refer to the main party when random or captor.

Will double check when this is fixed. Will let you fix this as you might be refactoring it further, and I might put it in the wrong place lol.

LogRaam commented 4 years ago

Ok from what I can see, random and captor have the same code, but captive have a different PartyBase.

From that point, what I can do is something like that:

image

There is a method that check if the Player is captive and select the proper party automatically. And I added another one where you can specify manually the PartyBase value.

I'll push that modif for testing. If it doesn't works, I'll have to set specific methods for each case.