Пример #1
0
        protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters)
        {
            entity.Transform.Position = parameters.Get<Vector2>(0);
            entity.Add(new CPlayerInfo(2));
            entity.Add<CCamera2D>(new CPlayerCamera2D());
            entity.Add<CWeapon>().Weapon = WeaponFactory.CreateDefaultWeapon();

            entity.Tag = EntityTags.Player;
        }
Пример #2
0
	public static void Attach(Entity result, Property<Vector3> property)
	{
		AkGameObjectTracker tracker = result.Get<AkGameObjectTracker>();
		if (tracker == null)
		{
			tracker = new AkGameObjectTracker();
			result.Add(tracker);
			tracker.Add(new Binding<Matrix, Vector3>(tracker.Matrix, x => Microsoft.Xna.Framework.Matrix.CreateTranslation(x), property));
		}
	}
Пример #3
0
 private void CreateObstacleEntities(AssetManager assetManager)
 {
     foreach (var obstacle in obstacles)
     {
         var entity = new Entity();
         var model  = assetManager.Load <Model>(obstacle.Model);
         entity.Add(new ModelComponent(model));
         if (!string.IsNullOrEmpty(obstacle.Animation))
         {
             var anim = assetManager.Load <AnimationClip>(obstacle.Animation);
             entity.Add(new AnimationComponent {
                 Animations = { { PlayIdleAnimationScript.AnimationName, anim } }
             });
             entity.Add(new ScriptComponent {
                 Scripts = { new PlayIdleAnimationScript() }
             });
         }
         obstacle.Entity = entity;
     }
 }
Пример #4
0
        void CreateCollider()
        {
            _colliderComponent = new StaticColliderComponent();

            var shape = new StaticMeshColliderShape(colVerts, tris,
                                                    Vector3.One);

            _colliderComponent.ColliderShape = shape;
            _colliderComponent.CanSleep      = true;
            Entity.Add(_colliderComponent);
        }
Пример #5
0
        public virtual async Task <IActionResult> PostProject([FromBody] T model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await Entity.Add(model);

            return(CreatedAtAction("Get", new { id = model.Id }, model));
        }
Пример #6
0
    public static void Attach(Entity entity, Property <Vector3> property)
    {
        AkGameObjectTracker tracker = entity.Get <AkGameObjectTracker>();

        if (tracker == null)
        {
            tracker = new AkGameObjectTracker();
            entity.Add(tracker);
            tracker.Add(new Binding <Matrix, Vector3>(tracker.Matrix, x => Microsoft.Xna.Framework.Matrix.CreateTranslation(x), property));
        }
    }
Пример #7
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspend = true;
            entity.GetOrCreate <Transform>("Transform");
            Counter c = entity.GetOrCreate <Counter>("Counter");

            base.Bind(entity, main, creating);
            entity.Add("StartingValue", c.StartingValue);
            entity.Add("Target", c.Target);
            entity.Add("IncrementBy", c.IncrementBy);
            entity.Add("OnlyTriggerOnce", c.OnlyOnce);
            entity.Add("OnTargetHit", c.OnTargetHit);
            entity.Add("Increment", c.Increment);
            entity.Add("Reset", c.Reset);
            entity.Add("Value", c.Count, readOnly: true);
            entity.Add("HasHitTarget", c.HasHitTarget, readOnly: true);
        }
