forked from WhiteFang5/VMods
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a VModCharacter and refactored code to make use of it; [PvPLead…
…erboard] Added the option to get the pvpstats of another player; Fixed an issue with character retrieval by character name
- Loading branch information
1 parent
d6f0587
commit 7efd9f7
Showing
11 changed files
with
135 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using ProjectM; | ||
using ProjectM.Network; | ||
using Unity.Collections; | ||
using Unity.Entities; | ||
|
||
namespace VMods.Shared | ||
{ | ||
public readonly struct VModCharacter | ||
{ | ||
#region Variables | ||
|
||
public readonly User User; | ||
public readonly PlayerCharacter Character; | ||
public readonly FromCharacter FromCharacter; | ||
|
||
#endregion | ||
|
||
#region Lifecycle | ||
|
||
public VModCharacter(User user, PlayerCharacter character) => (User, Character, FromCharacter) = (user, character, FromCharacter = new FromCharacter() | ||
{ | ||
User = character.UserEntity._Entity, | ||
Character = user.LocalCharacter._Entity, | ||
}); | ||
|
||
public VModCharacter(Entity userEntity, Entity charEntity, EntityManager? entityManager = null) | ||
{ | ||
entityManager ??= Utils.CurrentWorld.EntityManager; | ||
User = entityManager.Value.GetComponentData<User>(userEntity); | ||
Character = entityManager.Value.GetComponentData<PlayerCharacter>(charEntity); | ||
FromCharacter = new FromCharacter() | ||
{ | ||
User = Character.UserEntity._Entity, | ||
Character = User.LocalCharacter._Entity, | ||
}; | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Methods | ||
|
||
public static VModCharacter? GetVModCharacter(string charactername, EntityManager? entityManager = null) | ||
{ | ||
entityManager ??= Utils.CurrentWorld.EntityManager; | ||
var users = entityManager.Value.CreateEntityQuery(ComponentType.ReadOnly<User>()).ToEntityArray(Allocator.Temp); | ||
foreach(var userEntity in users) | ||
{ | ||
var userData = entityManager.Value.GetComponentData<User>(userEntity); | ||
var playerCharacter = entityManager.Value.GetComponentData<PlayerCharacter>(userData.LocalCharacter._Entity); | ||
if(userData.CharacterName.ToString() == charactername) | ||
{ | ||
return new VModCharacter(userData, playerCharacter); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public void ApplyBuff(PrefabGUID buffGUID) | ||
{ | ||
Utils.ApplyBuff(FromCharacter, buffGUID); | ||
} | ||
|
||
public void RemoveBuff(PrefabGUID buffGUID) | ||
{ | ||
Utils.RemoveBuff(FromCharacter.Character, buffGUID); | ||
} | ||
|
||
public bool HasBuff(PrefabGUID buffGUID, EntityManager? entityManager = null) | ||
{ | ||
entityManager ??= Utils.CurrentWorld.EntityManager; | ||
return BuffUtility.HasBuff(entityManager.Value, FromCharacter.Character, buffGUID); | ||
} | ||
|
||
#endregion | ||
} | ||
} |