v0.1.2
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# Release Notes v0.1.2
|
||||
|
||||
- Fixed "Rename Pet" menu having incorrect text.
|
||||
- Fixed pets getting stuck. (*Hopefully*)
|
||||
- Increased pet sleeping time.
|
||||
@@ -0,0 +1,5 @@
|
||||
[h1]Release Notes v0.1.2[/h1]
|
||||
|
||||
- Fixed "Rename Pet" menu having incorrect text.
|
||||
- Fixed pets getting stuck. (*Hopefully*)
|
||||
- Increased pet sleeping time.
|
||||
@@ -0,0 +1,11 @@
|
||||
using KitchenMods;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pets.Components
|
||||
{
|
||||
public struct CPetStuckChecker : IModComponent
|
||||
{
|
||||
public long LastCheck;
|
||||
public Vector3 LastPosition;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace Pets
|
||||
{
|
||||
public const string MOD_GUID = "com.starfluxgames.pets";
|
||||
public const string MOD_NAME = "Pets";
|
||||
public const string MOD_VERSION = "0.1.1";
|
||||
public const string MOD_VERSION = "0.1.2";
|
||||
public const string MOD_AUTHOR = "StarFluxGames";
|
||||
public const string MOD_GAMEVERSION = ">=1.1.8";
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Pets.Systems.Activities
|
||||
{
|
||||
InteractingWith = TargetEntity,
|
||||
StartTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
|
||||
TimeToFinish = Random.Range(5, 15),
|
||||
TimeToFinish = Random.Range(15, 25),
|
||||
IsWaitingForDestination = true
|
||||
});
|
||||
|
||||
|
||||
@@ -33,6 +33,12 @@ namespace Pets.Systems.Activities
|
||||
if (!Require(pet, out CMoveToLocation cMoveToLocation)) continue;
|
||||
if (!Require(pet, out CPosition cPosition)) continue;
|
||||
if (!Require(pet, out CCurrentSpeed cCurrentSpeed)) continue;
|
||||
if (cPetInteractingWith.InteractingWith == Entity.Null)
|
||||
{
|
||||
EntityManager.RemoveComponent<CPetInteractingWith>(pet);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cPetInteractingWith.IsWaitingForDestination)
|
||||
{
|
||||
if (Vector3.Distance(cPosition, cMoveToLocation.Location) < 0.1f && cCurrentSpeed.speed < Mod.MinimumSpeedThreshold)
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kitchen;
|
||||
using KitchenData;
|
||||
using KitchenLib.Utils;
|
||||
using Pets.Components;
|
||||
using Pets.Components.Status;
|
||||
using Pets.Customs.Types;
|
||||
@@ -84,27 +85,84 @@ namespace Pets.Systems
|
||||
|
||||
return entitiesInRange;
|
||||
}
|
||||
|
||||
protected bool CanGetTo(Vector3 startingPosition, Vector3 targetPosition, Vector3 targetOffset, out Vector3 targetDestination)
|
||||
{
|
||||
|
||||
private GameObject point1;
|
||||
private GameObject point2;
|
||||
|
||||
protected bool CanGetTo(Vector3 startingPosition, Vector3 targetPosition, Vector3 targetOffset, out Vector3 targetDestination, bool ShowDebugSpheres = false)
|
||||
{
|
||||
if (!ShowDebugSpheres)
|
||||
Mod.Logger.LogInfo("");
|
||||
|
||||
|
||||
if (ShowDebugSpheres)
|
||||
{
|
||||
if (point1 != null)
|
||||
GameObject.Destroy(point1);
|
||||
if (point2 != null)
|
||||
GameObject.Destroy(point2);
|
||||
|
||||
point1 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
||||
point2 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
||||
|
||||
point1.transform.position = startingPosition;
|
||||
point2.transform.position = targetPosition + targetOffset;
|
||||
|
||||
point1.transform.localScale = Vector3.one * 0.5f;
|
||||
point2.transform.localScale = Vector3.one * 0.5f;
|
||||
|
||||
GameObject.Destroy(point1.GetComponent<Collider>());
|
||||
GameObject.Destroy(point2.GetComponent<Collider>());
|
||||
}
|
||||
|
||||
targetDestination = Vector3.zero;
|
||||
CLayoutRoomTile tile1 = GetTile(targetPosition);
|
||||
CLayoutRoomTile tile2 = GetTile(targetPosition + targetOffset);
|
||||
if (tile1.RoomID != tile2.RoomID) return false;
|
||||
|
||||
|
||||
if (tile1.RoomID == 0 || tile2.RoomID == 0)
|
||||
{
|
||||
if (ShowDebugSpheres)
|
||||
{
|
||||
point1.GetComponent<MeshRenderer>().material = MaterialUtils.GetExistingMaterial("AppleRed");
|
||||
point2.GetComponent<MeshRenderer>().material = MaterialUtils.GetExistingMaterial("AppleRed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tile1.RoomID != tile2.RoomID)
|
||||
{
|
||||
if (ShowDebugSpheres)
|
||||
{
|
||||
point1.GetComponent<MeshRenderer>().material = MaterialUtils.GetExistingMaterial("AppleRed");
|
||||
point2.GetComponent<MeshRenderer>().material = MaterialUtils.GetExistingMaterial("AppleRed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NavMesh.CalculatePath(startingPosition, targetPosition + targetOffset, NavMesh.AllAreas, Path);
|
||||
|
||||
if (Path.status == NavMeshPathStatus.PathComplete)
|
||||
targetDestination = targetPosition + targetOffset;
|
||||
|
||||
return Path.status == NavMeshPathStatus.PathComplete;
|
||||
|
||||
if (Path.status != NavMeshPathStatus.PathComplete)
|
||||
{
|
||||
if (ShowDebugSpheres)
|
||||
{
|
||||
point1.GetComponent<MeshRenderer>().material = MaterialUtils.GetExistingMaterial("AppleRed");
|
||||
point2.GetComponent<MeshRenderer>().material = MaterialUtils.GetExistingMaterial("AppleRed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
point1.GetComponent<MeshRenderer>().material = MaterialUtils.GetExistingMaterial("AppleGreen");
|
||||
point2.GetComponent<MeshRenderer>().material = MaterialUtils.GetExistingMaterial("AppleGreen");
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool GetOffsetPosition(Vector3 forward, Vector2 offset, out Vector2 success)
|
||||
{
|
||||
success = Vector2.zero;
|
||||
float rotation = Mathf.Atan2(forward.x, forward.z) * Mathf.Rad2Deg;
|
||||
Mod.Logger.LogInfo("GetOffsetPosition " + rotation);
|
||||
if (rotation == 0)
|
||||
success = offset;
|
||||
if (rotation == 90)
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using Kitchen;
|
||||
using KitchenMods;
|
||||
using Pets.Components;
|
||||
using Pets.Components.Status;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pets.Systems
|
||||
{
|
||||
public class PetStuckCheck : GameSystemBase, IModSystem
|
||||
{
|
||||
private EntityQuery _pets;
|
||||
protected override void Initialise()
|
||||
{
|
||||
base.Initialise();
|
||||
_pets = GetEntityQuery(new QueryHelper().All(typeof(CPet)));
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
using NativeArray<Entity> pets = _pets.ToEntityArray(Allocator.Temp);
|
||||
|
||||
for (int i = 0; i < pets.Length; i++)
|
||||
{
|
||||
Entity pet = pets[i];
|
||||
if (!Require(pet, out CPet cPet)) continue;
|
||||
if (!Require(pet, out CPosition cPosition)) continue;
|
||||
if (!Require(pet, out CMoveToLocation cMoveToLocation)) continue;
|
||||
if (!Require(pet, out CCurrentSpeed cCurrentSpeed)) continue;
|
||||
|
||||
if (Vector3.Distance(cMoveToLocation.Location, cPosition) > 0)
|
||||
{
|
||||
if (Require(pet, out CPetStuckChecker cPetStuckChecker))
|
||||
{
|
||||
long currentTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
if ((currentTime - cPetStuckChecker.LastCheck) < 5) continue;
|
||||
if (!(Vector3.Distance(cPosition, cPetStuckChecker.LastPosition) < 0.1f))
|
||||
{
|
||||
EntityManager.AddComponentData(pet, new CPetStuckChecker
|
||||
{
|
||||
LastCheck = currentTime,
|
||||
LastPosition = cPosition.Position
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Require(pet, out CDefaultState cDefaultState)) continue;
|
||||
cPet.State = cDefaultState.State;
|
||||
EntityManager.SetComponentData(pet, cPet);
|
||||
|
||||
if (Has<CPetStuckChecker>(pet))
|
||||
EntityManager.RemoveComponent<CPetStuckChecker>(pet);
|
||||
|
||||
if (Has<CMoveToLocation>(pet))
|
||||
EntityManager.RemoveComponent<CMoveToLocation>(pet);
|
||||
|
||||
if (Has<CCurrentSpeed>(pet))
|
||||
EntityManager.AddComponentData(pet, new CCurrentSpeed
|
||||
{
|
||||
speed = 0
|
||||
});
|
||||
|
||||
if (Require(pet, out CPetInteractingWith cPetInteractingWith))
|
||||
{
|
||||
if (cPetInteractingWith.InteractingWith != Entity.Null)
|
||||
{
|
||||
EntityManager.RemoveComponent<COccupiedByPet>(cPetInteractingWith.InteractingWith);
|
||||
EntityManager.RemoveComponent<CPetInteractingWith>(pet);
|
||||
}
|
||||
}
|
||||
|
||||
EntityManager.RemoveComponent<CMoveToLocation>(pet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityManager.AddComponentData(pet, new CPetStuckChecker
|
||||
{
|
||||
LastCheck = DateTimeOffset.Now.ToUnixTimeSeconds(),
|
||||
LastPosition = cPosition.Position
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Has<CPetStuckChecker>(pet))
|
||||
EntityManager.RemoveComponent<CPetStuckChecker>(pet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -155,7 +155,7 @@ namespace Pets.Views
|
||||
|
||||
if (Data.RequestingInputSource == InputSourceIdentifier.Identifier)
|
||||
{
|
||||
TextInputView.RequestTextInput(base.Localisation["INPUT_TITLE_RENAME_RESTAURANT"], "", 24, HandleNewName);
|
||||
TextInputView.RequestTextInput("Rename Pet", "", 24, HandleNewName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user