Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/Unit.h
/* Copyright (C) 2016 Wildfire Games. | /* Copyright (C) 2021 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 All 9 Lines | |||||
#define INCLUDED_UNIT | #define INCLUDED_UNIT | ||||
#include <map> | #include <map> | ||||
#include <set> | #include <set> | ||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include "simulation2/system/Entity.h" // entity_id_t | #include "simulation2/system/Entity.h" // entity_id_t | ||||
class CActorDef; | |||||
class CModelAbstract; | class CModelAbstract; | ||||
class CObjectEntry; | class CObjectEntry; | ||||
class CObjectManager; | class CObjectManager; | ||||
class CSkeletonAnim; | class CSkeletonAnim; | ||||
class CUnitAnimation; | class CUnitAnimation; | ||||
///////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////// | ||||
// CUnit: simple "actor" definition - defines a sole object within the world | // CUnit: simple "actor" definition - defines a sole object within the world | ||||
class CUnit | class CUnit | ||||
{ | { | ||||
NONCOPYABLE(CUnit); | NONCOPYABLE(CUnit); | ||||
private: | private: | ||||
// Private constructor. Needs complete list of selections for the variation. | // Private constructor. Needs complete list of selections for the variation. | ||||
CUnit(CObjectEntry* object, CObjectManager& objectManager, | CUnit(CObjectManager& objectManager, const CActorDef& actor, uint32_t seed); | ||||
const std::set<CStr>& actorSelections, uint32_t seed); | |||||
public: | public: | ||||
// Attempt to create a unit with the given actor, with a set of | // Attempt to create a unit with the given actor, with a set of | ||||
// suggested selections (with the rest being randomised using the | // suggested selections (with the rest being randomised using the | ||||
// given random seed). | // given random seed). | ||||
// Returns NULL on failure. | // Returns NULL on failure. | ||||
static CUnit* Create(const CStrW& actorName, uint32_t seed, const std::set<CStr>& selections, CObjectManager& objectManager); | static CUnit* Create(const CStrW& actorName, uint32_t seed, const std::set<CStr>& selections, CObjectManager& objectManager); | ||||
Show All 24 Lines | public: | ||||
entity_id_t GetID() const { return m_ID; } | entity_id_t GetID() const { return m_ID; } | ||||
void SetID(entity_id_t id); | void SetID(entity_id_t id); | ||||
const std::set<CStr>& GetActorSelections() const { return m_ActorSelections; } | const std::set<CStr>& GetActorSelections() const { return m_ActorSelections; } | ||||
void SetActorSelections(const std::set<CStr>& selections); | void SetActorSelections(const std::set<CStr>& selections); | ||||
private: | private: | ||||
// object from which unit was created; never NULL | // Actor for the unit | ||||
CObjectEntry* m_Object; | const CActorDef& m_Actor; | ||||
// object model representation; never NULL | // object from which unit was created; never NULL once fully created. | ||||
CModelAbstract* m_Model; | CObjectEntry* m_Object = nullptr; | ||||
// object model representation; never NULL once fully created. | |||||
CModelAbstract* m_Model = nullptr; | |||||
CUnitAnimation* m_Animation; | CUnitAnimation* m_Animation = nullptr; | ||||
// unique (per map) ID number for units created in the editor, as a | // unique (per map) ID number for units created in the editor, as a | ||||
// permanent way of referencing them. | // permanent way of referencing them. | ||||
entity_id_t m_ID; | entity_id_t m_ID; | ||||
// seed used when creating unit | // seed used when creating unit | ||||
uint32_t m_Seed; | uint32_t m_Seed; | ||||
Show All 14 Lines |
Wildfire Games · Phabricator