Ejemplo n.º 1
0
        Group CreateEntity(string description)
        {
            Group group = EntityCreator.Create();

            group.Name = description;
            return(group);
        }
Ejemplo n.º 2
0
    public void OnRemoveMapObjectRes(stRemoveMapObjectMapScreenUserCmd_S cmd)
    {
        //Engine.Utility.Log.Info("OnRemoveMapObjectRes ID:" + cmd.qwThisID);

        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        {
            EntityCreator.Instance().RemovePlayer(cmd.qwThisID);
            IBox box = es.FindBox(cmd.qwThisID);
            if (box != null)
            {
                Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity();
                removeEntiy.uid = box.GetUID();
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy);
                es.RemoveEntity(box);
            }
            else
            {
                Engine.Utility.Log.Error("找不到box id{0}", cmd.qwThisID);
            }
        }
    }
Ejemplo n.º 3
0
    public void OnRemoveItems(GameCmd.stBatchRemoveItemMapScreenUserCmd_S cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        for (int i = 0; i < cmd.id.Count; ++i)
        {
            EntityCreator.Instance().RemovePlayer(cmd.id[i]);
            IBox box = es.FindBox(cmd.id[i]);
            if (box != null)
            {
                Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity();
                removeEntiy.uid = box.GetUID();
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy);
                es.RemoveEntity(box);
            }
            else
            {
                Engine.Utility.Log.Error("找不到box id{0}", cmd.id[i]);
            }
        }
    }
 public LevelingSystem(EntityCreator creator, GameConfig config)
 {
     _creator               = creator;
     _config                = config;
     _updateCallback        = OnUpdate;
     _addedToEngineCallback = OnAddedToEngine;
 }
Ejemplo n.º 5
0
        private Pair <PropertyContainer, long> CreateTimestampedEntity(EntityCreator <PropertyContainer> creator, TimelineIndex <PropertyContainer> timeline, long timestamp)
        {
            PropertyContainer entity = creator.Create();

            timeline.Add(entity, timestamp);
            return(Pair.of(entity, timestamp));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This Operation is called, when the module shall initialize itself.
        /// </summary>
        /// <param name="typeRegistry">The type registry for service requests or registrations.</param>
        /// <inheritdoc/>
        public void Initialize(ITypeRegistry typeRegistry)
        {
            var modelBuilderFactory    = typeRegistry.GetObject <IModelBuilderFactory>();
            var dataTypeRegistry       = typeRegistry.GetObject <IDataTypeRegistry>();
            var modelItemNamingService = typeRegistry.GetObject <IModelItemNamingService>();
            var odataObjectFactory     = typeRegistry.GetObject <IODataObjectFactory>();

            var structuralPropertyBinder = new StructuralPropertyBinder();
            var navigationPropertyBinder = new NavigationPropertyBinder();

            var entityReader    = new EntityReader();
            var referenceParser = new ReferenceParser(entityReader);
            var uncontainedNavigationPropertyParser = new UncontainedNavigationPropertyParser(referenceParser);
            var dependencyResolver = new DependencyResolver(uncontainedNavigationPropertyParser);

            var entityCreator = new EntityCreator(
                structuralPropertyBinder,
                navigationPropertyBinder,
                uncontainedNavigationPropertyParser,
                dependencyResolver);

            var entityUpdater = new EntityUpdater(structuralPropertyBinder, navigationPropertyBinder, uncontainedNavigationPropertyParser);

            uncontainedNavigationPropertyParser.SetUncontainedEntitiesFactory(entityCreator.CreateInUncontainedNavigationProperty);

            typeRegistry.RegisterInstance <IBindableModelBuilderFactory>(new BindableModelBuilderFactory(modelBuilderFactory));
            typeRegistry.RegisterInstance <IEntityCreator>(entityCreator);
            typeRegistry.RegisterInstance <IEntityReader>(entityReader);
            typeRegistry.RegisterInstance <IEntityUpdater>(entityUpdater);
            typeRegistry.RegisterInstance <IFactonQueryService>(CreateQueryService(typeRegistry));
            typeRegistry.RegisterInstance <IStructuralPropertyFactory>(new StructuralPropertyFactory(dataTypeRegistry, modelItemNamingService));
            typeRegistry.RegisterInstance <IODataEntityDtoBuilderFactory>(new ODataEntityDtoBuilderFactory(odataObjectFactory));
        }
Ejemplo n.º 7
0
    public void Execute(GameCmd.stAddMapNpcAndPosMapScreenUserCmd_S cmd)
    {
        //AddNPC(cmd.data);
        Profiler.BeginSample("stAddMapNpcAndPosMapScreenUserCmd_S");
        EntityCreator.Instance().AddNPC(cmd.data, cmd.master_id);
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }
        uint userUID = ClientGlobal.Instance().MainPlayer.GetID();

        if (userUID == cmd.master_id && cmd.pet_id != 0)
        {
            DataManager.Manager <PetDataManager>().AddPetToNpc(cmd.pet_id, cmd.data.mapnpcdata.npcdata.dwTempID);
        }

        GameCmd.stNpcBelongListMapScreenUserCmd_S belongcmd = new GameCmd.stNpcBelongListMapScreenUserCmd_S();
        belongcmd.teamid = cmd.data.mapnpcdata.npcdata.owernteamid;
        belongcmd.userid = cmd.master_id;
        belongcmd.npcid  = cmd.data.mapnpcdata.npcdata.dwTempID;
        Execute(belongcmd);
        RoleStateBarManager.RefreshAllRoleBarHeadStatus(HeadStatusType.Hp);
        Profiler.EndSample();
    }
Ejemplo n.º 8
0
    public void Excute(GameCmd.stBatchRemoveNpcMapScreenUserCmd_S cmd)
    {
        Profiler.BeginSample("stBatchRemoveNpcMapScreenUserCmd_S");
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }
        for (int i = 0; i < cmd.id.Count; ++i)
        {
            EntityCreator.Instance().RemoveNPC(cmd.id[i]);
            //  Engine.Utility.Log.LogGroup( "ZDY" , "stBatchRemoveNpcMapScreenUserCmd_S remove entity ----------------" + cmd.id[i] );
            IEntity npc = es.FindNPC(cmd.id[i]);
            if (npc == null)
            {
                npc = es.FindRobot(cmd.id[i]);
            }

            if (npc != null)
            {
                long uid = npc.GetUID();
                Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity();
                removeEntiy.uid = uid;
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy);

                NpcAscription.Instance.OnRemoveBelongData(uid);
            }

            es.RemoveEntity(npc);
        }
        Profiler.EndSample();
    }
Ejemplo n.º 9
0
        public static Entity CreateEntity(String key, EntityCreator creator)
        {
            Entity entity = creator.Create();
            SetEntity(key, entity);

            return entity;
        }
Ejemplo n.º 10
0
    public void Execute(GameCmd.stBatchRemoveUserMapScreenUserCmd_S cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }
        for (int i = 0; i < cmd.id.Count; ++i)
        {
            EntityCreator.Instance().RemovePlayer(cmd.id[i]);

            IPlayer player = es.FindPlayer(cmd.id[i]);
            if (player != null)
            {
                if (!ClientGlobal.Instance().IsMainPlayer(player))
                {
                    Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity();
                    removeEntiy.uid = player.GetUID();
                    Engine.Utility.Log.Info("remove :" + cmd.id[i]);
                    Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy);

                    es.RemoveEntity(player);
                }
            }
        }
    }
Ejemplo n.º 11
0
 public static void CreateEntities(List <string> tableNames, string nameSpace, string dir)
 {
     foreach (var val in tableNames)
     {
         Table table = EntityCreator.GetTable(val);
         EntityCreator.CreateEntity(table, nameSpace, dir);
     }
 }
Ejemplo n.º 12
0
    private void init()
    {
        m_messageBus      = new MessageBus();
        m_entityCreator   = new EntityCreator();
        m_languageManager = new LanguageManager();

        m_fxManager = GameObject.Find("FXManager").GetComponent <FXManager>();
    }
Ejemplo n.º 13
0
        public void ComplexList_When_Initialized_Has_Value()
        {
            var complexList = EntityCreator.CreateComplexList <ComplexType>();

            Assert.IsInstanceOfType(complexList, typeof(List <ComplexType>));
            Assert.IsTrue(complexList.Count > 0);
            Assert.IsNotNull(complexList.First().DateTime != default(DateTime));
        }
Ejemplo n.º 14
0
        Task CreateEntity(string description, Guid groupId)
        {
            Task task = EntityCreator.Create();

            task.Description = description;
            task.GroupId     = groupId;
            task.Index       = GetNewTaskIndex();
            return(task);
        }
Ejemplo n.º 15
0
        private void LoadEntity(List <KeyValuePair <string, string> > block, int index)
        {
            var className = GetClassName(block, index);

            if (EntityCreator.TryCreateEntity(className, block, out var entity))
            {
                Logger.Information("Spawning entity {ClassName} ({Index})", entity.ClassName, index);
            }
        }
Ejemplo n.º 16
0
        TimeBlock CreateEntity(Guid taskId, DateTime start)
        {
            TimeBlock task = EntityCreator.Create();

            task.TaskId = taskId;
            task.Start  = start;
            task.End    = DateTime.MaxValue;
            return(task);
        }
Ejemplo n.º 17
0
        private void MakeSureWeCanQueryLowerDefaultThan1970(EntityCreator <PropertyContainer> creator, TimelineIndex <PropertyContainer> timeline)
        {
            LinkedList <Pair <PropertyContainer, long> > timestamps = CreateTimestamps(creator, timeline, -10000, 0, 10000);

            using (Transaction tx = _db.beginTx())
            {
                assertEquals(SortedEntities(timestamps, true), asCollection(timeline.GetBetween(null, 10000L, true).GetEnumerator()));
                tx.Success();
            }
        }
Ejemplo n.º 18
0
        private void MakeSureRangesAreReturnedInCorrectReversedOrder(EntityCreator <PropertyContainer> creator, TimelineIndex <PropertyContainer> timeline)
        {
            LinkedList <Pair <PropertyContainer, long> > timestamps = CreateTimestamps(creator, timeline, 300000, 200000, 199999, 400000, 100000, 500000, 600000, 900000, 800000);

            using (Transaction tx = _db.beginTx())
            {
                assertEquals(SortedEntities(timestamps, true), asCollection(timeline.GetBetween(null, null, true).GetEnumerator()));
                tx.Success();
            }
        }
Ejemplo n.º 19
0
        /// register your block entity if you want to see it in the game
        /// provide your key from TerrainData.xml and creator for your entity, eg.
        /// RegisterBlock("JohnDoe.AwsomeBlock", (p) => new AwsomeEntity(p))
        /// If block have different values, keys for all values should be registered.
        protected Block.Material RegisterBlock(string key, EntityCreator creator)
        {
            Debug.Log("registering block: " + key);
            var block = new Block.Material(key);

            this.BlockRegistrations[block] = creator;
            this.RegistrationData.RegisterEntityHandler(key);
            Debug.Log("block: " + key + " registered successfully as: " + block.ToString());
            return(block);
        }
Ejemplo n.º 20
0
        // ======== Tests, although private so that we can create two versions of each,
        // ======== one for nodes and one for relationships

        private void MakeSureFirstAndLastAreReturnedCorrectly(EntityCreator <PropertyContainer> creator, TimelineIndex <PropertyContainer> timeline)
        {
            LinkedList <Pair <PropertyContainer, long> > timestamps = CreateTimestamps(creator, timeline, 223456, 12345, 432234);

            using (Transaction tx = _db.beginTx())
            {
                assertEquals(timestamps.get(1).first(), timeline.First);
                assertEquals(timestamps.Last.Value.first(), timeline.Last);
                tx.Success();
            }
        }
Ejemplo n.º 21
0
        private void ExecuteManageLanguages()
        {
            var selected = Translations.Aggregate(0, (current, t) => current | t.Language);

            var vm = ServiceProvider.Inject(new LanguageChooserVM(null));

            vm.SelectedLanguages = selected;
            vm.Name = Resources.Lbl.ManageLanguages;

            if (WindowService.ShowDialog(vm, canResize: true, allowSettings: false, saveSizeAndPosition: true, showOkCancelButtons: true, extraSettingsKey: "ManageLanguages") == true)
            {
                for (var i = 0; i < Entity.Translations.Count; ++i)
                {
                    if ((Entity.Translations[i].Language & vm.SelectedLanguages) == 0)
                    {
                        Entity.Translations[i].Deleted = true;
                        Entity.Translations[i].MakeDirty();
                    }
                }

                foreach (var li in LanguagesProvider.Languages)
                {
                    if ((li.Id & vm.SelectedLanguages) != 0 && Entity.Translations.All(t => t.Language != li.Id))
                    {
                        Entity.Translations.Add(EntityCreator.CreateTranslation(li.Id));
                    }
                }

                try
                {
                    DataAccess.Save(Entity);
                }
                catch (Exception ex)
                {
                    WindowService.ShowError(ex);
                }

                var parent = (MainWindowVM)Parent;
                if (Entity.Translations.Count(t => (t.Language & parent.Languages.SelectedLanguages) != 0) == 0)
                {
                    parent.HideExpression(this);
                }
                else if (!parent.ShowEmptyTranslations &&
                         Entity.Translations.Where(t => (t.Language & parent.Languages.SelectedLanguages) != 0)
                         .All(t => String.IsNullOrEmpty(t.Translation)))
                {
                    parent.HideExpression(this);
                }
                else
                {
                    PopulateTranslations();
                }
            }
        }
