Initial Commit
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
using Easter2025.Components;
|
||||
using Easter2025.Utilies;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems.Achievements
|
||||
{
|
||||
public class Serve3Eggs : RestaurantSystem, IModSystem
|
||||
{
|
||||
private EntityQuery _WaitingForItems;
|
||||
private EntityQuery _Trackers;
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_WaitingForItems = GetEntityQuery(new QueryHelper().All(typeof(CWaitingForItem)));
|
||||
_Trackers = GetEntityQuery(new QueryHelper().All(typeof(CServeThreeCoursesTracker)).None(typeof(CCompletedAchievementEntity)));
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
using (NativeArray<Entity> WaitingForItems = _WaitingForItems.ToEntityArray(Allocator.Temp))
|
||||
{
|
||||
foreach (Entity WaitingForItem in WaitingForItems)
|
||||
{
|
||||
if (!RequireBuffer(WaitingForItem, out DynamicBuffer<CWaitingForItem> cWaitingForItemBuffer)) continue;
|
||||
if (!RequireBuffer(WaitingForItem, out DynamicBuffer<CGroupMember> cGroupMemberBuffer)) continue;
|
||||
foreach (var cWaitingForItem in cWaitingForItemBuffer)
|
||||
{
|
||||
if (cWaitingForItem.Satisfied)
|
||||
{
|
||||
CGroupMember member = cGroupMemberBuffer[cWaitingForItem.MemberIndex];
|
||||
if (cWaitingForItem.ItemID == GDOReferences.PinkPlasticEgg.ID || cWaitingForItem.ItemID == GDOReferences.YellowPlasticEgg.ID || cWaitingForItem.ItemID == GDOReferences.OrangePlasticEgg.ID)
|
||||
{
|
||||
SetStarterComplete(member.Customer);
|
||||
}
|
||||
else if (cWaitingForItem.ItemID == GDOReferences.RedEgg.ID || cWaitingForItem.ItemID == GDOReferences.GreenEgg.ID || cWaitingForItem.ItemID == GDOReferences.BlueEgg.ID)
|
||||
{
|
||||
SetMainComplete(member.Customer);
|
||||
}
|
||||
else if (cWaitingForItem.ItemID == GDOReferences.WrappedCremeEgg.ID)
|
||||
{
|
||||
SetDessertComplete(member.Customer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (NativeArray<Entity> Trackers = _Trackers.ToEntityArray(Allocator.Temp))
|
||||
{
|
||||
foreach (Entity Tracker in Trackers)
|
||||
{
|
||||
if (Require(Tracker, out CServeThreeCoursesTracker cServeThreeCoursesTracker))
|
||||
{
|
||||
if (cServeThreeCoursesTracker.HasHadEggStarter && cServeThreeCoursesTracker.HasHadEggMain && cServeThreeCoursesTracker.HasHadEggDessert)
|
||||
{
|
||||
Set<CCompletedAchievementEntity>(Tracker);
|
||||
Mod.achievementsManager.UnlockAchievement(Mod.ACHIEVEMENT_SERVE_THREE_COURSE_EGGS);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetStarterComplete(Entity customer)
|
||||
{
|
||||
EnsureTracker(customer);
|
||||
if (Require(customer, out CServeThreeCoursesTracker cServeThreeCoursesTracker))
|
||||
{
|
||||
cServeThreeCoursesTracker.HasHadEggStarter = true;
|
||||
Set(customer, cServeThreeCoursesTracker);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMainComplete(Entity customer)
|
||||
{
|
||||
EnsureTracker(customer);
|
||||
if (Require(customer, out CServeThreeCoursesTracker cServeThreeCoursesTracker))
|
||||
{
|
||||
cServeThreeCoursesTracker.HasHadEggMain = true;
|
||||
Set(customer, cServeThreeCoursesTracker);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDessertComplete(Entity customer)
|
||||
{
|
||||
EnsureTracker(customer);
|
||||
if (Require(customer, out CServeThreeCoursesTracker cServeThreeCoursesTracker))
|
||||
{
|
||||
cServeThreeCoursesTracker.HasHadEggDessert = true;
|
||||
Set(customer, cServeThreeCoursesTracker);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureTracker(Entity customer)
|
||||
{
|
||||
if (!Has<CServeThreeCoursesTracker>(customer))
|
||||
{
|
||||
Set<CServeThreeCoursesTracker>(customer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using Easter2025.Components;
|
||||
using Easter2025.Utilies;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems.Achievements
|
||||
{
|
||||
public class TriggerBunnyReward : DaySystem, IModSystem
|
||||
{
|
||||
private readonly int REWARD_AMOUNT = 250;
|
||||
|
||||
private EntityQuery _OrangeOrbs;
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_OrangeOrbs = GetEntityQuery(new QueryHelper().All(typeof(CHasOrangeOrbs)));
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (HasSingleton<SHasTriggeredBunnies>()) return;
|
||||
if (_OrangeOrbs.IsEmpty) return;
|
||||
|
||||
if (HasSingleton<CSetting>())
|
||||
{
|
||||
CSetting setting = GetSingleton<CSetting>();
|
||||
if (setting.RestaurantSetting != GDOReferences.Easter2025Setting.ID && setting.RestaurantSetting != GDOReferences.Easter2025GardenSetting.ID) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SpawnBunny(1, Mod.RED_BUNNY_VIEW);
|
||||
SpawnBunny(3, Mod.GREEN_BUNNY_VIEW);
|
||||
SpawnBunny(5 , Mod.BLUE_BUNNY_VIEW);
|
||||
|
||||
Entity e = EntityManager.CreateEntity(typeof(CMoneyTrackEvent));
|
||||
EntityManager.SetComponentData(e, new CMoneyTrackEvent
|
||||
{
|
||||
Identifier = GDOReferences.GenerousBunnies.ID,
|
||||
Amount = REWARD_AMOUNT
|
||||
});
|
||||
|
||||
if (HasSingleton<SMoney>())
|
||||
{
|
||||
SMoney money = GetSingleton<SMoney>();
|
||||
money.Amount += REWARD_AMOUNT;
|
||||
SetSingleton(money);
|
||||
}
|
||||
Mod.achievementsManager.UnlockAchievement(Mod.ACHIEVEMENT_TRIGGER_BUNNIES);
|
||||
|
||||
EntityManager.CreateEntity(typeof(SHasTriggeredBunnies));
|
||||
}
|
||||
|
||||
private void SpawnBunny(int position, ViewType viewType)
|
||||
{
|
||||
Entity entity = EntityManager.CreateEntity(typeof(CPosition), typeof(CRequiresView), typeof(CEventBunny));
|
||||
Set(entity, new CPosition(-0.5f, 0, position));
|
||||
Set(entity, new CRequiresView
|
||||
{
|
||||
Type = viewType,
|
||||
ViewMode = ViewMode.World
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using System.Collections.Generic;
|
||||
using Easter2025.Components;
|
||||
using Kitchen;
|
||||
using Kitchen.Layouts;
|
||||
using KitchenData;
|
||||
using KitchenMods;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class BunniesRoam : GameSystemBase, IModSystem
|
||||
{
|
||||
private EntityQuery _Bunnies;
|
||||
private NavMeshPath Path = new NavMeshPath();
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_Bunnies = GetEntityQuery(typeof(CBunny));
|
||||
}
|
||||
|
||||
private float range = 5f;
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
List<Vector3> list = GetPostTiles(true);
|
||||
using (NativeArray<Entity> Bunnies = _Bunnies.ToEntityArray(Allocator.Temp))
|
||||
{
|
||||
foreach (Entity Bunny in Bunnies)
|
||||
{
|
||||
if (Require(Bunny, out CPosition cPosition))
|
||||
{
|
||||
if (!Has<CMoveToLocation>(Bunny))
|
||||
{
|
||||
int num = 0;
|
||||
Set(Bunny, new CMoveToLocation
|
||||
{
|
||||
Location = FindMovementLocation(cPosition),
|
||||
StoppingDistance = 0.8f
|
||||
});
|
||||
}
|
||||
|
||||
if (Require(Bunny, out CMoveToLocation cMoveToLocation))
|
||||
{
|
||||
if (Random.value <= 0.1f * Time.DeltaTime || Input.GetKeyDown(KeyCode.L))
|
||||
{
|
||||
if (Vector3.Distance(cMoveToLocation.Location, cPosition) < 1f)
|
||||
{
|
||||
cMoveToLocation.Location = FindMovementLocation(cPosition);
|
||||
|
||||
Set(Bunny, cMoveToLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 FindMovementLocation(Vector3 startingPosition)
|
||||
{
|
||||
for (var i = 0; i < 50; i++)
|
||||
{
|
||||
Vector3 pos = startingPosition + new Vector3(Random.Range(-range, range), 0, Random.Range(-range, range));
|
||||
if (TileManager.GetOccupant(pos) != default)
|
||||
{
|
||||
if (TileManager.GetTile(startingPosition).RoomID == TileManager.GetTile(pos).RoomID)
|
||||
{
|
||||
NavMesh.CalculatePath(startingPosition, pos, NavMesh.AllAreas, Path);
|
||||
if (Path.status == NavMeshPathStatus.PathComplete)
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return startingPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Easter2025.Components;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class CompletedBushSystem : GameSystemBase, IModSystem
|
||||
{
|
||||
private EntityQuery _eggBushes;
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_eggBushes = GetEntityQuery(typeof(CItemHolder), typeof(CEggBush), typeof(CCanHideItem));
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
using NativeArray<Entity> eggBushes = _eggBushes.ToEntityArray(Allocator.Temp);
|
||||
foreach (Entity eggBush in eggBushes)
|
||||
{
|
||||
if (Require(eggBush, out CCanHideItem cCanHideItem) && Require(eggBush, out CTakesDuration cTakesDuration))
|
||||
{
|
||||
if (!cTakesDuration.Active) continue;
|
||||
if (!(cTakesDuration.Remaining <= 0)) continue;
|
||||
if (cCanHideItem.HiddenItem == 0) continue;
|
||||
|
||||
Entity createItemRequest = EntityManager.CreateEntity(typeof(CCreateItem));
|
||||
EntityManager.SetComponentData(createItemRequest, new CCreateItem
|
||||
{
|
||||
ID = cCanHideItem.HiddenItem,
|
||||
Holder = eggBush
|
||||
});
|
||||
cCanHideItem.HiddenItem = 0;
|
||||
EntityManager.SetComponentData(eggBush, cCanHideItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kitchen;
|
||||
using KitchenLib.UI;
|
||||
using KitchenMods;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class ConflictWarning : FranchiseFirstFrameSystem, IModSystem
|
||||
{
|
||||
private EntityQuery _ConflictWarningSingleton;
|
||||
private List<ulong> _ConflictingMods = new List<ulong>
|
||||
{
|
||||
2957324159,
|
||||
3210372194
|
||||
};
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_ConflictWarningSingleton = GetEntityQuery(typeof(SConflictWarning));
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (!_ConflictWarningSingleton.IsEmpty) return;
|
||||
|
||||
List<string> ConflictWarningList = (from mod in ModPreload.Mods where _ConflictingMods.Contains(mod.ID) select mod.Name).ToList();
|
||||
|
||||
if (ConflictWarningList.Count > 0)
|
||||
{
|
||||
string conflictList = "";
|
||||
foreach (string conflictWarning in ConflictWarningList)
|
||||
{
|
||||
conflictList += " - " + conflictWarning + "\n";
|
||||
}
|
||||
|
||||
GenericPopupManager.CreatePopup(
|
||||
"Mod Conflict",
|
||||
$"One or more of your mods are conflicting with {Mod.MOD_NAME}\n\n{conflictList}\nContinue to close your game, or cancel to ignore this warning.",
|
||||
GenericChoiceType.AcceptOrConsentCancel,
|
||||
() => { Application.Quit();},
|
||||
null,
|
||||
TMPro.TextAlignmentOptions.Center
|
||||
);
|
||||
}
|
||||
|
||||
EntityManager.CreateEntity(typeof(SConflictWarning), typeof(CPersistThroughSceneChanges), typeof(CDoNotPersist));
|
||||
}
|
||||
|
||||
public struct SConflictWarning : IComponentData, IModComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Easter2025.Utilies;
|
||||
using Kitchen;
|
||||
using Kitchen.ShopBuilder;
|
||||
using KitchenData;
|
||||
using KitchenMods;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class DishLockedAppliances : StartOfDaySystem, IModSystem
|
||||
{
|
||||
private EntityQuery _CurrentMenuItems;
|
||||
private EntityQuery _ShopBuilderOptions;
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_CurrentMenuItems = base.GetEntityQuery(typeof(CMenuItem), typeof(CAvailableIngredient));
|
||||
_ShopBuilderOptions = base.GetEntityQuery(typeof(CShopBuilderOption));
|
||||
}
|
||||
|
||||
private static Dictionary<int, List<Appliance>> Appliances = new Dictionary<int, List<Appliance>>
|
||||
{
|
||||
{
|
||||
GDOReferences.DishDyedEggs.ID, new List<Appliance>
|
||||
{
|
||||
GDOReferences.GrassBunny,
|
||||
GDOReferences.MountedCarrots,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private readonly Dictionary<int, Entity> BuilderOptions = new Dictionary<int, Entity>();
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
BuilderOptions.Clear();
|
||||
foreach (Appliance appliance in Appliances.Keys.SelectMany(id => Appliances[id]))
|
||||
{
|
||||
appliance.IsPurchasable = false;
|
||||
}
|
||||
|
||||
using (NativeArray<Entity> CurrentMenuItems = _CurrentMenuItems.ToEntityArray(Allocator.Temp))
|
||||
{
|
||||
using (NativeArray<Entity> ShopBuilderOptions = _ShopBuilderOptions.ToEntityArray(Allocator.Temp))
|
||||
{
|
||||
foreach (Entity ShopBuilderOption in ShopBuilderOptions)
|
||||
{
|
||||
if (!Require(ShopBuilderOption, out CShopBuilderOption cShopBuilderOption)) continue;
|
||||
if (BuilderOptions.ContainsKey(cShopBuilderOption.Appliance)) continue;
|
||||
BuilderOptions.Add(cShopBuilderOption.Appliance, ShopBuilderOption);
|
||||
}
|
||||
|
||||
foreach (Appliance appliance in Appliances.Keys.SelectMany(id => Appliances[id]))
|
||||
{
|
||||
if (!BuilderOptions.ContainsKey(appliance.ID)) continue;
|
||||
EntityManager.DestroyEntity(BuilderOptions[appliance.ID]);
|
||||
BuilderOptions.Remove(appliance.ID);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Entity CurrentMenuItem in CurrentMenuItems)
|
||||
{
|
||||
if (!Require(CurrentMenuItem, out CMenuItem cMenuItem)) continue;
|
||||
if (!Appliances.ContainsKey(cMenuItem.SourceDish)) continue;
|
||||
foreach (Appliance appliance in Appliances[cMenuItem.SourceDish])
|
||||
{
|
||||
AddOption(appliance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddOption(Appliance app)
|
||||
{
|
||||
Entity entity = EntityManager.CreateEntity(typeof(CShopBuilderOption));
|
||||
EntityManager.SetComponentData(entity, new CShopBuilderOption(app));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Easter2025.Utilies;
|
||||
using Kitchen;
|
||||
using KitchenData;
|
||||
using KitchenMods;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class DishLockedDecor : StartOfDaySystem, IModSystem
|
||||
{
|
||||
private EntityQuery _CurrentMenuItems;
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_CurrentMenuItems = base.GetEntityQuery(typeof(CMenuItem), typeof(CAvailableIngredient));
|
||||
}
|
||||
|
||||
private static Dictionary<int, List<Decor>> Decor = new Dictionary<int, List<Decor>>
|
||||
{
|
||||
{
|
||||
GDOReferences.DishDyedEggs.ID, new List<Decor>
|
||||
{
|
||||
GDOReferences.EggWallpaper,
|
||||
GDOReferences.GalaxyEggsWallpaper,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
|
||||
foreach (Decor decor in Decor.Keys.SelectMany(id => Decor[id]))
|
||||
{
|
||||
decor.IsAvailable = false;
|
||||
}
|
||||
|
||||
using (NativeArray<Entity> CurrentMenuItems = _CurrentMenuItems.ToEntityArray(Allocator.Temp))
|
||||
{
|
||||
foreach (Entity CurrentMenuItem in CurrentMenuItems)
|
||||
{
|
||||
if (!Require(CurrentMenuItem, out CMenuItem cMenuItem)) continue;
|
||||
if (!Decor.ContainsKey(cMenuItem.SourceDish)) continue;
|
||||
foreach (Decor decor in Decor[cMenuItem.SourceDish])
|
||||
{
|
||||
decor.IsAvailable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Easter2025.Components;
|
||||
using KitchenLib.References;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
[UpdateInGroup(typeof(ItemTransferEarlyPrune))]
|
||||
public class EggBasketRestrictions : GameSystemBase, IModSystem
|
||||
{
|
||||
private EntityQuery _TransferProposals;
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
_TransferProposals = GetEntityQuery(typeof(CItemTransferProposal));
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
NativeArray<Entity> entities = _TransferProposals.ToEntityArray(Allocator.Temp);
|
||||
NativeArray<CItemTransferProposal> components = _TransferProposals.ToComponentDataArray<CItemTransferProposal>(Allocator.Temp);
|
||||
|
||||
using (NativeArray<Entity> TransferProposals = _TransferProposals.ToEntityArray(Allocator.Temp))
|
||||
{
|
||||
foreach (Entity TransferProposal in TransferProposals)
|
||||
{
|
||||
if (!Require(TransferProposal, out CItemTransferProposal cItemTransferProposal)) continue;
|
||||
if (cItemTransferProposal.Status == ItemTransferStatus.Pruned) continue;
|
||||
if ((!Require(cItemTransferProposal.Destination, out CToolUser cToolUser) || !Has<CEggBasket>(cToolUser.CurrentTool)) && (!Require(cItemTransferProposal.Destination, out CItemHolder cItemHolder) || !Has<CEggBasket>(cItemHolder.HeldItem))) continue;
|
||||
if (Has<CEggBasket.CanPlaceInBasket>(cItemTransferProposal.Item)) continue;
|
||||
cItemTransferProposal.Status = ItemTransferStatus.Pruned;
|
||||
SetComponent(TransferProposal, cItemTransferProposal);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Easter2025.Components;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class FindWaitingForEggs : GameSystemBase, IModSystem
|
||||
{
|
||||
private EntityQuery _waitingForEggsQuery;
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_waitingForEggsQuery = GetEntityQuery(typeof(CWaitingForItem), typeof(CPatience));
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
using NativeArray<Entity> waitingForEggs = _waitingForEggsQuery.ToEntityArray(Allocator.Temp);
|
||||
foreach (Entity entity in waitingForEggs)
|
||||
{
|
||||
DynamicBuffer<CWaitingForItem> waitingForItemBuffer = EntityManager.GetBuffer<CWaitingForItem>(entity);
|
||||
if (!Require(entity, out CPatience cPatience)) continue;
|
||||
if ((cPatience.StartTime > 0f ? cPatience.RemainingTime : 1f) > 0.5f) continue;
|
||||
foreach (CWaitingForItem waitingForItem in waitingForItemBuffer)
|
||||
{
|
||||
if (EntityManager.HasComponent<CHidableItem>(waitingForItem.Item))
|
||||
{
|
||||
EntityManager.AddComponent<CShouldShakeBushes>(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Easter2025.Components;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class HiddenBurning : RestaurantSystem, IModSystem
|
||||
{
|
||||
private EntityQuery _HiddenBurnables;
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_HiddenBurnables = GetEntityQuery(new QueryHelper().All(typeof(CHiddenBurnProcess), typeof(CItem)));
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
using (NativeArray<Entity> hiddenBurnables = _HiddenBurnables.ToEntityArray(Allocator.Temp))
|
||||
{
|
||||
for (var i = 0; i < hiddenBurnables.Length; i++)
|
||||
{
|
||||
var hiddenBurnable = hiddenBurnables[i];
|
||||
if (!Require(hiddenBurnable, out CHiddenBurnProcess cHiddenBurnProcess)) continue;
|
||||
if (cHiddenBurnProcess.BurnableSurfaces.Length == 0) continue;
|
||||
if (cHiddenBurnProcess.Result.Length == 0) continue;
|
||||
if (cHiddenBurnProcess.IsComplete) continue;
|
||||
|
||||
if (Require(hiddenBurnable, out CHeldBy cHeldBy))
|
||||
{
|
||||
if (Require(cHeldBy.Holder, out CAppliance cAppliance))
|
||||
{
|
||||
if (cHiddenBurnProcess.BurnableSurfaces.Contains(cAppliance.ID))
|
||||
{
|
||||
if (cHiddenBurnProcess.BurnProgress >= 1)
|
||||
{
|
||||
Set(hiddenBurnable, new CChangeItemType
|
||||
{
|
||||
NewID = cHiddenBurnProcess.Result[Random.Range(0, cHiddenBurnProcess.Result.Length)]
|
||||
});
|
||||
cHiddenBurnProcess.IsComplete = true;
|
||||
Set(hiddenBurnable, cHiddenBurnProcess);
|
||||
}
|
||||
else
|
||||
{
|
||||
cHiddenBurnProcess.BurnProgress = Mathf.Clamp01(cHiddenBurnProcess.BurnProgress + (Time.DeltaTime * (1 / cHiddenBurnProcess.BurnTimeInSeconds)));
|
||||
Set(hiddenBurnable, cHiddenBurnProcess);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cHiddenBurnProcess.BurnProgress = 0;
|
||||
Set(hiddenBurnable, cHiddenBurnProcess);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Easter2025.Components;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class KillRoamingBunnies : StartOfNightSystem, IModSystem
|
||||
{
|
||||
private EntityQuery _Bunnies;
|
||||
private EntityQuery _EventBunnies;
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_Bunnies = GetEntityQuery(typeof(CBunny));
|
||||
_EventBunnies = GetEntityQuery(typeof(CEventBunny));
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
EntityManager.DestroyEntity(_Bunnies);
|
||||
EntityManager.DestroyEntity(_EventBunnies);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Easter2025.Components;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class SpawnRoamingBunnies : StartOfDaySystem, IModSystem
|
||||
{
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (!HasSingleton<SHasTriggeredBunnies>()) return;
|
||||
SpawnBunny(-5, Mod.ROAMING_RED_BUNNY_VIEW);
|
||||
SpawnBunny(-6, Mod.ROAMING_GREEN_BUNNY_VIEW);
|
||||
SpawnBunny(-7, Mod.ROAMING_BLUE_BUNNY_VIEW);
|
||||
}
|
||||
|
||||
private void SpawnBunny(int position, ViewType viewType)
|
||||
{
|
||||
Entity entity = EntityManager.CreateEntity(typeof(CPosition), typeof(CRequiresView), typeof(CBunny));
|
||||
Set(entity, new CPosition(-0.5f, 0, position));
|
||||
Set(entity, new CRequiresView
|
||||
{
|
||||
Type = viewType,
|
||||
ViewMode = ViewMode.World,
|
||||
PhysicsDriven = true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using Easter2025.Components;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class SpawnWaitingFood : GameSystemBase, IModSystem
|
||||
{
|
||||
private EntityQuery _items;
|
||||
private EntityQuery _eggBushes;
|
||||
private EntityQuery _waitingFoods;
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_items = GetEntityQuery(new QueryHelper().All(typeof(CItem)).None(typeof(CRequestItemOf)));
|
||||
_eggBushes = GetEntityQuery(typeof(CItemHolder), typeof(CEggBush), typeof(CCanHideItem));
|
||||
_waitingFoods = GetEntityQuery(typeof(CWaitingForItem));
|
||||
}
|
||||
|
||||
private readonly Dictionary<int, int> _waitingItems = new Dictionary<int, int>();
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
using NativeArray<Entity> eggBushes = _eggBushes.ToEntityArray(Allocator.Temp);
|
||||
using NativeArray<Entity> waitingFoods = _waitingFoods.ToEntityArray(Allocator.Temp);
|
||||
using NativeArray<Entity> items = _items.ToEntityArray(Allocator.Temp);
|
||||
_waitingItems.Clear();
|
||||
|
||||
foreach (Entity waitingFood in waitingFoods)
|
||||
{
|
||||
DynamicBuffer<CWaitingForItem> waitingForItems = EntityManager.GetBuffer<CWaitingForItem>(waitingFood);
|
||||
foreach (CWaitingForItem waitingForItem in waitingForItems)
|
||||
{
|
||||
if (waitingForItem.Satisfied) continue;
|
||||
if (!Has<CHidableItem>(waitingForItem.Item)) continue;
|
||||
|
||||
if (!_waitingItems.ContainsKey(waitingForItem.ItemID))
|
||||
{
|
||||
_waitingItems.Add(waitingForItem.ItemID, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_waitingItems[waitingForItem.ItemID]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (int waiting in _waitingItems.Keys)
|
||||
{
|
||||
int required = _waitingItems[waiting];
|
||||
int found = 0;
|
||||
|
||||
foreach (Entity item in items)
|
||||
{
|
||||
if (!Require(item, out CItem cItem)) continue;
|
||||
if (waiting != cItem.ID) continue;
|
||||
found++;
|
||||
}
|
||||
|
||||
foreach (Entity eggBush in eggBushes)
|
||||
{
|
||||
if (!Require(eggBush, out CCanHideItem cCanHideItem)) continue;
|
||||
if (waiting != cCanHideItem.HiddenItem) continue;
|
||||
found++;
|
||||
}
|
||||
|
||||
if (found >= required) continue;
|
||||
|
||||
eggBushes.ShuffleInPlace();
|
||||
|
||||
foreach (Entity eggBush in eggBushes)
|
||||
{
|
||||
if (!Require(eggBush, out CItemHolder cItemHolder) || !Require(eggBush, out CCanHideItem cCanHideItem)) continue;
|
||||
if (cItemHolder.HeldItem != Entity.Null || cCanHideItem.HiddenItem != 0) continue;
|
||||
cCanHideItem.HiddenItem = waiting;
|
||||
EntityManager.AddComponentData(eggBush, cCanHideItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using Easter2025.Components;
|
||||
using Easter2025.Utilies;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class TriggerBunnies : DaySystem, IModSystem
|
||||
{
|
||||
private readonly int REWARD_AMOUNT = 250;
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (HasSingleton<SHasTriggeredBunnies>()) return;
|
||||
if (Input.GetKeyDown(KeyCode.F))
|
||||
{
|
||||
SpawnBunny(1, Mod.RED_BUNNY_VIEW);
|
||||
SpawnBunny(3, Mod.GREEN_BUNNY_VIEW);
|
||||
SpawnBunny(5 , Mod.BLUE_BUNNY_VIEW);
|
||||
|
||||
Entity e = EntityManager.CreateEntity(typeof(CMoneyTrackEvent));
|
||||
EntityManager.SetComponentData(e, new CMoneyTrackEvent
|
||||
{
|
||||
Identifier = GDOReferences.GenerousBunnies.ID,
|
||||
Amount = REWARD_AMOUNT
|
||||
});
|
||||
|
||||
if (HasSingleton<SMoney>())
|
||||
{
|
||||
SMoney money = GetSingleton<SMoney>();
|
||||
money.Amount += REWARD_AMOUNT;
|
||||
SetSingleton(money);
|
||||
}
|
||||
|
||||
EntityManager.CreateEntity(typeof(SHasTriggeredBunnies));
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnBunny(int position, ViewType viewType)
|
||||
{
|
||||
Entity entity = EntityManager.CreateEntity(typeof(CPosition), typeof(CRequiresView), typeof(CEventBunny));
|
||||
Set(entity, new CPosition(-0.5f, 0, position));
|
||||
Set(entity, new CRequiresView
|
||||
{
|
||||
Type = viewType,
|
||||
ViewMode = ViewMode.World
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace Easter2025.Systems
|
||||
{
|
||||
public class UtilitySystem : GameSystemBase, IModSystem
|
||||
{
|
||||
private static UtilitySystem Instance;
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public static bool _Has<T>(Entity entity) where T : struct, IComponentData
|
||||
{
|
||||
return Instance.Has<T>(entity);
|
||||
}
|
||||
|
||||
public static bool _Require<T>(Entity entity, out T result) where T : struct, IComponentData
|
||||
{
|
||||
return Instance.Require<T>(entity, out result);
|
||||
}
|
||||
|
||||
public static void _Set<T>(Entity entity, T componentData) where T : struct, IComponentData
|
||||
{
|
||||
Instance.Set<T>(entity, componentData);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user