Beispiel #1
0
        public override object Decode(ProtocolBuffer protocolBuffer)
        {
            EntityInternal internal2;
            long           entityId = (long)this.longCodec.Decode(protocolBuffer);

            return(!SharedEntityRegistry.TryGetEntity(entityId, out internal2) ? SharedEntityRegistry.CreateEntity(entityId) : internal2);
        }
 private void CreateEntity(Engine engine)
 {
     this._entity      = this.GetOrCreateEntity();
     this._entity.Name = !string.IsNullOrEmpty(this.EntityName) ? string.Empty : this.GetNameFromTemplate();
     SharedEntityRegistry.SetShared(this.EntityId);
     this.Components.ForEach <Component>(c => this._entity.AddComponentSilent(c));
 }
 public EntityInternal GetOrCreateEntity()
 {
     if (SharedEntityRegistry.TryGetEntity(this.EntityId, out this._entity))
     {
         this._entity.TemplateAccessor = this.EntityTemplateAccessor;
     }
     else
     {
         this._entity = SharedEntityRegistry.CreateEntity(this.EntityId, this.EntityTemplateAccessor);
     }
     return(this._entity);
 }
Beispiel #4
0
        public CommandsSender(EngineService engineService, NetworkService networkService, ComponentAndEventRegistrator componentAndEventRegistrator, SharedEntityRegistry entityRegistry)
        {
            this.networkService   = networkService;
            this.entityRegistry   = entityRegistry;
            this.commandCollector = new CommandCollector();
            this.logger           = LoggerProvider.GetLogger(this);
            EventCommandCollector     eventListener     = new EventCommandCollector(this.commandCollector, componentAndEventRegistrator, entityRegistry);
            ComponentCommandCollector componentListener = new ComponentCommandCollector(this.commandCollector, componentAndEventRegistrator, entityRegistry);

            engineService.AddFlowListener(this);
            engineService.AddComponentListener(componentListener);
            engineService.AddEventListener(eventListener);
        }
        public static NetworkServiceImpl Build(EngineServiceInternal engineServiceInternal, Protocol protocol, ComponentAndEventRegistrator componentAndEventRegistrator, SharedEntityRegistry entityRegistry, CommandsCodec commandsCodec)
        {
            NetworkServiceImpl networkService = new NetworkServiceImpl(new ProtocolAdapterImpl(protocol, commandsCodec), new TcpSocketImpl());
            CommandsSender     sender1        = new CommandsSender(engineServiceInternal, networkService, componentAndEventRegistrator, entityRegistry);

            return(networkService);
        }
 public ComponentCommandCollector(CommandCollector commandCollector, ComponentAndEventRegistrator componentAndEventRegistrator, SharedEntityRegistry entityRegistry) : base(commandCollector)
 {
     this.componentAndEventRegistrator = componentAndEventRegistrator;
     this.entityRegistry = entityRegistry;
 }
Beispiel #7
0
 private void DeleteEntity(Engine engine)
 {
     engine.DeleteEntity(base.Entity);
     SharedEntityRegistry.SetUnshared(base.Entity.Id);
 }