当前位置: 首页>>代码示例>>C#>>正文


C# Entity.GetOrMakeProperty方法代码示例

本文整理汇总了C#中System.Entity.GetOrMakeProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.GetOrMakeProperty方法的具体用法?C# Entity.GetOrMakeProperty怎么用?C# Entity.GetOrMakeProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Entity的用法示例。


在下文中一共展示了Entity.GetOrMakeProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Bind

        public override void Bind(Entity result, Main main, bool creating = false)
        {
            PointLight light = result.Get<PointLight>();
            Transform transform = result.Get<Transform>();
            Property<float> attachOffset = result.GetOrMakeProperty<float>("AttachmentOffset", true);
            light.Add(new TwoWayBinding<Vector3>(light.Position, transform.Position));

            if (result.GetOrMakeProperty<bool>("Attach", true))
                MapAttachable.MakeAttachable(result, main);

            this.SetMain(result, main);
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:12,代码来源:PointLightFactory.cs

示例2: Attach

		public static void Attach(Entity entity, Main main)
		{
			Transform transform = entity.Get<Transform>();
			Property<float> attachOffset = entity.GetOrMakeProperty<float>("AttachmentOffset", true);
			Property<Entity.Handle> map = entity.GetOrMakeProperty<Entity.Handle>("AttachedMap");
			Property<Map.Coordinate> coord = entity.GetOrMakeProperty<Map.Coordinate>("AttachedCoordinate");

			if (main.EditorEnabled)
				return;

			entity.Add(new PostInitialization
			{
				delegate()
				{
					if (map.Value.Target == null)
					{
						Map closestMap = null;
						Map.Coordinate? closestCoord = null;
						int closestDistance = 3;
						float closestFloatDistance = 3.0f;
						Vector3 target = Vector3.Transform(new Vector3(0, 0, attachOffset), transform.Matrix);
						foreach (Map m in Map.Maps)
						{
							Map.Coordinate targetCoord = m.GetCoordinate(target);
							Map.Coordinate? c = m.FindClosestFilledCell(targetCoord, closestDistance);
							if (c.HasValue)
							{
								float distance = (m.GetRelativePosition(c.Value) - m.GetRelativePosition(targetCoord)).Length();
								if (distance < closestFloatDistance)
								{
									closestFloatDistance = distance;
									closestDistance = (int)Math.Floor(distance);
									closestMap = m;
									closestCoord = c;
								}
							}
						}
						if (closestMap == null)
							entity.Delete.Execute();
						else
						{
							map.Value = closestMap.Entity;
							coord.Value = closestCoord.Value;
						}
					}
					else
					{
						map.Reset();
						coord.Reset();
					}
				}
			});
		}
开发者ID:sparker,项目名称:Lemma,代码行数:53,代码来源:VoxelEntity.cs

示例3: AttachEditorComponents

		public static void AttachEditorComponents(Entity result, Main main, Property<Vector3> color = null)
		{
			Model model = new Model();
			model.Filename.Value = "Models\\cone";
			if (color != null)
				model.Add(new Binding<Vector3>(model.Color, color));
			model.Add(new Binding<bool>(model.Enabled, result.GetOrMakeProperty<bool>("EditorSelected")));
			model.Add(new Binding<Vector3, float>(model.Scale, x => new Vector3(1.0f, 1.0f, x), result.GetOrMakeProperty<float>("AttachmentOffset", true)));
			model.Editable = false;
			model.Serialize = false;

			result.Add("EditorModel2", model);

			model.Add(new Binding<Matrix>(model.Transform, result.Get<Transform>().Matrix));
		}
开发者ID:sparker,项目名称:Lemma,代码行数:15,代码来源:VoxelEntity.cs

示例4: Bind

        public override void Bind(Entity result, Main main, bool creating = false)
        {
            this.SetMain(result, main);
            result.CannotSuspendByDistance = true;

            Transform transform = result.Get<Transform>();

            ModelAlpha model = new ModelAlpha();
            model.Color.Value = new Vector3(1.2f, 1.0f, 0.8f);
            model.Editable = false;
            model.Serialize = false;
            model.Filename.Value = "Models\\electricity";
            model.DrawOrder.Value = 11;
            result.Add("Model", model);

            result.GetOrMakeProperty<bool>("IsMapEdge", true, true);

            PhysicsBlock block = result.Get<PhysicsBlock>();
            block.Box.BecomeKinematic();
            this.boundaries.Add(result);
            result.Add(new CommandBinding(result.Delete, delegate() { this.boundaries.Remove(result); }));
            block.Add(new TwoWayBinding<Matrix>(transform.Matrix, block.Transform));
            model.Add(new Binding<Matrix>(model.Transform, transform.Matrix));
            model.Add(new Binding<Vector3>(model.Scale, x => new Vector3(x.X * 0.5f, x.Y * 0.5f, 1.0f), block.Size));

            Property<Vector2> scaleParameter = model.GetVector2Parameter("Scale");
            model.Add(new Binding<Vector2, Vector3>(scaleParameter, x => new Vector2(x.Y, x.X), model.Scale));
            model.Add(new CommandBinding(main.ReloadedContent, delegate()
            {
                scaleParameter.Reset();
            }));
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:32,代码来源:MapBoundaryFactory.cs

示例5: AttachEditorComponents

		public static void AttachEditorComponents(Entity result, ListProperty<Entity.Handle> target)
		{
			Transform transform = result.Get<Transform>();

			Property<bool> selected = result.GetOrMakeProperty<bool>("EditorSelected");

			Command<Entity> toggleEntityConnected = new Command<Entity>
			{
				Action = delegate(Entity entity)
				{
					if (target.Contains(entity))
						target.Remove(entity);
					else if (entity != result)
						target.Add(entity);
				}
			};
			result.Add("ToggleEntityConnected", toggleEntityConnected);

			LineDrawer connectionLines = new LineDrawer { Serialize = false };
			connectionLines.Add(new Binding<bool>(connectionLines.Enabled, selected));

			Color connectionLineColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
			ListBinding<LineDrawer.Line, Entity.Handle> connectionBinding = new ListBinding<LineDrawer.Line, Entity.Handle>(connectionLines.Lines, target, delegate(Entity.Handle entity)
			{
				return new LineDrawer.Line
				{
					A = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(transform.Position, connectionLineColor),
					B = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(entity.Target.Get<Transform>().Position, connectionLineColor)
				};
			}, x => x.Target != null && x.Target.Active);
			result.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, selected));
			result.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, () => selected, transform.Position));
			connectionLines.Add(connectionBinding);
			result.Add(connectionLines);
		}