Пример #8
0
        /// <summary>
        /// 装箱操作
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Entity SaveBoxEntity(Entity entity)
        {
            string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string msg          = "";

            try
            {
                this._Dal.BeginTransaction();

                UniqueDal unique = new UniqueDal(this._Dal.SqlTransaction);

                // 新增
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    CheckForSaveBoxEntityInsert(entity.GetValue("WoodID"));
                    Entity entityBox = new Entity(new PropertyCollection()
                    {
                    });
                    entityBox.Add(new SimpleProperty("Unique", typeof(int)), unique.GetValueByName("WoodPackBox"));
                    entityBox.Add(new SimpleProperty("WoodID", typeof(int)), entity.GetValue("WoodID").TryInt32());
                    entityBox.Add(new SimpleProperty("Box", typeof(int)), entity.GetValue("Box").TryInt32());
                    entityBox.Add(new SimpleProperty("PackTime", typeof(DateTime)), strCrateDate);
                    entityBox.Add(new SimpleProperty("Operator", typeof(int)), entity.GetValue("Operator").TryInt32());
                    entityBox.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                    entityBox.Add(new SimpleProperty("Version", typeof(int)), 1);
                    entityBox.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");
                    this._Dal.InsertBoxEntity(entityBox);

                    msg = "添加记录成功";
                }
                // 修改
                //else
                //{
                //    CheckForSaveBoxEntityUpdate(entity.GetValue("WoodID"));

                //    this._Dal.UpdateEntityByUniqueWithOperator(entity);

                //    msg = "修改记录成功";
                //}

                this._Dal.CommitTransaction();

                return(Helper.GetEntity(true, msg, entity.GetValue("Unique").ToString()));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Пример #9
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform   transform = entity.GetOrCreate <Transform>("Transform");
            TimeTrial   trial     = entity.GetOrCreate <TimeTrial>("TimeTrial");
            TimeTrialUI ui        = entity.GetOrCreate <TimeTrialUI>("UI");

            SetMain(entity, main);
            entity.Add("EndTimeTrial", trial.Disable);
            entity.Add("StartTimeTrial", trial.Enable);
            ui.Add(new Binding <float>(ui.ElapsedTime, trial.ElapsedTime));
            ui.Add(new Binding <string>(ui.NextMap, trial.NextMap));
            ui.Add(new CommandBinding(trial.Enable, (Action)ui.AnimateIn));
            ui.Add(new CommandBinding(trial.Disable, (Action)ui.ShowEndPanel));
            ui.Add(new CommandBinding(ui.Retry, trial.Retry));
            ui.Add(new CommandBinding(ui.MainMenu, delegate()
            {
                main.CurrentSave.Value   = null;
                main.EditorEnabled.Value = false;
                IO.MapLoader.Load(main, Main.MenuMap);
                main.Menu.Show();
            }));

            ui.Add(new CommandBinding(ui.LoadNextMap, delegate()
            {
                main.CurrentSave.Value   = null;
                main.EditorEnabled.Value = false;
                IO.MapLoader.Load(main, trial.NextMap);
            }));

            ui.Add(new CommandBinding(ui.Edit, delegate()
            {
                main.CurrentSave.Value   = null;
                main.EditorEnabled.Value = true;
                IO.MapLoader.Load(main, main.MapFile);
            }));

            entity.Add("NextMap", trial.NextMap, new PropertyEntry.EditorData
            {
                Options = FileFilter.Get(main, main.MapDirectory, new string[] { "", "Challenge" }, IO.MapLoader.MapExtension),
            });
        }
Пример #10
0
	public static void Attach(Entity result, Property<Matrix> property = null)
	{
		AkGameObjectTracker tracker = result.Get<AkGameObjectTracker>();
		if (tracker == null)
		{
			tracker = new AkGameObjectTracker();
			result.Add(tracker);
			if (property == null)
				property = result.Get<Transform>().Matrix;
			tracker.Add(new Binding<Matrix>(tracker.Matrix, property));
		}
	}
Пример #11
0
        private static EntityGroupAsset CreateOriginAsset()
        {
            // Basic test of entity serialization with links between entities (entity-entity, entity-component)
            // E1
            //   | E2 + link to E1 via TestEntityComponent
            // E3
            // E4 + link to E3.Transform component via TestEntityComponent

            var originAsset = new EntityGroupAsset();

            {
                var entity1 = new Entity()
                {
                    Name = "E1"
                };
                var entity2 = new Entity()
                {
                    Name = "E2"
                };
                var entity3 = new Entity()
                {
                    Name = "E3"
                };
                var entity4 = new Entity()
                {
                    Name = "E4"
                };

                entity1.Transform.Children.Add(entity2.Transform);

                // Test a link between entity1 and entity2
                entity2.Add(new TestEntityComponent()
                {
                    EntityLink = entity1
                });

                // Test a component link between entity4 and entity 3
                entity4.Add(new TestEntityComponent()
                {
                    EntityComponentLink = entity3.Transform
                });

                originAsset.Hierarchy.Entities.Add(entity1);
                originAsset.Hierarchy.Entities.Add(entity2);
                originAsset.Hierarchy.Entities.Add(entity3);
                originAsset.Hierarchy.Entities.Add(entity4);

                originAsset.Hierarchy.RootEntities.Add(entity1.Id);
                originAsset.Hierarchy.RootEntities.Add(entity3.Id);
                originAsset.Hierarchy.RootEntities.Add(entity4.Id);
            }
            return(originAsset);
        }
