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); }
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"); 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"); VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main); attachable.Enabled.Value = true; this.SetMain(entity, main); VoxelAttachable.BindTarget(entity, trigger.Position); PointLight light = entity.GetOrCreate <PointLight>(); light.Add(new Binding <Vector3>(light.Position, trigger.Position)); light.Color.Value = new Vector3(1.0f, 0.5f, 1.7f); Property <float> lightBaseRadius = new Property <float> { Value = 10.0f }; Updater updater = new Updater ( delegate(float dt) { light.Attenuation.Value = lightBaseRadius.Value * (1.0f + (((float)this.random.NextDouble() - 0.5f) * 0.1f)); } ); updater.EnabledInEditMode = true; entity.Add(updater); SignalTower tower = entity.GetOrCreate <SignalTower>("SignalTower"); Animation enterAnimation = null; trigger.Add(new CommandBinding(trigger.PlayerEntered, delegate() { if (!string.IsNullOrEmpty(tower.Initial) && (enterAnimation == null || !enterAnimation.Active)) { enterAnimation = new Animation ( new Animation.FloatMoveTo(lightBaseRadius, 20.0f, 0.25f), new Animation.FloatMoveTo(lightBaseRadius, 10.0f, 0.5f) ); entity.Add(enterAnimation); } })); tower.Add(new CommandBinding(trigger.PlayerEntered, tower.PlayerEnteredRange)); tower.Add(new CommandBinding(trigger.PlayerExited, tower.PlayerExitedRange)); tower.Add(new Binding <Entity.Handle>(tower.Player, trigger.Player)); Sound.AttachTracker(entity, trigger.Position); 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); ParticleEmitter purpleEmitter = entity.GetOrCreate <ParticleEmitter>("PurpleEmitter"); purpleEmitter.Serialize = false; purpleEmitter.Add(new Binding <Vector3>(purpleEmitter.Position, trigger.Position)); purpleEmitter.ParticleType.Value = "Purple"; purpleEmitter.ParticlesPerSecond.Value = 30; purpleEmitter.Jitter.Value = new Vector3(0.5f); entity.Add("AttachOffset", attachable.Offset); trigger.EditorProperties(); entity.Add("Initial", tower.Initial); }