GDG Factions Manager
Framework for Unity to easily manage factions in a game.
|
This class handles all the information for the Faction System. This takes advantage of the singleton pattern to ensure that only one instance is available at any point in time. More...
Public Member Functions | |
void | FixedUpdate () |
Execute any function commands that may have been queued. This should be called on update to make sure that delayed commands are executed. Such commands include the restoration of temporary faction changes such as SetTemporaryHostile... which should return the ojects faction to normal after the duration expires. More... | |
int | RegisterFactionMember (FactionEntity targetMember) |
Registers the member with its faction. This method will try to add the faction to the faction map if it doesn't already exist. It then registers the member with the faction member's list. More... | |
int | RegisterFaction (string factionID) |
This method tries to register the faction. If the faction already exists nothing is done. More... | |
void | PrintFactionTable () |
Prints the faction table. Faction table is printed in the form Source Faction "to" Target Faction "=" Faction Value More... | |
void | PrintFactionMambers (string factionID) |
Prints the members of the specified faction. More... | |
int | GetReputation (FactionEntity oSource, FactionEntity oTarget) |
Returns an integer between 0 and 100 (inclusive) that represents how oSource feels about oTarget. More... | |
bool | GetReactionIsFriendly (FactionEntity oSource, FactionEntity oTarget) |
Returns true if the source is friendly towards the target. More... | |
bool | GetReactionIsNeutral (FactionEntity oSource, FactionEntity oTarget) |
Returns true if the source considers the target a Neutral More... | |
bool | GetReactionIsHostile (FactionEntity oSource, FactionEntity oTarget) |
Returns true if the source is Hostile towards target. More... | |
int | GetReputation (string sTargetID, string sSourceID) |
This answers the quastion: How do members from sSourceFactionID faction feel about sTargetFactionID? More... | |
void | AdjustReputation (FactionEntity oTarget, FactionEntity oSourceFactionMember, int nAdjustment) |
Adjust how oSourceFactionMember's faction feels about oTarget by the amount specified in nAdjustment. More... | |
int | AdjustReputation (string sTargetFactionID, string sSourceFactionID, int nAdjustment) |
Adjusts how members of sSourceFactionID feels about sTargetFactionID. More... | |
void | SetIsTemporaryNeutral (FactionEntity oTarget, FactionEntity oSource, bool bDecays, float fDurationInSeconds) |
Make oSource temporarily neutral to oTarget using personal reputation. This will fail if oTarget and oSource are in the same faction or party as they can never be considered tempoarily anything but what the faction in general tells them to think. More... | |
void | SetIsTemporaryNeutral (string sTargetFactionID, string sSourceFactionID, bool bDecays, float fDurationInSeconds) |
Makes the member of sTargetFactionID be viewed as neutral sSourceFactionID. More... | |
void | SetIsTemporaryHostile (FactionEntity oTarget, FactionEntity oSource, bool bDecays, float fDurationInSeconds) |
Make oSource temporarily hostile to oTarget using personal reputation. This will fail if oTarget and oSource are in the same faction or party as they can never be considered tempoarily anything but what the faction in general tells them to think. More... | |
void | SetIsTemporaryHostile (string sTargetFactionID, string sSourceFactionID, bool bDecays, float fDurationInSeconds) |
Makes the member of sTargetFactionID be viewed as hostile sSourceFactionID. More... | |
void | SetIsTemporaryFriendly (FactionEntity oTarget, FactionEntity oSource, bool bDecays, float fDurationInSeconds) |
Make oSource temporarily friendly to oTarget using personal reputation. This will fail if oTarget and oSource are in the same faction or party as they can never be considered tempoarily anything but what the faction in general tells them to think. More... | |
void | SetIsTemporaryFriendly (string sTargetFactionID, string sSourceFactionID, bool bDecays, float fDurationInSeconds) |
Makes the member of sTargetFactionID be viewed as friendly sSourceFactionID. More... | |
int | NotifyFactionOfEvent (string factionID, FactionEvent fEvent) |
Notifies all members of a given faction of the event. More... | |
int | ChangeFaction (FactionEntity oDeserter, string sToFactionID) |
Changes the faction of oChange to the faction specified by sToFactionID More... | |
int | ChangeFaction (FactionEntity oDeserter, FactionEntity oToFactionMember) |
Changes the faction of oDeserter to that of oToFactionMember. More... | |
int | AdjustWorldReputation (string sTargetFaction, int nAdjustment) |
This method adjusts how everyone in the world feels about sTargetFaction. More... | |
int | AdjustWorldReputation (FactionEntity oTarget, int nAdjustment) |
Adjusts the world's view of the faction to which oTarget belongs. More... | |
double | GetAverageOfFactionAttribute (string factionID, FactionCountableAttributeVisitor visitor) |
This method returns the average value of a given attribute accross the entire faction. More... | |
double | GetAverageOfFactionAttribute (FactionEntity member, FactionCountableAttributeVisitor visitor) |
This method returns the average value of a given attribute accross the entire faction that member belongs to. More... | |
FactionEntity | GetFactionMemberWithMinAttribute (string factionID, FactionCountableAttributeVisitor visitor) |
This method returns the member of the faction with the minimum in the desired attriute. The attribute to be explored is handled by the visitor reference. More... | |
FactionEntity | GetFactionMemberWithMinAttribute (FactionEntity member, FactionCountableAttributeVisitor visitor) |
This method returns the member of the faction with the minimum in the desired attriute. The attribute to be explored is handled by the visitor reference. More... | |
FactionEntity | GetFactionMemberWithMaxAttribute (string factionID, FactionCountableAttributeVisitor visitor) |
This method returns the member of the faction with the maximum in the desired attriute. The attribute to be explored is handled by the visitor reference. More... | |
FactionEntity | GetFactionMemberWithMaxAttribute (FactionEntity member, FactionCountableAttributeVisitor visitor) |
This method returns the member of the faction with the maximum in the desired attriute. The attribute to be explored is handled by the visitor reference. More... | |
ArrayList | GetMembersInFaction (string factionID) |
Returns the members of the faction specified by the faction ID. It returns null, if no faction is found. More... | |
string[] | GetFactionIDs () |
Returns all the Factions ID's registered with this manager. More... | |
void | ResetFactions () |
This method resets all the factions to the default start of all factions. That is, it makes every faction friendly to itself and neutral to everyone else. More... | |
Static Public Member Functions | |
static FactionManager | GetInstance () |
This class handles all the information for the Faction System. This takes advantage of the singleton pattern to ensure that only one instance is available at any point in time.
void FactionManager.AdjustReputation | ( | FactionEntity | oTarget, |
FactionEntity | oSourceFactionMember, | ||
int | nAdjustment | ||
) |
Adjust how oSourceFactionMember's faction feels about oTarget by the amount specified in nAdjustment.
oTarget | The creature who will be viewed differently by an entire faction. |
oSourceFactionMember | The member of the faction that will have its opinion changed. |
nAdjustment | The amount (positive or negative) that the faction's opinion will change. |
int FactionManager.AdjustReputation | ( | string | sTargetFactionID, |
string | sSourceFactionID, | ||
int | nAdjustment | ||
) |
Adjusts how members of sSourceFactionID feels about sTargetFactionID.
sTargetFactionID | Id of the faction which will be viewed differently by the other faction. |
sSourceFaction | Id of the faction that will have its view changed. |
int FactionManager.AdjustWorldReputation | ( | string | sTargetFaction, |
int | nAdjustment | ||
) |
This method adjusts how everyone in the world feels about sTargetFaction.
sTargetFaction | The ID of the faction that will be viewed differently by the world. |
nAdjustment | Number to adjust the faction by. Prefferably 0<= nAdjustment <=100. |
int FactionManager.AdjustWorldReputation | ( | FactionEntity | oTarget, |
int | nAdjustment | ||
) |
Adjusts the world's view of the faction to which oTarget belongs.
oTarget | Entity whose faction will be viewed differently by the everyone in world. |
nAdjustment | Amount to adjust the reputation by 0<= nAdjustment <= 100 |
int FactionManager.ChangeFaction | ( | FactionEntity | oDeserter, |
string | sToFactionID | ||
) |
Changes the faction of oChange to the faction specified by sToFactionID
oDeserter | Entity whom will change factions. |
sToFactionID | Id of the faction that oDeserter will change to. |
int FactionManager.ChangeFaction | ( | FactionEntity | oDeserter, |
FactionEntity | oToFactionMember | ||
) |
Changes the faction of oDeserter to that of oToFactionMember.
oDeserter | Entity to change the faction of. |
oToFactionMember | Member of the faction that oDeserter will be converted to. |
void FactionManager.FixedUpdate | ( | ) |
Execute any function commands that may have been queued. This should be called on update to make sure that delayed commands are executed. Such commands include the restoration of temporary faction changes such as SetTemporaryHostile... which should return the ojects faction to normal after the duration expires.
double FactionManager.GetAverageOfFactionAttribute | ( | string | factionID, |
FactionCountableAttributeVisitor | visitor | ||
) |
This method returns the average value of a given attribute accross the entire faction.
Example: if we wanted to get the average gold of a faction, we need to create a visitor that returns the amount of gold from a given entity and pass it as a reference here.
factionID | Id of the faction to explore. |
visitor | Vistor instance. This is in charge of returning the value for the attribute we want to explore. |
double FactionManager.GetAverageOfFactionAttribute | ( | FactionEntity | member, |
FactionCountableAttributeVisitor | visitor | ||
) |
This method returns the average value of a given attribute accross the entire faction that member belongs to.
Example: if we wanted to get the average gold of a faction, we need to create a visitor that returns the amount of gold from a given entity and pass it as a reference here.
member | Member of the faction for which we want to calculate the average. |
visitor | Vistor instance. This is in charge of returning the value for the attribute we want to explore. |
string [] FactionManager.GetFactionIDs | ( | ) |
Returns all the Factions ID's registered with this manager.
FactionEntity FactionManager.GetFactionMemberWithMaxAttribute | ( | string | factionID, |
FactionCountableAttributeVisitor | visitor | ||
) |
This method returns the member of the faction with the maximum in the desired attriute. The attribute to be explored is handled by the visitor reference.
factionID | Id of the faction to explore. |
visitor | Reference to the visitor that will handle the retrieval of the value. |
FactionEntity FactionManager.GetFactionMemberWithMaxAttribute | ( | FactionEntity | member, |
FactionCountableAttributeVisitor | visitor | ||
) |
This method returns the member of the faction with the maximum in the desired attriute. The attribute to be explored is handled by the visitor reference.
member | Member of the faction to explore. |
visitor | Reference to the visitor that will handle the retrieval of the value. |
FactionEntity FactionManager.GetFactionMemberWithMinAttribute | ( | string | factionID, |
FactionCountableAttributeVisitor | visitor | ||
) |
This method returns the member of the faction with the minimum in the desired attriute. The attribute to be explored is handled by the visitor reference.
factionID | Id of the faction to explore. |
visitor | Reference to the visitor that will handle the retrieval of the value. |
FactionEntity FactionManager.GetFactionMemberWithMinAttribute | ( | FactionEntity | member, |
FactionCountableAttributeVisitor | visitor | ||
) |
This method returns the member of the faction with the minimum in the desired attriute. The attribute to be explored is handled by the visitor reference.
member | Member of the faction to explore. |
visitor | Reference to the visitor that will handle the retrieval of the value. |
ArrayList FactionManager.GetMembersInFaction | ( | string | factionID | ) |
Returns the members of the faction specified by the faction ID. It returns null, if no faction is found.
factionID | Faction I. |
bool FactionManager.GetReactionIsFriendly | ( | FactionEntity | oSource, |
FactionEntity | oTarget | ||
) |
Returns true if the source is friendly towards the target.
oSource | Source entity |
oTarget | Target entity |
bool FactionManager.GetReactionIsHostile | ( | FactionEntity | oSource, |
FactionEntity | oTarget | ||
) |
Returns true if the source is Hostile towards target.
oSource | Source entity |
oTarget | Target entity |
bool FactionManager.GetReactionIsNeutral | ( | FactionEntity | oSource, |
FactionEntity | oTarget | ||
) |
Returns true if the source considers the target a Neutral
oSource | Source entity |
oTarget | Target entity |
int FactionManager.GetReputation | ( | FactionEntity | oSource, |
FactionEntity | oTarget | ||
) |
Returns an integer between 0 and 100 (inclusive) that represents how oSource feels about oTarget.
oSource | Source entity. |
oTarget | Target entity. |
int FactionManager.GetReputation | ( | string | sTargetID, |
string | sSourceID | ||
) |
This answers the quastion: How do members from sSourceFactionID faction feel about sTargetFactionID?
sTargetFactionID | Id of the faction for which sSourceFactionID feels about. |
sSourceFactionID | Id of the faction for which is opinion is wanted. |
int FactionManager.NotifyFactionOfEvent | ( | string | factionID, |
FactionEvent | fEvent | ||
) |
Notifies all members of a given faction of the event.
factionID | Id of the faction to send the event to. |
fEvent | Faction Event to send out. |
void FactionManager.PrintFactionMambers | ( | string | factionID | ) |
Prints the members of the specified faction.
factionID | Faction I. |
void FactionManager.PrintFactionTable | ( | ) |
Prints the faction table. Faction table is printed in the form Source Faction "to" Target Faction "=" Faction Value
int FactionManager.RegisterFaction | ( | string | factionID | ) |
This method tries to register the faction. If the faction already exists nothing is done.
If the faction does not exist it is added and the faction's reaction to every other reaction is also mapped. By default factions are mapped Friendly to itself and Neutral to every other faction.
factionID | Id of the faction to register. |
int FactionManager.RegisterFactionMember | ( | FactionEntity | targetMember | ) |
Registers the member with its faction. This method will try to add the faction to the faction map if it doesn't already exist. It then registers the member with the faction member's list.
targetMember | Target member. |
void FactionManager.ResetFactions | ( | ) |
This method resets all the factions to the default start of all factions. That is, it makes every faction friendly to itself and neutral to everyone else.
void FactionManager.SetIsTemporaryFriendly | ( | FactionEntity | oTarget, |
FactionEntity | oSource, | ||
bool | bDecays, | ||
float | fDurationInSeconds | ||
) |
Make oSource temporarily friendly to oTarget using personal reputation. This will fail if oTarget and oSource are in the same faction or party as they can never be considered tempoarily anything but what the faction in general tells them to think.
oTarget | The object whose reputation will be altered. |
oSource | The creature whose opinion will change. |
bDecays | If this is TRUE, the friendlyness decays over fDurationInSeconds; otherwise it is indefinite. |
fDurationInSeconds | This is only used if bDecays is TRUE, it is how long the neutrality lasts. |
void FactionManager.SetIsTemporaryFriendly | ( | string | sTargetFactionID, |
string | sSourceFactionID, | ||
bool | bDecays, | ||
float | fDurationInSeconds | ||
) |
Makes the member of sTargetFactionID be viewed as friendly sSourceFactionID.
sTargetFactionID | The id of the faction whose reputation will be altered. |
sSourceFactionID | The id of the faction whose opinion will change. |
bDecays | If this is TRUE, the neutrality decays over fDurationInSeconds; otherwise it is indefinite. |
fDurationInSeconds | This is only used if bDecays is TRUE, it is how long the neutrality lasts. |
void FactionManager.SetIsTemporaryHostile | ( | FactionEntity | oTarget, |
FactionEntity | oSource, | ||
bool | bDecays, | ||
float | fDurationInSeconds | ||
) |
Make oSource temporarily hostile to oTarget using personal reputation. This will fail if oTarget and oSource are in the same faction or party as they can never be considered tempoarily anything but what the faction in general tells them to think.
oTarget | The object whose reputation will be altered. |
oSource | The creature whose opinion will change. |
bDecays | If this is TRUE, the hostility decays over fDurationInSeconds; otherwise it is indefinite. |
fDurationInSeconds | This is only used if bDecays is TRUE, it is how long the neutrality lasts. |
void FactionManager.SetIsTemporaryHostile | ( | string | sTargetFactionID, |
string | sSourceFactionID, | ||
bool | bDecays, | ||
float | fDurationInSeconds | ||
) |
Makes the member of sTargetFactionID be viewed as hostile sSourceFactionID.
sTargetFactionID | The id of the faction whose reputation will be altered. |
sSourceFactionID | The id of the faction whose opinion will change. |
bDecays | If this is TRUE, the neutrality decays over fDurationInSeconds; otherwise it is indefinite. |
fDurationInSeconds | This is only used if bDecays is TRUE, it is how long the neutrality lasts. |
void FactionManager.SetIsTemporaryNeutral | ( | FactionEntity | oTarget, |
FactionEntity | oSource, | ||
bool | bDecays, | ||
float | fDurationInSeconds | ||
) |
Make oSource temporarily neutral to oTarget using personal reputation. This will fail if oTarget and oSource are in the same faction or party as they can never be considered tempoarily anything but what the faction in general tells them to think.
oTarget | The object whose reputation will be altered. |
oSource | The creature whose opinion will change. |
bDecays | If this is TRUE, the neutrality decays over fDurationInSeconds; otherwise it is indefinite. |
fDurationInSeconds | This is only used if bDecays is TRUE, it is how long the neutrality lasts. |
void FactionManager.SetIsTemporaryNeutral | ( | string | sTargetFactionID, |
string | sSourceFactionID, | ||
bool | bDecays, | ||
float | fDurationInSeconds | ||
) |
Makes the member of sTargetFactionID be viewed as neutral sSourceFactionID.
sTargetFactionID | The id of the faction whose reputation will be altered. |
sSourceFactionID | The id of the faction whose opinion will change. |
bDecays | If this is TRUE, the neutrality decays over fDurationInSeconds; otherwise it is indefinite. |
fDurationInSeconds | This is only used if bDecays is TRUE, it is how long the neutrality lasts. |