Пример #12
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspendByDistance = true;

            Transform transform = entity.GetOrCreate <Transform>("Transform");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            attachable.Enabled.Value = true;

            VoxelTrigger trigger = entity.GetOrCreate <VoxelTrigger>("VoxelTrigger");

            trigger.Add(new Binding <Voxel.Coord>(trigger.Coord, attachable.Coord));
            trigger.Add(new Binding <Entity.Handle>(trigger.AttachedVoxel, attachable.AttachedVoxel));

            this.SetMain(entity, main);

            trigger.EditorProperties();
            entity.Add("AttachOffset", attachable.Offset);
            entity.Add("AttachVector", attachable.Vector);
        }
Пример #13
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            SoundBank bank = entity.GetOrCreate <SoundBank>("SoundBank");

            this.SetMain(entity, main);

            entity.Add("Name", bank.Name, new PropertyEntry.EditorData {
                Options = FileFilter.Get(main, AkBankPath.GetPlatformBasePath(), null, SoundBank.Extension)
            });
        }
Пример #14
0
        public void testRemoveComponent()
        {
            Entity entity = new Entity();
            Id     id     = new Id();

            id.Value = 1;
            entity.Add(id);
            Name name = new Name();

            name.Value = "bob";
            entity.Add(name);

            NodeList <TestNode> nodeList = Ash.GetNodeList <TestNode>();

            Ash.AddEntity(entity);
            //Ash.RemoveEntity(entity);
            Assert.AreEqual(nodeList.Count, 1);

            entity.Remove(typeof(Name));
            Assert.AreEqual(nodeList.Count, 0);             // entity should no longer be in nodeList
        }
Пример #15
0
        public DashFuseBox(EntityData data, Vector2 offset) : base(data.Position + offset, 4f, 16f, false)
        {
            string[] activationIds = data.Attr("activationIds", "").Split(',');

            _startCutscene = data.Bool("startCutscene", false);
            _persistent    = data.Bool("persistent", false);
            _id            = new EntityID(data.Level.Name, data.ID);
            _direction     = Direction.Right;
            Enum.TryParse(data.Attr("direction", "Right"), out _direction);

            Depth           = -20;
            Add(_mainSprite = new Sprite(GFX.Game, "objects/FactoryHelper/dashFuseBox/"));
            _mainSprite.Add("idle", "idle", 0.1f, "idleBackwards");
            _mainSprite.Add("chaos", "chaos", 0.08f, "chaos");
            _mainSprite.Add("idleBackwards", "idle", 0.1f, "idle", 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
            _mainSprite.Play("idle", false, false);

            _door = new Entity(Position)
            {
                Depth = 8490
            };
            _door.Add(_doorSprite = new Sprite(GFX.Game, "objects/FactoryHelper/dashFuseBox/"));
            _doorSprite.Add("busted", "busted", 0.05f);
            _doorSprite.Play("busted", false, false);
            _doorSprite.Active  = false;
            _doorSprite.Visible = false;


            if (_direction == Direction.Left)
            {
                _mainSprite.Scale *= new Vector2(-1f, 1f);
                //_mainSprite.Position.X += 4;
                _doorSprite.Scale      *= new Vector2(-1f, 1f);
                _doorSprite.Position.X += 4;

                Collider.Position.X -= 4;
                _pressDirection      = Vector2.UnitX;
                _sparks.Direction    = (float)Math.PI;
            }
            else
            {
                _pressDirection = -Vector2.UnitX;
            }

            foreach (string activationId in activationIds)
            {
                if (activationId != "")
                {
                    _activationIds.Add(activationId);
                }
            }
            OnDashCollide = OnDashed;
        }
Пример #16
0
        public void AddShieldComponentsToEntity(Entity buildingEntity, BuildingTypeVO buildingType)
        {
            Entity          entity    = this.NewEntity();
            HealthComponent component = new HealthComponent(Service.Get <ShieldController>().PointsToHealth[buildingType.ShieldHealthPoints], ArmorType.Shield);

            entity.Add(component);
            entity.Add(new ShieldBorderComponent
            {
                ShieldGeneratorEntity = buildingEntity
            });
            TeamComponent component2 = new TeamComponent(buildingEntity.Get <TeamComponent>().TeamType);

            entity.Add(component2);
            Service.Get <EntityController>().AddEntity(entity);
            ShieldGeneratorComponent shieldGeneratorComponent = new ShieldGeneratorComponent();

            shieldGeneratorComponent.PointsRange        = buildingType.ShieldRangePoints;
            shieldGeneratorComponent.CurrentRadius      = Service.Get <ShieldController>().PointsToRange[shieldGeneratorComponent.PointsRange];
            shieldGeneratorComponent.ShieldBorderEntity = entity;
            buildingEntity.Add(shieldGeneratorComponent);
        }
Пример #17
0
            protected override Entity CreateEntity()
            {
                // create the entity, create and set the model component
                var entity = new Entity {
                    Name = "Thumbnail Entity of model: " + AssetUrl
                };

                entity.Add(new ModelComponent {
                    Model = model
                });
                entity.Add(new AnimationComponent {
                    Animations = { { "preview", srcClip ?? LoadedAsset } }
                });

                if (srcClip != null || LoadedAsset != null)
                {
                    entity.Get <AnimationComponent>().Play("preview");
                }

                return(entity);
            }
Пример #18
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // sets the virtual resolution
            areaSize = new Vector2(GraphicsDevice.Presenter.BackBuffer.Width, GraphicsDevice.Presenter.BackBuffer.Height);

            // Creates the camera
            CameraComponent.UseCustomProjectionMatrix = true;
            CameraComponent.ProjectionMatrix          = Matrix.OrthoRH(areaSize.X, areaSize.Y, -2, 2);

            // Load assets
            groundSprites = Content.Load <SpriteSheet>("GroundSprite");
            ballSprite1   = Content.Load <SpriteSheet>("BallSprite1");
            ballSprite2   = Content.Load <SpriteSheet>("BallSprite2");
            ball          = new Entity {
                new SpriteComponent {
                    SpriteProvider = new SpriteFromSheet {
                        Sheet = Content.Load <SpriteSheet>("BallSprite1")
                    }
                }
            };

            // create fore/background entities
            foreground = new Entity();
            background = new Entity();
            foreground.Add(new SpriteComponent {
                SpriteProvider = new SpriteFromSheet {
                    Sheet = groundSprites, CurrentFrame = 1
                }
            });
            background.Add(new SpriteComponent {
                SpriteProvider = new SpriteFromSheet {
                    Sheet = groundSprites, CurrentFrame = 0
                }
            });

            Scene.Entities.Add(ball);
            Scene.Entities.Add(foreground);
            Scene.Entities.Add(background);

            spriteComponent    = ball.Get <SpriteComponent>();
            transformComponent = ball.Get <TransformComponent>();

            var decorationScalings = new Vector3(areaSize.X, areaSize.Y, 1);

            background.Get <TransformComponent>().Scale    = decorationScalings;
            foreground.Get <TransformComponent>().Scale    = decorationScalings / 2;
            background.Get <TransformComponent>().Position = new Vector3(0, 0, -1);
            foreground.Get <TransformComponent>().Position = new Vector3(0, 0, 1);

            SpriteAnimation.Play(spriteComponent, 0, spriteComponent.SpriteProvider.SpritesCount - 1, AnimationRepeatMode.LoopInfinite, 30);
        }
Пример #19
0
        private void CreateEmptyDragPile()
        {
            //znznznznznznznznznznznznznznznznznznznznznznznznznznznznzn
            // Drag stack (all cards are faceup and are being moved)
            //znznznznznznznznznznznznznznznznznznznznznznznznznznznznzn
            //DragDisp = CardDeck.DealEmptyHolder();
            DragDisp      = CreateGameEntity("DragStack");
            DragDisp.Tag  = 85;
            DragDisp.Name = "DragStack";
            DragDisp.Get <Transform>().Visiable = false;
            DragDisp.Get <Transform>().Position = Vector2.Zero;
            DragDisp.Add(new CardPileComponent()
            {
                PileID = 0, CName = "DragStack", FannedDirection = 4
            });
            //DragDisp.Add(new PileDispComponent());
            BoxCollider bx = new BoxCollider(CardDeck.CardWidth, CardDeck.CardHeight);

            bx.RenderLayer = Global.BOXCOLLIDER_LAYER;
            DragDisp.Add(bx);
        }
Пример #20
0
        public void NotificationAfterInitialization()
        {
            Entity Test = new Entity();

            Test.Add <SpriteData>();

            Test.Initialize(false);

            Test.Notify(Messages.ColorChanged, Color.Aqua);

            Assert.AreEqual(Color.Aqua, Test.Get <SpriteData>().Color);
        }
Пример #21
0
 public IEnumerable <IEntity> GetEntities(ContentManager cm)
 {
     foreach (var entityModel in entities)
     {
         var e = new Entity(entityModel.Name);
         foreach (var componentModel in entityModel.Components)
         {
             e.Add((IComponent)loadObject(componentModel, cm));
         }
         yield return(e);
     }
 }
Пример #22
0
        public static void Run(Entity script)
        {
            Property <string> node    = property <string>(script, "Node");
            Command           trigger = command(script, "Trigger");

            Phone phone = PlayerDataFactory.Instance.Get <Phone>();

            if (!string.IsNullOrEmpty(node))
            {
                script.Add(new CommandBinding(phone.OnVisit(node), trigger));
            }
        }
Пример #23
0
        public override Entity Create(Main main)
        {
            Entity entity = new Entity(main, "Rain");

            ParticleEmitter emitter = new ParticleEmitter();

            emitter.ParticleType.Value       = "Rain";
            emitter.ParticlesPerSecond.Value = 12000;
            entity.Add("Emitter", emitter);

            return(entity);
        }
Пример #24
0
        public static void CreateOsmWay(Dispatcher dispatcher, Connection connection, string name, Coordinates coords, List <EntityId> entityIds)
        {
            string entityType = name;
            var    entity     = new Entity();
            var    basicWorkerRequirementSet = new WorkerRequirementSet(
                new List <WorkerAttributeSet> {
                new WorkerAttributeSet(new List <string> {
                    "simulation"
                })
            }
                );
            var writeAcl = new Map <uint, WorkerRequirementSet> {
            };

            entity.Add(EntityAcl.Metaclass, new EntityAclData(basicWorkerRequirementSet, writeAcl));
            entity.Add(Persistence.Metaclass, new PersistenceData());
            entity.Add(Metadata.Metaclass, new MetadataData(entityType));
            entity.Add(Position.Metaclass, new PositionData(coords));
            entity.Add(OsmRoad.Metaclass, new OsmRoadData(entityIds));
            connection.SendCreateEntityRequest(entity, new Option <EntityId>(), new Option <uint>());
        }
        public void TestEntityIsRemovedWhenComponentRemoved()
        {
            var entity = new Entity();

            entity.Add(new Point());
            _family.NewEntity(entity);
            entity.Remove(typeof(Point));
            _family.ComponentRemovedFromEntity(entity, typeof(Point));
            var nodes = _family.NodeList;

            Assert.IsNull(nodes.Head);
        }
Пример #26
0
        /// <summary>
        /// Creates the physics collider
        /// </summary>
        private void CreateCollider()
        {
            _colliderComponent = new StaticColliderComponent();
            var shape = new StaticMeshColliderShape(_colVertices, indices, Vector3.One);

            _colliderComponent.ColliderShape = shape;

            // Not sure if this is strictly necessary but can save cpu time according to the docs
            _colliderComponent.CanSleep = true;

            Entity.Add(_colliderComponent);
        }
