fix: add is_sheltered attribute to AgentSnapshot class

- Add is_sheltered parameter to AgentSnapshot in both locations
- Include is_sheltered in agent_data dictionary for idle chat

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
empty
2026-01-02 01:18:14 +08:00
parent 4f3bd5695c
commit ce0be0045d
7 changed files with 87 additions and 29 deletions

View File

@@ -211,6 +211,22 @@ namespace TheIsland.Visual
// Phase 19: Smooth UI Bar Transitions
UpdateSmoothBars();
// Phase 20-C: Hard boundary enforcement (No water allowed!)
ClampPosition();
}
private void ClampPosition()
{
// Safety boundaries for the island beach - Phase 20-C.2 Recalibrated (Shore at Z=7.0)
// X: ~[-25, 25], Z: ~[-10, 6.5]
float clampedX = Mathf.Clamp(transform.position.x, -25f, 25f);
float clampedZ = Mathf.Clamp(transform.position.z, -10f, 6.5f); // Stay clearly on land
if (clampedX != transform.position.x || clampedZ != transform.position.z)
{
transform.position = new Vector3(clampedX, transform.position.y, clampedZ);
}
}
private void UpdateGrounding()
@@ -223,6 +239,13 @@ namespace TheIsland.Visual
float bopY = (_spriteRenderer != null) ? _spriteRenderer.transform.localPosition.y : 0;
float shadowScale = Mathf.Clamp(1.0f - (bopY * 0.5f), 0.5f, 1.2f);
_shadowObj.transform.localScale = new Vector3(1.2f * shadowScale, 0.6f * shadowScale, 1f);
// Phase 20-B: Darker shadow when sheltered (under tree)
if (_shadowRenderer != null)
{
float targetAlpha = (_currentData != null && _currentData.is_sheltered) ? 0.6f : 0.3f;
_shadowRenderer.color = new Color(0, 0, 0, Mathf.Lerp(_shadowRenderer.color.a, targetAlpha, Time.deltaTime * 5f));
}
}
if (_isMoving)
@@ -1340,7 +1363,7 @@ namespace TheIsland.Visual
}
/// <summary>
/// Display social role indicator based on agent's role.
/// Display social role and shelter indicators based on agent's state.
/// </summary>
private void UpdateSocialRoleDisplay()
{
@@ -1354,9 +1377,11 @@ namespace TheIsland.Visual
_ => ""
};
// Append role icon to name (strip any existing icons first)
string baseName = _currentData.name;
_nameLabel.text = baseName + roleIcon;
// Phase 20-B: Shelter Icon
string shelterIcon = (_currentData != null && _currentData.is_sheltered) ? " <color=#90EE90>🏠</color>" : "";
// Update name label with icons
_nameLabel.text = _currentData.name + roleIcon + shelterIcon;
}
#endregion

View File

@@ -574,18 +574,19 @@ namespace TheIsland.Core
switch (location.ToLower())
{
case "tree_left":
return new Vector3(-10f, 0f, 8f);
return new Vector3(-12f, 0f, 5.0f); // Phase 20-C.2: Recalibrated
case "tree_right":
return new Vector3(10f, 0f, 8f);
return new Vector3(13f, 0f, 5.5f); // Phase 20-C.2: Recalibrated
case "campfire":
case "center":
return new Vector3(0f, 0f, 0f);
case "water":
case "beach":
return new Vector3(Random.Range(-5, 5), 0f, 4f);
// Shore starts at Z=7.0. Safe beach area is Z=[3, 6]
return new Vector3(Random.Range(-5, 5), 0f, Random.Range(4, 6));
case "nearby":
// Move to random nearby spot (wandering)
return new Vector3(Random.Range(-12, 12), 0f, Random.Range(-2, 6));
// Wandering constrained to dry land Z=[-6, 6]
return new Vector3(Random.Range(-15, 15), 0f, Random.Range(-6, 6));
case "herb_patch":
// Phase 16: Herb gathering location
return new Vector3(-8f, 0f, -5f);

View File

@@ -59,6 +59,9 @@ namespace TheIsland.Models
// Relationship 2.0 (Phase 17-B)
public string social_role; // "leader", "follower", "loner", "neutral"
// Shelter System (Phase 20-B)
public bool is_sheltered;
public bool IsAlive => status == "Alive";
}

View File

@@ -276,9 +276,9 @@ namespace TheIsland.Visual
_groundPlane = GameObject.CreatePrimitive(PrimitiveType.Quad);
_groundPlane.name = "GroundPlane";
_groundPlane.transform.SetParent(transform);
_groundPlane.transform.position = new Vector3(0, -0.5f, 5);
_groundPlane.transform.position = new Vector3(0, -0.5f, 0); // Phase 20-C.2: Center ground
_groundPlane.transform.rotation = Quaternion.Euler(90, 0, 0);
_groundPlane.transform.localScale = new Vector3(40, 20, 1);
_groundPlane.transform.localScale = new Vector3(80, 24, 1); // Phase 20-C.2: Larger sand area Z=[-12, 12]
// Create sand texture
_groundMaterial = new Material(Shader.Find("Unlit/Texture"));
@@ -325,9 +325,9 @@ namespace TheIsland.Visual
_waterPlane = GameObject.CreatePrimitive(PrimitiveType.Quad);
_waterPlane.name = "WaterPlane";
_waterPlane.transform.SetParent(transform);
_waterPlane.transform.position = new Vector3(0, -0.3f, 12);
_waterPlane.transform.position = new Vector3(0, -0.3f, 15); // Phase 20-C.2: Move water back (Shore starts at ~7.0)
_waterPlane.transform.rotation = Quaternion.Euler(90, 0, 0);
_waterPlane.transform.localScale = new Vector3(60, 15, 1);
_waterPlane.transform.localScale = new Vector3(100, 16, 1); // Range Z=[7, 23]
// Create water material
if (customWaterMaterial != null)
@@ -409,16 +409,17 @@ namespace TheIsland.Visual
private void CreateDecorations()
{
// Create palm tree silhouettes
CreatePalmTree(new Vector3(-8, 0, 8), 2.5f);
CreatePalmTree(new Vector3(-10, 0, 10), 3f);
CreatePalmTree(new Vector3(9, 0, 7), 2.2f);
CreatePalmTree(new Vector3(11, 0, 9), 2.8f);
// Create palm tree silhouettes - Recalibrated for Phase 20-C (Stay on Land Z < 4.5)
// Create palm tree silhouettes - Recalibrated for Phase 20-C.2 (Safe dry land Z < 6.0)
CreatePalmTree(new Vector3(-12, 0, 5.0f), 2.8f);
CreatePalmTree(new Vector3(-15, 0, 4.0f), 3.2f);
CreatePalmTree(new Vector3(13, 0, 5.5f), 2.5f);
CreatePalmTree(new Vector3(16, 0, 4.5f), 3.0f);
// Create rocks
CreateRock(new Vector3(-5, 0, 4), 0.5f);
CreateRock(new Vector3(6, 0, 5), 0.7f);
CreateRock(new Vector3(-7, 0, 6), 0.4f);
// Create rocks - Recalibrated for Phase 20-C.2
CreateRock(new Vector3(-8, 0, 4.5f), 0.5f);
CreateRock(new Vector3(10, 0, 5.5f), 0.7f);
CreateRock(new Vector3(-14, 0, 3.0f), 0.4f);
CreateGroundDetails();
}