TrueReality  v0.1.1912
ActorBase.h
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 
22 #pragma once
23 
24 #include "Export.h"
25 
26 #include <trManager/MessageBase.h>
27 #include <trManager/EntityBase.h>
28 #include <trBase/UniqueId.h>
29 #include <trBase/SmrtPtr.h>
30 
31 #include <stdlib.h>
32 #include <vector>
33 
34 namespace trManager
35 {
42  {
43  public:
44 
46 
47  const static trUtil::RefStr CLASS_TYPE;
48 
56  ActorBase(const std::string& name = CLASS_TYPE);
57 
61  virtual const std::string& GetType() const override = 0;
62 
73  virtual void RegisterForMessage(const std::string& messageType, const std::string& invokableName);
74 
84  virtual void UnRegisterFromMessage(const std::string& messageType);
85 
94  virtual void RegisterForMessagesAboutEntity(const trBase::UniqueId& aboutEntityId, const std::string& invokableName);
95 
103  virtual void UnregisterFromMessagesAboutEntity(const trBase::UniqueId& aboutEntityId);
104 
110  virtual void BuildInvokables();
111 
120  virtual void OnTick(const trManager::MessageBase& msg) = 0;
121 
130  virtual void OnTickRemote(const trManager::MessageBase& msg);
131 
141  virtual bool SendMessage(const trManager::MessageBase& message);
142 
152  virtual bool SendNetworkMessage(const trManager::MessageBase& message);
153 
166  virtual bool AddActorModule(trManager::EntityBase& actorModule);
167 
177  virtual bool RemoveActorModule(trManager::EntityBase& actorModule);
178 
188  virtual bool RemoveActorModule(const trBase::UniqueId& id);
189 
197  virtual bool RemoveAllActorModules();
198 
208  virtual trManager::EntityBase* FindActorModule(const trBase::UniqueId& id);
209 
215  virtual void OnAddedToSysMan() override;
216 
222  virtual void OnRemovedFromSysMan() override;
223 
224  protected:
225 
231  ~ActorBase();
232 
241  virtual void ActorModuleTick(const trManager::MessageBase& tickMsg);
242 
243  private:
244 
250  using ActorModules = std::vector<trBase::SmrtPtr<trManager::EntityBase>>;
251  ActorModules mActorModules; //Actor Module Storage
252 
253  //Temp Storage for actor modules if this actor is disconnected and reconnected from and to System Manager.
255  };
256 }
257 
This class creates a GUID, or a Unique ID that is used through out TR to identify and distinguish one...
Definition: UniqueId.h:42
A string wrapper that will make sure that all of the strings with the same value will point to the sa...
Definition: RefStr.h:50
std::vector< trBase::SmrtPtr< trManager::EntityBase > > ActorModules
ActorModules = std::vector<trBase::SmrtPtr<trManager::EntityBase>>
Definition: ActorBase.h:250
This class is part of the internal garbage collection system.
Definition: SmrtClass.h:38
ActorModules mActModReAttachStore
Definition: ActorBase.h:254
A base class for all actors in the entity system.
Definition: ActorBase.h:41
static const trUtil::RefStr CLASS_TYPE
Adds an easy and swappable access to the base class.
Definition: ActorBase.h:47
This serves as the base class for the Entity class and removes a circular dependency between Entity a...
Definition: EntityBase.h:46
This is the base class for all the messages in TR.
Definition: MessageBase.h:40
#define TR_MANAGER_EXPORT
ActorModules mActorModules
Definition: ActorBase.h:251