Пример #27
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspend = true;

            Transform transform = entity.GetOrCreate <Transform>("Transform");

            PlayerTrigger trigger = entity.GetOrCreate <PlayerTrigger>("Trigger");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            base.Bind(entity, main, creating);

            TargetFactory.Positions.Add(transform);
            entity.Add(new CommandBinding(entity.Delete, delegate()
            {
                TargetFactory.Positions.Remove(transform);
            }));

            trigger.Add(new Binding <Vector3>(trigger.Position, transform.Position));

            trigger.Add(new CommandBinding(trigger.PlayerEntered, delegate()
            {
                entity.Add(new Animation(new Animation.Execute(entity.Delete)));
            }));
            trigger.Add(new Binding <bool>(trigger.Enabled, transform.Enabled));
            trigger.EditorProperties();
            attachable.EditorProperties();

            entity.Add("Enabled", transform.Enabled);

            entity.Add("Enable", transform.Enable);
            entity.Add("Disable", transform.Disable);
            entity.Add("Reached", trigger.PlayerEntered);
        }
Пример #28
0
        /// <summary>
        /// 保存相片
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Entity SavePhoto(Entity entity)
        {
            string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            string msg = "";

            try
            {
                this._Dal.BeginTransaction();

                UniqueDal unique = new UniqueDal(this._Dal.SqlTransaction);

                entity.Add(new SimpleProperty("Unique", typeof(int)), unique.GetValueByName("WoodCarPhoto"));
                entity.Add(new SimpleProperty("PhotoTime", typeof(DateTime)), strCrateDate);
                entity.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                entity.Add(new SimpleProperty("Version", typeof(int)), 1);
                entity.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\"}");

                int rows = this._Dal.SavePhoto(entity);

                this._Dal.CommitTransaction();

                if (rows > 0)
                {
                    msg = "照片发送成功";
                }
                else
                {
                    msg = "照片发送失败,可能是网络慢的原因,请再发送一次";
                }

                return(Helper.GetEntity(true, msg, entity.GetValue("Unique").ToString()));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Пример #29
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            CameraStop cameraStop = entity.GetOrCreate <CameraStop>("CameraStop");

            entity.CannotSuspendByDistance = true;

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();

            if (main.EditorEnabled)
            {
                entity.Add("Preview", new Command
                {
                    Action = delegate()
                    {
                        ulong id = entity.GUID;

                        Action go = delegate()
                        {
                            main.EditorEnabled.Value = false;
                            IO.MapLoader.Load(main, main.MapFile);

                            main.Spawner.CanSpawn             = false;
                            main.Renderer.Brightness.Value    = 0.0f;
                            main.Renderer.InternalGamma.Value = 0.0f;
                            main.UI.IsMouseVisible.Value      = false;

                            main.AddComponent(new PostInitialization
                            {
                                delegate()
                                {
                                    // We have to squirrel away the ID and get a new entity
                                    // because OUR entity got wiped out by the MapLoader.
                                    main.GetByGUID(id).Get <CameraStop>().Go.Execute();
                                }
                            });
                        };

                        Editor editor = main.Get("Editor").First().Get <Editor>();
                        if (editor.NeedsSave)
                        {
                            editor.SaveWithCallback(go);
                        }
                        else
                        {
                            go();
                        }
                    },
                }, Command.Perms.Executable);
            }

            entity.Add("Go", cameraStop.Go);
            entity.Add("OnDone", cameraStop.OnDone);
            entity.Add("Offset", cameraStop.Offset);
            entity.Add("Blend", cameraStop.Blend);
            entity.Add("Duration", cameraStop.Duration);
        }
