Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/components/CCmpRallyPointRenderer.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | case MT_OwnershipChanged: | ||||
break; | break; | ||||
case MT_TurnStart: | case MT_TurnStart: | ||||
{ | { | ||||
UpdateOverlayLines(); // check for changes to the SoD and update the overlay lines accordingly | UpdateOverlayLines(); // check for changes to the SoD and update the overlay lines accordingly | ||||
} | } | ||||
break; | break; | ||||
case MT_Destroy: | case MT_Destroy: | ||||
{ | { | ||||
for (std::vector<entity_id_t>::iterator it = m_MarkerEntityIds.begin(); it < m_MarkerEntityIds.end(); ++it) | Reset(); | ||||
{ | |||||
if (*it != INVALID_ENTITY) | |||||
{ | |||||
GetSimContext().GetComponentManager().DestroyComponentsSoon(*it); | |||||
*it = INVALID_ENTITY; | |||||
} | |||||
} | |||||
} | } | ||||
break; | break; | ||||
case MT_PositionChanged: | case MT_PositionChanged: | ||||
{ | { | ||||
// Unlikely to happen in-game, but can occur in atlas | // Unlikely to happen in-game, but can occur in atlas | ||||
// Just recompute the path from the entity to the first rally point | // Just recompute the path from the entity to the first rally point | ||||
RecomputeRallyPointPath_wrapper(0); | RecomputeRallyPointPath_wrapper(0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (m_Displayed != displayed) | ||||
UpdateOverlayLines(); | UpdateOverlayLines(); | ||||
UpdateMessageSubscriptions(); | UpdateMessageSubscriptions(); | ||||
} | } | ||||
} | } | ||||
virtual void Reset() | virtual void Reset() | ||||
{ | { | ||||
for (entity_id_t& componentId : m_MarkerEntityIds) | |||||
{ | |||||
if (componentId != INVALID_ENTITY) | |||||
{ | |||||
GetSimContext().GetComponentManager().DestroyComponentsSoon(componentId); | |||||
componentId = INVALID_ENTITY; | |||||
} | |||||
} | |||||
m_MarkerEntityIds.clear(); | |||||
m_LastOwner = INVALID_PLAYER; | |||||
m_LastMarkerCount = 0; | |||||
m_RallyPoints.clear(); | m_RallyPoints.clear(); | ||||
RecomputeAllRallyPointPaths(); | RecomputeAllRallyPointPaths(); | ||||
UpdateMessageSubscriptions(); | UpdateMessageSubscriptions(); | ||||
} | } | ||||
/** | /** | ||||
* Returns true if at least one display rally point is set; i.e., if we have a point to render our marker/line at. | * Returns true if at least one display rally point is set; i.e., if we have a point to render our marker/line at. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 973 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator