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); }
public override void Bind(Entity entity, Main main, bool creating = false) { Transform transform = entity.GetOrCreate <Transform>("Transform"); ParticleEmitter emitter = entity.GetOrCreate <ParticleEmitter>("ParticleEmitter"); VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main); this.SetMain(entity, main); attachable.EditorProperties(); emitter.Add(new Binding <Vector3>(emitter.Position, transform.Position)); emitter.EditorProperties(); entity.Add("Enabled", emitter.Enabled); entity.Add("Enable", emitter.Enable); entity.Add("Disable", emitter.Disable); entity.Add("Burst", new Command { Action = delegate() { entity.Add(new Animation ( new Animation.Execute(emitter.Enable), new Animation.Delay(0.3f), new Animation.Execute(emitter.Disable) )); } }); }
public override void Bind(Entity entity, Main main, bool creating = false) { Transform transform = entity.GetOrCreate <Transform>("Transform"); entity.CannotSuspendByDistance = true; PlayerTrigger trigger = entity.GetOrCreate <PlayerTrigger>("Trigger"); PlayerSpawn spawn = entity.GetOrCreate <PlayerSpawn>("PlayerSpawn"); VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main); this.SetMain(entity, main); attachable.EditorProperties(); if (main.EditorEnabled) { entity.Add("Spawn Here", new Command { Action = delegate() { main.Spawner.StartSpawnPointGUID.Value = entity.GUID; Action go = delegate() { main.EditorEnabled.Value = false; IO.MapLoader.Load(main, main.MapFile); }; Editor editor = main.Get("Editor").First().Get <Editor>(); if (editor.NeedsSave) { editor.SaveWithCallback(go); } else { go(); } }, }, Command.Perms.Executable); } spawn.Add(new TwoWayBinding <Vector3>(transform.Position, spawn.Position)); spawn.Add(new Binding <float, Quaternion>(spawn.Rotation, delegate(Quaternion value) { Vector3 x = Vector3.Transform(Vector3.Forward, value); return(((float)Math.PI * -0.5f) - (float)Math.Atan2(x.Z, x.X)); }, transform.Quaternion)); spawn.EditorProperties(); trigger.Enabled.Value = true; trigger.Add(new TwoWayBinding <Vector3>(transform.Position, trigger.Position)); trigger.Add(new CommandBinding(trigger.PlayerEntered, spawn.Activate)); trigger.EditorProperties(); }
public override void Bind(Entity entity, Main main, bool creating = false) { Transform transform = entity.GetOrCreate <Transform>("Transform"); PlayerTrigger trigger = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger"); trigger.Serialize = false; VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main); Collectible collectible = entity.GetOrCreate <Collectible>("Collectible"); trigger.Radius.Value = 3; trigger.Add(new Binding <Vector3>(trigger.Position, transform.Position)); trigger.Add(new Binding <bool>(trigger.Enabled, x => !x, collectible.PickedUp)); collectible.Add(new CommandBinding(trigger.PlayerEntered, collectible.PlayerTouched)); Sound.AttachTracker(entity, trigger.Position); PointLight light = entity.Create <PointLight>(); light.Serialize = false; light.Attenuation.Value = 10.0f; light.Color.Value = new Vector3(1.25f, 1.75f, 2.0f); light.Add(new Binding <Vector3>(light.Position, transform.Position)); light.Add(new Binding <bool>(light.Enabled, x => !x, collectible.PickedUp)); ParticleEmitter distortionEmitter = entity.GetOrCreate <ParticleEmitter>("DistortionEmitter"); distortionEmitter.Serialize = false; distortionEmitter.Add(new Binding <Vector3>(distortionEmitter.Position, trigger.Position)); distortionEmitter.ParticleType.Value = "Distortion"; distortionEmitter.ParticlesPerSecond.Value = 4; distortionEmitter.Jitter.Value = new Vector3(0.5f); distortionEmitter.Add(new Binding <bool>(distortionEmitter.Enabled, x => !x, collectible.PickedUp)); Model model = entity.GetOrCreate <Model>("Model"); model.Filename.Value = "Models\\sphere"; model.Serialize = false; model.Scale.Value = new Vector3(0.5f); model.Add(new Binding <Matrix>(model.Transform, transform.Matrix)); model.Add(new Binding <bool>(model.Enabled, x => !x, collectible.PickedUp)); this.SetMain(entity, main); attachable.EditorProperties(); entity.Add("Collected", collectible.PlayerTouched); }
public override void Bind(Entity entity, Main main, bool creating = false) { Transform transform = entity.GetOrCreate <Transform>("Transform"); this.positions.Add(transform.Position); transform.Add(new CommandBinding(transform.Delete, delegate() { this.positions.Remove(transform.Position); })); entity.CannotSuspendByDistance = true; VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main); this.SetMain(entity, main); transform.EditorProperties(); attachable.EditorProperties(); entity.Add(new Updater ( delegate(float dt) { Entity player = PlayerFactory.Instance; if (player != null && player.Active) { Player p = player.Get <Player>(); float y = p.Character.Transform.Value.Translation.Y; float limit = transform.Position.Value.Y; if (y < limit + absoluteLimit || (y < limit && p.Character.LinearVelocity.Value.Y < velocityThreshold)) { p.Die.Execute(); } } else { player = null; } } )); }
public override void Bind(Entity entity, Main main, bool creating = false) { Transform transform = entity.GetOrCreate <Transform>("Transform"); PlayerTrigger trigger = entity.GetOrCreate <PlayerTrigger>(); Model model = entity.GetOrCreate <Model>("Model"); VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main); this.SetMain(entity, main); model.Serialize = false; model.Filename.Value = "Models\\papers"; model.Add(new Binding <Matrix>(model.Transform, transform.Matrix)); Note note = entity.GetOrCreate <Note>("Note"); trigger.Serialize = false; trigger.Add(new Binding <Vector3>(trigger.Position, transform.Position)); trigger.Radius.Value = 3.5f; trigger.Add(new CommandBinding(trigger.PlayerEntered, delegate() { PlayerFactory.Instance.Get <Player>().Note.Value = entity; })); trigger.Add(new CommandBinding(trigger.PlayerExited, delegate() { if (PlayerFactory.Instance != null) { PlayerFactory.Instance.Get <Player>().Note.Value = null; } })); entity.Add("Collected", note.Collected); entity.Add("Text", note.Text); entity.Add("Image", note.Image, new PropertyEntry.EditorData { Options = FileFilter.Get(main, main.Content.RootDirectory, new[] { "Images", Path.Combine(MapLoader.MapDirectory, "Images") }), }); attachable.EditorProperties(); }