Пример #30
0
        public void Execute(HttpRequest httpRequest)
        {
            // Connect
            NetworkChannel channel = new NetworkChannel(Connection);

            // Data
            Entity entity = new Entity(null);

            entity.EntityShutdown += Listener;

            EntityIdleComponent idle = new EntityIdleComponent();

            entity.Add(idle);

            SessionComponent session = new SessionComponent()
            {
                Key = Key.Parse(httpRequest.Data)
            };

            entity.Add(session);

            SessionMap.Add(session.Id, entity);
            Server.Sessions = SessionMap.Count;

            // TODO: Use Diffie–Hellman
            //
            // Response
            HttpResponse httpResponse = new HttpResponse(session.Id)
            {
                Data = SecurityUtil.Token
            };

            channel.Send(httpResponse);
#if DEBUG
            LogComponent log = new LogComponent(Log.Controller);
            entity.Add(log);

            Log.Add(httpRequest, httpResponse);
#endif
        }
Пример #31
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform     transform = entity.GetOrCreate <Transform>("Transform");
            PlayerTrigger trigger   = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();

            MapExit mapExit = entity.GetOrCreate <MapExit>("MapExit");

            trigger.Add(new TwoWayBinding <Vector3>(transform.Position, trigger.Position));
            trigger.Add(new CommandBinding(trigger.PlayerEntered, (Action)mapExit.Go));

            trigger.EditorProperties();
            entity.Add("OnEnter", trigger.PlayerEntered);
            entity.Add("Enable", trigger.Enable);
            entity.Add("Enabled", trigger.Enabled);
            entity.Add("Disable", trigger.Disable);
            entity.Add("NextMap", mapExit.NextMap, new PropertyEntry.EditorData
            {
                Options = FileFilter.Get(main, main.MapDirectory, null, MapLoader.MapExtension, delegate()
                {
                    return(new[] { Main.MenuMap });
                }),
            });
            entity.Add("StartSpawnPoint", mapExit.StartSpawnPoint);
        }
Пример #32
0
        public Entity Add()
        {
            Entity entity = new Entity();

            ServerComponent server = new ServerComponent()
            {
                Name = Environment.MachineName, Address = "127.0.0.1"
            };

            entity.Add(server);

            ServerOptionsComponent options = new ServerOptionsComponent();

            entity.Add(options);

            ServerStatusComponent status = new ServerStatusComponent();

            entity.Add(status);

            MachineComponent machine = new ServerMachineComponent();

            entity.Add(machine);

            SessionMapComponent sessions = new SessionMapComponent();

            entity.Add(sessions);
#if DEBUG
            LogComponent log = new LogComponent(LogController);
            entity.Add(log);
#endif
            Add(entity);

            return(entity);
        }
Пример #33
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");
            Rift      rift      = entity.GetOrCreate <Rift>("Rift");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main, false, false, null);

            attachable.Enabled.Value = true;
            VoxelAttachable.BindTarget(entity, rift.Position);

            this.SetMain(entity, main);

            PointLight light = entity.GetOrCreate <PointLight>();

            light.Color.Value = new Vector3(1.2f, 1.4f, 1.6f);
            light.Add(new Binding <Vector3>(light.Position, rift.Position));
            light.Add(new Binding <bool>(light.Enabled, () => rift.Type == Rift.Style.In && rift.Enabled, rift.Type, rift.Enabled));
            light.Add(new Binding <float>(light.Attenuation, x => x * 2.0f, rift.CurrentRadius));

            rift.Add(new Binding <Entity.Handle>(rift.Voxel, attachable.AttachedVoxel));
            rift.Add(new Binding <Voxel.Coord>(rift.Coordinate, attachable.Coord));

            entity.Add("Enable", rift.Enable);
            entity.Add("Disable", rift.Disable);
            entity.Add("AttachOffset", attachable.Offset);
            entity.Add("Enabled", rift.Enabled);
            entity.Add("Radius", rift.Radius);
            entity.Add("Style", rift.Type);
        }
 protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters)
 {
     entity.Add(new CVirtualThumbstick(parameters.Get<VirtualThumbstick>(0)));
     entity.Tag = EntityTags.VirtualThumbStick;
 }
