Index: binaries/data/mods/public/art/actors/fauna/crocodile.xml
===================================================================
--- binaries/data/mods/public/art/actors/fauna/crocodile.xml
+++ binaries/data/mods/public/art/actors/fauna/crocodile.xml
@@ -10,6 +10,7 @@
+
Index: binaries/data/mods/public/simulation/components/UnitAI.js
===================================================================
--- binaries/data/mods/public/simulation/components/UnitAI.js
+++ binaries/data/mods/public/simulation/components/UnitAI.js
@@ -3140,7 +3140,7 @@
"ROAMING": {
"enter": function() {
// Walk in a random direction
- this.SelectAnimation("walk", false, this.GetWalkSpeed());
+ this.SelectAnimation("move");
this.SetFacePointAfterMove(false);
this.MoveRandomly(+this.template.RoamDistance);
// Set a random timer to switch to feeding state
Index: binaries/data/mods/public/simulation/templates/gaia/fauna_crocodile.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/gaia/fauna_crocodile.xml
+++ binaries/data/mods/public/simulation/templates/gaia/fauna_crocodile.xml
@@ -21,6 +21,8 @@
pitch-roll
+ true
+ 1.0
Index: source/simulation2/components/CCmpPosition.cpp
===================================================================
--- source/simulation2/components/CCmpPosition.cpp
+++ source/simulation2/components/CCmpPosition.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Wildfire Games.
+/* Copyright (C) 2018 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -467,6 +467,19 @@
AdvertiseInterpolatedPositionChanges();
}
+ virtual bool IsCurrentlyFloating() const
+ {
+ if (!m_Floating)
+ return false;
+
+ CmpPtr cmpTerrain(GetSystemEntity());
+ CmpPtr cmpWaterManager(GetSystemEntity());
+ if (!cmpTerrain || !cmpWaterManager)
+ return false;
+
+ return cmpTerrain->GetGroundLevel(m_X, m_Z) < cmpWaterManager->GetWaterLevel(m_X, m_Z) - m_FloatDepth;
+ }
+
virtual bool CanFloat() const
{
return m_Floating;
@@ -942,7 +955,7 @@
return;
}
- if (m_AnchorType == UPRIGHT || !m_RotZ.IsZero() || !m_RotX.IsZero())
+ if (m_AnchorType == UPRIGHT || !m_RotZ.IsZero() || !m_RotX.IsZero() || IsCurrentlyFloating())
{
// set the visual rotations to the ones fixed by the interface
m_InterpolatedRotX = m_RotX.ToFloat();
Index: source/simulation2/components/CCmpVisualActor.cpp
===================================================================
--- source/simulation2/components/CCmpVisualActor.cpp
+++ source/simulation2/components/CCmpVisualActor.cpp
@@ -788,8 +788,10 @@
if (speed.IsZero())
{
speed = fixed::FromFloat(1.f);
- name = "idle";
+ name = cmpPosition->IsCurrentlyFloating() ? "float" : "idle";
}
+ else if (cmpPosition->IsCurrentlyFloating())
+ name = "swim";
else
name = speed < m_AnimRunThreshold ? "walk" : "run";
Index: source/simulation2/components/ICmpPosition.h
===================================================================
--- source/simulation2/components/ICmpPosition.h
+++ source/simulation2/components/ICmpPosition.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Wildfire Games.
+/* Copyright (C) 2018 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -137,6 +137,11 @@
virtual void SetHeightRelative(bool flag) = 0;
/**
+ * Returns whether the entity is currently floating on water.
+ */
+ virtual bool IsCurrentlyFloating() const = 0;
+
+ /**
* Returns whether the entity can float on water.
*/
virtual bool CanFloat() const = 0;
Index: source/simulation2/components/ICmpPosition.cpp
===================================================================
--- source/simulation2/components/ICmpPosition.cpp
+++ source/simulation2/components/ICmpPosition.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Wildfire Games.
+/* Copyright (C) 2018 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -35,6 +35,7 @@
DEFINE_INTERFACE_METHOD_CONST_0("GetHeightFixed", entity_pos_t, ICmpPosition, GetHeightFixed)
DEFINE_INTERFACE_METHOD_CONST_0("IsHeightRelative", bool, ICmpPosition, IsHeightRelative)
DEFINE_INTERFACE_METHOD_1("SetHeightRelative", void, ICmpPosition, SetHeightRelative, bool)
+DEFINE_INTERFACE_METHOD_CONST_0("IsCurrentlyFloating", bool, ICmpPosition, IsCurrentlyFloating)
DEFINE_INTERFACE_METHOD_CONST_0("CanFloat", bool, ICmpPosition, CanFloat)
DEFINE_INTERFACE_METHOD_1("SetFloating", void, ICmpPosition, SetFloating, bool)
DEFINE_INTERFACE_METHOD_1("SetConstructionProgress", void, ICmpPosition, SetConstructionProgress, fixed)
Index: source/simulation2/components/tests/test_RangeManager.h
===================================================================
--- source/simulation2/components/tests/test_RangeManager.h
+++ source/simulation2/components/tests/test_RangeManager.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Wildfire Games.
+/* Copyright (C) 2018 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -54,6 +54,7 @@
virtual entity_pos_t GetHeightFixed() const { return entity_pos_t::Zero(); }
virtual bool IsHeightRelative() const { return true; }
virtual void SetHeightRelative(bool UNUSED(relative)) { }
+ virtual bool IsCurrentlyFloating() const { return false; }
virtual bool CanFloat() const { return false; }
virtual void SetFloating(bool UNUSED(flag)) { }
virtual void SetActorFloating(bool UNUSED(flag)) { }