Initial Commit

This commit is contained in:
Lachlan Leone
2024-01-20 20:00:35 +11:00
commit d78ae93c97
70 changed files with 3212 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
using Kitchen;
using KitchenMods;
using Pets.Components.Creation;
using Unity.Collections;
using Unity.Entities;
namespace Pets.Systems
{
public class EnsureCorrectPet : GameSystemBase, IModSystem
{
private EntityQuery _players;
protected override void Initialise()
{
base.Initialise();
_players = GetEntityQuery(typeof(CPlayer), typeof(CLinkedPet), typeof(CRequiresPet));
}
protected override void OnUpdate()
{
NativeArray<Entity> players = _players.ToEntityArray(Allocator.Temp);
for (int i = 0; i < players.Length; i++)
{
Entity player = players[i];
if (!Require(player, out CLinkedPet cLinkedPet)) continue;
if (!Require(player, out CRequiresPet cRequiresPet)) continue;
if (cLinkedPet.PetType != cRequiresPet.PetType && cLinkedPet.PetEntity != Entity.Null)
{
EntityManager.DestroyEntity(cLinkedPet.PetEntity);
EntityManager.RemoveComponent<CLinkedPet>(player);
}
}
players.Dispose();
}
}
}