Пример #35
0
        protected  Entity GetUIEntity(SpriteFont font, bool fixedSize, Vector3 position)
        {
            // Create and initialize "Touch Screen to Start"
            var touchStartLabel = new ContentDecorator
            {
                Content = new TextBlock
                {
                    Font = font,
                    TextSize = 32,
                    Text = (fixedSize) ? "Fixed Size UI" : "Regular UI",
                    TextColor = Color.White
                },
                Padding = new Thickness(30, 20, 30, 25),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            //touchStartLabel.SetPanelZIndex(1);

            var grid = new Grid
            {
                BackgroundColor = (fixedSize) ? new Color(255, 0, 255) : new Color(255, 255, 0),
                MaximumWidth = 100,
                MaximumHeight = 100,
                MinimumWidth = 100,
                MinimumHeight = 100,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition());
            grid.LayerDefinitions.Add(new StripDefinition());

            grid.Children.Add(touchStartLabel);

            // Add the background
            var background = new ImageElement { StretchType = StretchType.Fill };
            background.SetPanelZIndex(-1);

            var uiEntity = new Entity();

            // Create a procedural model with a diffuse material
            var uiComponent = new UIComponent();
            uiComponent.RootElement = new UniformGrid { Children = { background, grid } };

            uiComponent.Resolution = new Vector3(100, 100, 100);    // Same size as the inner grid
            uiComponent.IsFullScreen = false;
//            uiComponent.IsBillboard = true;
            uiComponent.IsFixedSize = fixedSize;
            uiComponent.Size = new Vector3(0.1f);   // 10% of the vertical resolution

            uiEntity.Add(uiComponent);

            uiEntity.Transform.Position = position;

            return uiEntity;
        }
Пример #36
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            Window.AllowUserResizing = true;

            // Instantiate a scene with a single entity and model component
            var scene = new Scene();

            // Create a cube entity
            cubeEntity = new Entity();

            // Create a procedural model with a diffuse material
            var model = new Model();
            var material = Material.New(GraphicsDevice, new MaterialDescriptor
            {
                Attributes =
                {
                    Diffuse = new MaterialDiffuseMapFeature(new ComputeColor(Color.White)),
                    DiffuseModel = new MaterialDiffuseLambertModelFeature()
                }
            });
            model.Materials.Add(material);
            cubeEntity.Add(new ModelComponent(model));

            var modelDescriptor = new ProceduralModelDescriptor(new CubeProceduralModel());
            modelDescriptor.GenerateModel(Services, model);

            // Add the cube to the scene
            scene.Entities.Add(cubeEntity);

            // Create a camera entity and add it to the scene
            var cameraEntity = new Entity { new CameraComponent() };
            cameraEntity.Transform.Position = new Vector3(0, 0, 5);
            scene.Entities.Add(cameraEntity);

            // Create a light
            var lightEntity = new Entity()
            {
                new LightComponent()
            };

            lightEntity.Transform.Position = new Vector3(0, 0, 1);
            lightEntity.Transform.Rotation = Quaternion.RotationY(MathUtil.DegreesToRadians(45));
            scene.Entities.Add(lightEntity);

            // Create a graphics compositor
            var compositor = new SceneGraphicsCompositorLayers();

            bool isLDR = false;
            if (isLDR)
            {
                compositor.Master.Renderers.Add(new ClearRenderFrameRenderer());
                compositor.Master.Renderers.Add(new SceneCameraRenderer() {});
            }
            else
            {
                var layer = new SceneGraphicsLayer();
                var renderHDROutput = new LocalRenderFrameProvider { Descriptor = { Format = RenderFrameFormat.HDR, DepthFormat = RenderFrameDepthFormat.Shared} };
                layer.Output = renderHDROutput;
                layer.Renderers.Add(new ClearRenderFrameRenderer());
                layer.Renderers.Add(new SceneCameraRenderer());
                compositor.Layers.Add(layer);
                compositor.Master.Renderers.Add(new SceneEffectRenderer()
                {
                    Effect = new PostProcessingEffects()
                });
            }
            compositor.Cameras.Add(cameraEntity.Get<CameraComponent>());

            SceneSystem.SceneInstance = new SceneInstance(Services, scene);

            // Use this graphics compositor
            scene.Settings.GraphicsCompositor = compositor;

            // Create a scene instance
            SceneSystem.SceneInstance = new SceneInstance(Services, scene);
        }