Ejemplo n.º 22
0
        public Scene(WorldState worldState, EntitySystemMetaData entitySystemMetaData, IModelManager modelManager, ITime engineTime, ICommandContext commandContext)
        {
            _engineTime = engineTime ?? throw new ArgumentNullException(nameof(engineTime));

            WorldState           = worldState ?? throw new ArgumentNullException(nameof(worldState));
            EntitySystemMetaData = entitySystemMetaData ?? throw new ArgumentNullException(nameof(entitySystemMetaData));
            EntityCreator        = new EntityCreator(this);
            Components           = new ComponentSystem(this);
            Models   = modelManager ?? throw new ArgumentNullException(nameof(modelManager));
            Physics  = new GamePhysics(WorldState.Logger, this, engineTime, Time, WorldState.MapInfo.Model, commandContext);
            Movement = new GameMovement(WorldState.Logger, this, engineTime, Time, Random, Physics, commandContext);
        }
Ejemplo n.º 23
0
        public void InsertOrUpdate_AddGeneOrder_AddedSuccessfully()
        {
            GeneOrder geneOrder = EntityCreator.CreateGeneOrder();

            InsertOrUpdate(geneOrder);

            GeneOrder createdGeneOrder = UnitOfWork.GetById <GeneOrder>(CreatedEntity.Id);

            Assert.NotNull(createdGeneOrder);
            Assert.NotNull(createdGeneOrder.UserId);
            Assert.NotNull(createdGeneOrder.User);
        }
Ejemplo n.º 24
0
        /// register your multiblock machine if you want to see it in the game
        /// this method can be used to create complex entities
        /// key is prefix for your enties for Control and Filler blocks in TerrainData.xml file
        /// placementSuffixes is a list of all the suffixes such as TerrainData.xml has entry key + placementSuffix[i]
        /// that way you can build machine from different blocks
        /// creators are the same as for RegisterBoxMultiblock
        /// builder controls how and from what machine is being built
        /// it is recommended to save result of this method in public static to access it from machine constructor
        protected Multiblock.Materials RegisterMultiblock(
            string key,
            List <string> placementSuffixes,
            EntityCreator controlCreator,
            EntityCreator fillerCreator,
            Multiblock.Builder builder
            )
        {
            var materials = this.RegisterMultiblockNoBuilder(key, placementSuffixes, controlCreator, fillerCreator);

            this.RegisterMultiblockBuilder(materials, builder);
            return(materials);
        }
Ejemplo n.º 25
0
 private LinkedList <Pair <PropertyContainer, long> > CreateTimestamps(EntityCreator <PropertyContainer> creator, TimelineIndex <PropertyContainer> timeline, params long[] timestamps)
 {
     using (Transaction tx = _db.beginTx())
     {
         LinkedList <Pair <PropertyContainer, long> > result = new LinkedList <Pair <PropertyContainer, long> >();
         foreach (long timestamp in timestamps)
         {
             result.AddLast(CreateTimestampedEntity(creator, timeline, timestamp));
         }
         tx.Success();
         return(result);
     }
 }
Ejemplo n.º 26
0
        private void Copy()
        {
            CopiedExpressions.Clear();

            foreach (var ex in Expressions)
            {
                if (ex.IsSelected)
                {
                    var copy = EntityCreator.CopyExpression(ex.Entity);
                    CopiedExpressions.Add(copy);
                }
            }
        }
        public override bool Initialize(EntityCreator creator, Entity entity, IReadOnlyList <KeyValuePair <string, string> > keyValues)
        {
            if (!base.Initialize(creator, entity, keyValues))
            {
                return(false);
            }

            var renderable = entity.GetComponent <StudioRenderableComponent>();

            renderable.FrameRate = 1;

            return(true);
        }
