Allow setting the passability class dynamically. This is needed to improve formation behavior for the release.
Accepted by: @Freagarach Refs: https://code.wildfiregames.com/D4563, https://code.wildfiregames.com/D4605 Differential Revision: https://code.wildfiregames.com/Dr4599 This was SVN commit r26801.
This commit is contained in:
parent
c6da4d9312
commit
5de50c447c
@ -357,7 +357,15 @@ UnitMotionFlying.prototype.SetAcceleration = function()
|
||||
|
||||
UnitMotionFlying.prototype.GetPassabilityClassName = function()
|
||||
{
|
||||
return this.template.PassabilityClass;
|
||||
return this.passabilityClassName ? this.passabilityClassName : this.template.PassabilityClass;
|
||||
};
|
||||
|
||||
UnitMotionFlying.prototype.SetPassabilityClassName = function(passClassName)
|
||||
{
|
||||
this.passabilityClassName = passClassName;
|
||||
const cmpPathfinder = Engine.QueryInterface(SYSTEM_ENTITY, IID_Pathfinder);
|
||||
if (cmpPathfinder)
|
||||
this.passabilityClass = cmpPathfinder.GetPassabilityClass(passClassName);
|
||||
};
|
||||
|
||||
UnitMotionFlying.prototype.GetPassabilityClass = function()
|
||||
|
@ -141,3 +141,7 @@ cmpUnitMotionFlying.OnUpdate({ "turnLength": 900 });
|
||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0);
|
||||
TS_ASSERT_EQUALS(height, 5);
|
||||
|
||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetPassabilityClassName(), "unrestricted");
|
||||
const newPassabilityClass = "newClass";
|
||||
cmpUnitMotionFlying.SetPassabilityClassName(newPassabilityClass);
|
||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetPassabilityClassName(), newPassabilityClass);
|
||||
|
@ -517,7 +517,7 @@ public:
|
||||
return m_PassClassName;
|
||||
}
|
||||
|
||||
virtual void SetPassabilityClassName(const std::string& passClassName)
|
||||
void SetPassabilityClassName(const std::string& passClassName) override
|
||||
{
|
||||
m_PassClassName = passClassName;
|
||||
CmpPtr<ICmpPathfinder> cmpPathfinder(GetSystemEntity());
|
||||
|
@ -40,6 +40,7 @@ DEFINE_INTERFACE_METHOD("SetSpeedMultiplier", ICmpUnitMotion, SetSpeedMultiplier
|
||||
DEFINE_INTERFACE_METHOD("GetAcceleration", ICmpUnitMotion, GetAcceleration)
|
||||
DEFINE_INTERFACE_METHOD("SetAcceleration", ICmpUnitMotion, SetAcceleration)
|
||||
DEFINE_INTERFACE_METHOD("GetPassabilityClassName", ICmpUnitMotion, GetPassabilityClassName)
|
||||
DEFINE_INTERFACE_METHOD("SetPassabilityClassName", ICmpUnitMotion, SetPassabilityClassName)
|
||||
DEFINE_INTERFACE_METHOD("GetUnitClearance", ICmpUnitMotion, GetUnitClearance)
|
||||
DEFINE_INTERFACE_METHOD("SetFacePointAfterMove", ICmpUnitMotion, SetFacePointAfterMove)
|
||||
DEFINE_INTERFACE_METHOD("GetFacePointAfterMove", ICmpUnitMotion, GetFacePointAfterMove)
|
||||
@ -156,6 +157,11 @@ public:
|
||||
return m_Script.Call<std::string>("GetPassabilityClassName");
|
||||
}
|
||||
|
||||
void SetPassabilityClassName(const std::string& passClassName) override
|
||||
{
|
||||
return m_Script.CallVoid("SetPassabilityClassName", passClassName);
|
||||
}
|
||||
|
||||
entity_pos_t GetUnitClearance() const override
|
||||
{
|
||||
return m_Script.Call<entity_pos_t>("GetUnitClearance");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -157,6 +157,11 @@ public:
|
||||
*/
|
||||
virtual std::string GetPassabilityClassName() const = 0;
|
||||
|
||||
/**
|
||||
* Sets the passability class name (as defined in pathfinder.xml)
|
||||
*/
|
||||
virtual void SetPassabilityClassName(const std::string& passClassName) = 0;
|
||||
|
||||
/**
|
||||
* Get the unit clearance (used by the Obstruction component)
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user