forked from mirrors/0ad
@@ -60,6 +60,17 @@ function ChangeEntityTemplate(oldEnt, newTemplate)
|
||||
cmpNewPosition.SetHeightOffset(cmpPosition.GetHeightOffset());
|
||||
}
|
||||
|
||||
const cmpUnitMotion = Engine.QueryInterface(oldEnt, IID_UnitMotion);
|
||||
const cmpNewUnitMotion = Engine.QueryInterface(newEnt, IID_UnitMotion);
|
||||
if (cmpUnitMotion && cmpNewUnitMotion)
|
||||
{
|
||||
const currentSpeed = cmpUnitMotion.GetCurrentSpeed();
|
||||
cmpNewUnitMotion.SetCurrentSpeed(currentSpeed);
|
||||
|
||||
const acceleration = cmpUnitMotion.GetAcceleration();
|
||||
cmpNewUnitMotion.SetAcceleration(acceleration);
|
||||
}
|
||||
|
||||
// Prevent spawning subunits on occupied positions.
|
||||
const cmpTurretHolder = Engine.QueryInterface(oldEnt, IID_TurretHolder);
|
||||
const cmpNewTurretHolder = Engine.QueryInterface(newEnt, IID_TurretHolder);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -541,6 +541,16 @@ public:
|
||||
return m_CurrentSpeed;
|
||||
}
|
||||
|
||||
void SetCurrentSpeed(const fixed& speed) override
|
||||
{
|
||||
m_CurrentSpeed = speed;
|
||||
|
||||
if (speed == fixed::Zero())
|
||||
m_LastTurnSpeed = fixed::Zero();
|
||||
else
|
||||
m_LastTurnSpeed = speed;
|
||||
}
|
||||
|
||||
void SetFacePointAfterMove(bool facePointAfterMove) override
|
||||
{
|
||||
m_FacePointAfterMove = facePointAfterMove;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -32,6 +32,7 @@ DEFINE_INTERFACE_METHOD("PossiblyAtDestination", ICmpUnitMotion, PossiblyAtDesti
|
||||
DEFINE_INTERFACE_METHOD("FaceTowardsPoint", ICmpUnitMotion, FaceTowardsPoint)
|
||||
DEFINE_INTERFACE_METHOD("StopMoving", ICmpUnitMotion, StopMoving)
|
||||
DEFINE_INTERFACE_METHOD("GetCurrentSpeed", ICmpUnitMotion, GetCurrentSpeed)
|
||||
DEFINE_INTERFACE_METHOD("SetCurrentSpeed", ICmpUnitMotion, SetCurrentSpeed)
|
||||
DEFINE_INTERFACE_METHOD("IsMoveRequested", ICmpUnitMotion, IsMoveRequested)
|
||||
DEFINE_INTERFACE_METHOD("GetSpeed", ICmpUnitMotion, GetSpeed)
|
||||
DEFINE_INTERFACE_METHOD("GetWalkSpeed", ICmpUnitMotion, GetWalkSpeed)
|
||||
@@ -98,6 +99,11 @@ public:
|
||||
return m_Script.Call<fixed>("GetCurrentSpeed");
|
||||
}
|
||||
|
||||
void SetCurrentSpeed(const fixed& speed) override
|
||||
{
|
||||
m_Script.CallVoid("SetCurrentSpeed", speed);
|
||||
}
|
||||
|
||||
bool IsMoveRequested() const override
|
||||
{
|
||||
return m_Script.Call<bool>("IsMoveRequested");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -104,6 +104,11 @@ public:
|
||||
*/
|
||||
virtual fixed GetCurrentSpeed() const = 0;
|
||||
|
||||
/**
|
||||
* Set the speed.
|
||||
*/
|
||||
virtual void SetCurrentSpeed(const fixed& speed) = 0;
|
||||
|
||||
/**
|
||||
* @returns true if the unit has a destination.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user