Ejemplo n.º 28
0
        public async Task EntityCreatorTest()
        {
            var model = new OrderBindingModel()
            {
                CustomerId = 3,
                ProductId  = 3,
                Quantity   = 30
            };
            var creator = new EntityCreator <OrderBindingModel, Order>(_db.Object);
            var order   = await creator.CreateAsync(model);

            Assert.NotNull(order);
            Assert.Equal(model.Quantity, order.Quantity);
        }
Ejemplo n.º 29
0
 public void OnAddMapObjectRes(stAddMapObjectMapScreenUserCmd_S cmd)
 {
     if (cmd.data.byHideType == SceneItemHideType.SceneItem_OneUserSee)
     {
         if (cmd.data.SeeOwner == MainPlayerHelper.GetPlayerID())
         {
             EntityCreator.Instance().AddBox(cmd.data, cmd.data.remain_time);
         }
     }
     else if (cmd.data.byHideType == SceneItemHideType.SceneItem_AllSee)
     {
         EntityCreator.Instance().AddBox(cmd.data, cmd.data.remain_time);
     }
 }
Ejemplo n.º 30
0
    public void Execute(GameCmd.stAddUserAndPosMapScreenUserCmd_S cmd)
    {
        //IPlayer player = AddPlayer(cmd.data.mapuserdata);
        //if (player != null)

        //MapVector2 mapPos = MapVector2.FromCoordinate(cmd.data.x, cmd.data.y);
        Vector3 pos = new Vector3(cmd.data.cur_pos.x * 0.01f, 0, -cmd.data.cur_pos.y * 0.01f); // 服务器到客户端坐标转换

        //player.SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos);
        //Vector3 rot = GameUtil.S2CDirection(cmd.data.byDir);
        //player.SendMessage(EntityMessage.EntityCommand_SetRotate, (object)rot);
        //Engine.Utility.Log.Error("add player pos is ({0},{1})", pos.x, pos.z);
        EntityCreator.Instance().AddPlayer(cmd.data.mapuserdata, pos, cmd.data.byDir, cmd.data.poslist, true);
    }
Ejemplo n.º 31
0
        public override bool Initialize(EntityCreator creator, Entity entity, IReadOnlyList <KeyValuePair <string, string> > keyValues)
        {
            if (!creator.InitializeComponent(entity.GetComponent <Transform>(), keyValues))
            {
                return(false);
            }

            if (!creator.InitializeComponent(entity.GetComponent <Light>(), keyValues))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 32
0
 public CollisionSystem(EntityCreator creator)
 {
     this.creator = creator;
 }
Ejemplo n.º 33
0
 public GameManagerSystem(EntityCreator creator, GameConfig config)
 {
     this.creator = creator;
     this.config = config;
 }
Ejemplo n.º 34
0
 public NetworkSystem(EntityCreator creator)
 {
     this.creator = creator;
 }
Ejemplo n.º 35
0
 public GunControlSystem(EntityCreator creator)
 {
     this.creator = creator;
 }
Ejemplo n.º 36
0
        public override void Initialize()
        {
            Space = new Vector2(HealGame.Game.GraphicsDevice.Viewport.Width,
                                 HealGame.Game.GraphicsDevice.Viewport.Height);
            m_level = MapManager.GetInstance();
            m_senceManager = SenceManager.GetInstance();
            m_graphic = GraphicsManager.GetInstance();
            m_entityCreator = EntityCreator.GetInstance();
            m_dialog = DialogManager.GetInstance();
            m_camera = CameraManager.GetInstance();

            m_splash = new SplashTools();
            m_splash.Initialize();

            m_handbook = new HandbookTools();
            m_handbook.Initialize();
        }
Ejemplo n.º 37
0
 public DeathThroesSystem(EntityCreator creator)
 {
     this.creator = creator;
 }
Ejemplo n.º 38
0
 public AgeSystem(EntityCreator creator)
 {
     this.creator = creator;
 }
Ejemplo n.º 39
0
 public WaitForStartSystem(EntityCreator creator)
 {
     this.creator = creator;
 }
Ejemplo n.º 40
0
 public AIMovementSystem(EntityCreator creator, GameConfig config)
 {
     this.creator = creator;
     this.config = config;
 }