开发者ID:sparker,项目名称:Lemma,代码行数:35,代码来源:EntityConnectable.cs

示例6: Bind

        public override void Bind(Entity result, Main main, bool creating = false)
        {
            if (result.GetOrMakeProperty<bool>("Attach", true))
                MapAttachable.MakeAttachable(result, main);

            this.SetMain(result, main);

            if (main.EditorEnabled)
            {
                result.Add("Spawn Here", new Command
                {
                    Action = delegate()
                    {
                        ((GameMain)main).StartSpawnPoint.Value = result.ID;
                        Editor editor = main.Get("Editor").First().Get<Editor>();
                        if (editor.NeedsSave)
                            editor.Save.Execute();
                        main.EditorEnabled.Value = false;
                        IO.MapLoader.Load(main, null, main.MapFile);
                    },
                    ShowInEditor = true,
                });
            }

            Transform transform = result.Get<Transform>();

            PlayerSpawn spawn = result.Get<PlayerSpawn>();
            spawn.Add(new TwoWayBinding<Vector3>(transform.Position, spawn.Position));
            spawn.Add(new Binding<float, Vector3>(spawn.Rotation, x => ((float)Math.PI * -0.5f) - (float)Math.Atan2(x.Z, x.X), transform.Forward));

            PlayerTrigger trigger = result.Get<PlayerTrigger>();
            trigger.Enabled.Editable = true;
            trigger.Add(new TwoWayBinding<Vector3>(transform.Position, trigger.Position));
            trigger.Add(new CommandBinding<Entity>(trigger.PlayerEntered, delegate(Entity player) { spawn.Activate.Execute(); }));
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:35,代码来源:PlayerSpawnFactory.cs

示例7: Bind

        public override void Bind(Entity result, Main main, bool creating = false)
        {
            result.CannotSuspend = true;

            Script script = result.Get<Script>();

            Property<bool> executeOnLoad = result.GetProperty<bool>("ExecuteOnLoad");
            if (executeOnLoad && !main.EditorEnabled)
            {
                result.Add("Executor", new PostInitialization
                {
                    delegate()
                    {
                        if (executeOnLoad)
                            script.Execute.Execute();
                    }
                });
            }

            Property<bool> deleteOnExecute = result.GetOrMakeProperty<bool>("DeleteOnExecute", true, false);
            if (deleteOnExecute)
                result.Add(new CommandBinding(script.Execute, result.Delete));

            this.SetMain(result, main);
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:25,代码来源:ScriptFactory.cs

示例8: Bind

        public override void Bind(Entity result, Main main, bool creating = false)
        {
            Transform transform = result.GetOrCreate<Transform>("Transform");
            PhysicsBlock physics = result.GetOrCreate<PhysicsBlock>();
            physics.Size.Value = Vector3.One;
            physics.Editable = false;
            ModelInstance model = result.GetOrCreate<ModelInstance>();
            model.Editable = false;

            physics.Add(new TwoWayBinding<Matrix>(transform.Matrix, physics.Transform));

            Property<string> soundCue = result.GetOrMakeProperty<string>("CollisionSoundCue", false);
            soundCue.Serialize = false;

            model.Add(new Binding<Matrix>(model.Transform, transform.Matrix));

            const float volumeMultiplier = 0.1f;

            physics.Add(new CommandBinding<Collidable, ContactCollection>(physics.Collided, delegate(Collidable collidable, ContactCollection contacts)
            {
                float volume = contacts[contacts.Count - 1].NormalImpulse * volumeMultiplier;
                if (volume > 0.1f && soundCue.Value != null)
                {
                    Sound sound = Sound.PlayCue(main, soundCue, transform.Position, volume, 0.05f);
                    if (sound != null)
                        sound.GetProperty("Pitch").Value = 1.0f;
                }
            }));

            this.SetMain(result, main);

            Property<bool> valid = result.GetOrMakeProperty<bool>("Valid", false);
            valid.Serialize = false;

            Property<string> type = result.GetOrMakeProperty<string>("Type", true);
            type.Set = delegate(string value)
            {
                Map.CellState state;
                if (WorldFactory.StatesByName.TryGetValue(value, out state))
                {
                    state.ApplyToBlock(result);
                    valid.Value = true;
                }

                type.InternalValue = value;
            };
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:47,代码来源:SceneryBlockFactory.cs

示例9: AttachEditorComponents

 public override void AttachEditorComponents(Entity result, Main main)
 {
     base.AttachEditorComponents(result, main);
     Model model = result.Get<Model>("Model");
     Model editorModel = result.Get<Model>("EditorModel");
     Property<bool> editorSelected = result.GetOrMakeProperty<bool>("EditorSelected", false);
     editorSelected.Serialize = false;
     editorModel.Add(new Binding<bool>(editorModel.Enabled, () => !editorSelected || !model.IsValid, editorSelected, model.IsValid));
 }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:9,代码来源:PropFactory.cs

示例10: Bind

        public override void Bind(Entity result, Main main, bool creating = false)
        {
            base.Bind(result, main, creating);
            result.CannotSuspendByDistance = true;

            ModelAlpha clouds = result.Get<ModelAlpha>("Clouds");

            Property<float> height = result.GetOrMakeProperty<float>("Height", true, 1.0f);
            result.Add(new Binding<float>(clouds.GetFloatParameter("Height"), height));

            Property<Vector2> velocity = result.GetOrMakeProperty<Vector2>("Velocity", true, Vector2.One);
            result.Add(new Binding<Vector2>(clouds.GetVector2Parameter("Velocity"), x => x * (1.0f / 60.0f), velocity));

            result.Add(new CommandBinding(main.ReloadedContent, delegate()
            {
                height.Reset();
                velocity.Reset();
            }));
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:19,代码来源:CloudFactory.cs

示例11: Bind

        public override void Bind(Entity result, Main main, bool creating = false)
        {
            Transform transform = result.Get<Transform>();
            SpotLight spotLight = result.Get<SpotLight>();

            if (result.GetOrMakeProperty<bool>("Attach", true))
                MapAttachable.MakeAttachable(result, main);

            this.SetMain(result, main);

            spotLight.Add(new TwoWayBinding<Vector3>(spotLight.Position, transform.Position));
            spotLight.Add(new TwoWayBinding<Quaternion>(spotLight.Orientation, transform.Quaternion));
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:13,代码来源:SpotLightFactory.cs

示例12: Bind

		public override void Bind(Entity result, Main main, bool creating = false)
		{
			this.InternalBind(result, main, creating, null, true);
			if (result.GetOrMakeProperty<bool>("Attached", true))
				MapAttachable.MakeAttachable(result, main);

			Property<Entity.Handle> target = result.GetOrMakeProperty<Entity.Handle>("Target");

			Map map = result.Get<Map>();

			Property<float> intervalMultiplier = result.GetOrMakeProperty<float>("IntervalMultiplier", true, 1.0f);

			ListProperty<CoordinateEntry> coords = result.GetOrMakeListProperty<CoordinateEntry>("Coordinates");

			Property<int> index = result.GetOrMakeProperty<int>("FillIndex");

			Action populateCoords = delegate()
			{
				if (coords.Count == 0)
				{
					Entity targetEntity = target.Value.Target;
					if (targetEntity != null && targetEntity.Active)
					{
						Map m = targetEntity.Get<Map>();
						foreach (CoordinateEntry e in map.Chunks.SelectMany(c => c.Boxes.SelectMany(x => x.GetCoords())).Select(delegate(Map.Coordinate y)
						{
							Map.Coordinate z = m.GetCoordinate(map.GetAbsolutePosition(y));
							z.Data = y.Data;
							return new CoordinateEntry { Coord = z, };
						}))
							coords.Add(e);
					}
				}
			};

			if (main.EditorEnabled)
				coords.Clear();
			else
				result.Add(new PostInitialization { populateCoords });

			Property<float> blockLifetime = result.GetOrMakeProperty<float>("BlockLifetime", true, 0.25f);

			float intervalTimer = 0.0f;
			Updater update = new Updater
			{
				delegate(float dt)
				{
					intervalTimer += dt;
					Entity targetEntity = target.Value.Target;
					if (targetEntity != null && targetEntity.Active && index < coords.Count)
					{
						float interval = 0.03f * intervalMultiplier;
						while (intervalTimer > interval && index < coords.Count)
						{
							EffectBlockFactory factory = Factory.Get<EffectBlockFactory>();
							Map m = targetEntity.Get<Map>();
							
							CoordinateEntry entry = coords[index];
							Entity block = factory.CreateAndBind(main);
							entry.Coord.Data.ApplyToEffectBlock(block.Get<ModelInstance>());
							block.GetProperty<bool>("CheckAdjacent").Value = false;
							block.GetProperty<Vector3>("Offset").Value = m.GetRelativePosition(entry.Coord);
							block.GetProperty<bool>("Scale").Value = true;

							block.GetProperty<Vector3>("StartPosition").Value = entry.Position + new Vector3(8.0f, 20.0f, 8.0f) * blockLifetime.Value;
							block.GetProperty<Matrix>("StartOrientation").Value = Matrix.CreateRotationX(0.15f * index) * Matrix.CreateRotationY(0.15f * index);

							block.GetProperty<float>("TotalLifetime").Value = blockLifetime;
							factory.Setup(block, targetEntity, entry.Coord, entry.Coord.Data.ID);
							main.Add(block);

							index.Value++;
							intervalTimer -= interval;
						}
					}
					else
						result.Delete.Execute();
				}
			};
			update.Enabled.Value = index > 0;
			result.Add("Update", update);

			Action fill = delegate()
			{
				if (index > 0 || update.Enabled)
					return; // We're already filling

				Entity targetEntity = target.Value.Target;
				if (targetEntity != null && targetEntity.Active)
				{
					populateCoords();
					Map m = targetEntity.Get<Map>();
					Vector3 focusPoint = main.Camera.Position;
					foreach (CoordinateEntry entry in coords)
					{
						entry.Position = m.GetAbsolutePosition(entry.Coord);
						entry.Distance = (focusPoint - entry.Position).LengthSquared();
					}

					List<CoordinateEntry> coordList = coords.ToList();
//.........这里部分代码省略.........
开发者ID:sparker,项目名称:Lemma,代码行数:101,代码来源:FillMapFactory.cs

示例13: AttachEditorComponents

		public override void AttachEditorComponents(Entity result, Main main)
		{
			base.AttachEditorComponents(result, main);

			MapAttachable.AttachEditorComponents(result, main, result.Get<Model>().Color);

			EntityConnectable.AttachEditorComponents(result, result.GetOrMakeProperty<Entity.Handle>("Target"));
		}
开发者ID:sparker,项目名称:Lemma,代码行数:8,代码来源:FillMapFactory.cs

示例14: Bind

        public override void Bind(Entity result, Main main, bool creating = false)
        {
            result.CannotSuspend = true;

            result.Add(new TwoWayBinding<string>(result.GetProperty<string>("LightRampTexture"), main.Renderer.LightRampTexture));
            result.Add(new TwoWayBinding<string>(result.GetOrMakeProperty<string>("EnvironmentMap", true, "Maps\\env0"), main.Renderer.EnvironmentMap));
            result.Add(new TwoWayBinding<Vector3>(result.GetOrMakeProperty<Vector3>("EnvironmentColor", true, Vector3.One), main.Renderer.EnvironmentColor));
            result.Add(new TwoWayBinding<Color>(result.GetProperty<Color>("BackgroundColor"), main.Renderer.BackgroundColor));
            result.Add(new TwoWayBinding<float>(result.GetProperty<float>("FarPlaneDistance"), main.Camera.FarPlaneDistance));

            WorldFactory.AddState(result.GetListProperty<Map.CellState>("AdditionalMaterials").ToArray());
            result.Add(new CommandBinding(result.Delete, delegate()
            {
                WorldFactory.RemoveState(result.GetListProperty<Map.CellState>("AdditionalMaterials").ToArray());
            }));

            // Zone management
            Zone currentZone = null;

            result.Add(new CommandBinding<Entity>(main.EntityAdded, delegate(Entity e)
            {
                if (!e.CannotSuspend)
                    processEntity(e, currentZone, getActiveBoundingBoxes(main.Camera, currentZone), main.Camera.Position, main.Camera.FarPlaneDistance);
            }));

            IEnumerable<NonAxisAlignedBoundingBox> boxes = getActiveBoundingBoxes(main.Camera, currentZone);
            Vector3 cameraPosition = main.Camera.Position;
            float suspendDistance = main.Camera.FarPlaneDistance;
            foreach (Entity e in main.Entities)
            {
                if (!e.CannotSuspend)
                    processEntity(e, currentZone, boxes, cameraPosition, suspendDistance);
            }

            result.Add("ProcessMap", new Command<Map>
            {
                Action = delegate(Map map)
                {
                    processMap(map, boxes);
                }
            });

            Property<float> reverbAmount = result.GetProperty<float>("ReverbAmount");
            Property<float> reverbSize = result.GetProperty<float>("ReverbSize");

            Sound.ReverbSettings(main, reverbAmount, reverbSize);

            Vector3 lastUpdatedCameraPosition = new Vector3(float.MinValue);
            bool lastFrameUpdated = false;

            Action<Zone> updateZones = delegate(Zone newZone)
            {
                currentZone = newZone;

                if (newZone != null)
                    Sound.ReverbSettings(main, newZone.ReverbAmount, newZone.ReverbSize);
                else
                    Sound.ReverbSettings(main, reverbAmount, reverbSize);

                boxes = getActiveBoundingBoxes(main.Camera, newZone);
                cameraPosition = main.Camera.Position;
                suspendDistance = main.Camera.FarPlaneDistance;
                foreach (Entity e in main.Entities)
                {
                    if (!e.CannotSuspend)
                        processEntity(e, newZone, boxes, cameraPosition, suspendDistance);
                }

                lastUpdatedCameraPosition = main.Camera.Position;
            };

            result.Add("UpdateZones", new Command
            {
                Action = delegate() { updateZones(Zone.Get(main.Camera.Position)); },
            });

            Updater update = new Updater
            {
                delegate(float dt)
                {
                    // Update every other frame
                    if (lastFrameUpdated)
                    {
                        lastFrameUpdated = false;
                        return;
                    }
                    lastFrameUpdated = true;

                    Zone newZone = Zone.Get(main.Camera.Position);

                    if (newZone != currentZone || (newZone == null && (main.Camera.Position - lastUpdatedCameraPosition).Length() > 10.0f))
                        updateZones(newZone);
                }
            };
            update.EnabledInEditMode.Value = true;
            result.Add(update);

            this.SetMain(result, main);
            WorldFactory.instance = result;
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:100,代码来源:WorldFactory.cs

示例15: Bind

        public override void Bind(Entity result, Main main, bool creating = false)
        {
            Property<float> maxForce = result.GetOrMakeProperty<float>("MaxForce", true, 150.0f);
            Property<float> damping = result.GetOrMakeProperty<float>("Damping", true, 1.5f);
            Property<float> stiffness = result.GetOrMakeProperty<float>("Stiffness", true, 15.0f);

            NoRotationJoint joint = null;
            EntityMover mover = null;

            Action setMaxForce = delegate()
            {
                if (mover != null)
                {
                    if (maxForce > 0.001f)
                        mover.LinearMotor.Settings.MaximumForce = maxForce * result.Get<DynamicMap>().PhysicsEntity.Mass;
                    else
                        mover.LinearMotor.Settings.MaximumForce = float.MaxValue;
                }
            };
            result.Add(new NotifyBinding(setMaxForce, maxForce));
            result.Add(new CommandBinding(result.Get<DynamicMap>().PhysicsUpdated, setMaxForce));

            Action setDamping = delegate()
            {
                if (mover != null && damping != 0)
                    mover.LinearMotor.Settings.Servo.SpringSettings.DampingConstant = damping;
            };
            result.Add(new NotifyBinding(setDamping, damping));

            Action setStiffness = delegate()
            {
                if (mover != null && stiffness != 0)
                    mover.LinearMotor.Settings.Servo.SpringSettings.StiffnessConstant = stiffness * result.Get<DynamicMap>().PhysicsEntity.Mass;
            };
            result.Add(new NotifyBinding(setStiffness, stiffness));
            result.Add(new CommandBinding(result.Get<DynamicMap>().PhysicsUpdated, setStiffness));

            Func<BEPUphysics.Entities.Entity, BEPUphysics.Entities.Entity, Vector3, Vector3, Vector3, ISpaceObject> createJoint = delegate(BEPUphysics.Entities.Entity entity1, BEPUphysics.Entities.Entity entity2, Vector3 pos, Vector3 direction, Vector3 anchor)
            {
                joint = new NoRotationJoint(entity1, entity2);
                if (mover != null && mover.Space != null)
                    main.Space.Remove(mover);
                mover = new EntityMover(entity1);
                main.Space.Add(mover);
                setMaxForce();
                setDamping();
                setStiffness();
                return joint;
            };

            JointFactory.Bind(result, main, createJoint, true, creating);

            result.Add(new CommandBinding(result.Get<DynamicMap>().OnSuspended, delegate()
            {
                if (mover != null && mover.Space != null)
                    main.Space.Remove(mover);
            }));

            result.Add(new CommandBinding(result.Get<DynamicMap>().OnResumed, delegate()
            {
                if (mover != null && mover.Space == null)
                    main.Space.Add(mover);
            }));

            result.Add(new CommandBinding(result.Delete, delegate()
            {
                if (mover != null && mover.Space != null)
                {
                    main.Space.Remove(mover);
                    mover = null;
                }
            }));

            Property<Entity.Handle> parent = result.GetOrMakeProperty<Entity.Handle>("Parent");
            Property<Map.Coordinate> coord = result.GetOrMakeProperty<Map.Coordinate>("Coord");
            Updater updater = null;
            updater = new Updater
            {
                delegate(float dt)
                {
                    Entity parentEntity = parent.Value.Target;
                    if (parentEntity != null && parentEntity.Active)
                        mover.TargetPosition = parentEntity.Get<Map>().GetAbsolutePosition(coord) + new Vector3(0, -0.01f, 0);
                    else
                    {
                        updater.Delete.Execute();
                        parent.Value = null;
                        if (mover != null && mover.Space != null)
                        {
                            main.Space.Remove(mover);
                            mover = null;
                        }
                    }
                }
            };
            result.Add(updater);
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:97,代码来源:FloaterFactory.cs


注:本文中的System.Entity.GetOrMakeProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。