public override void Added(Scene scene) { base.Added(scene); if ((scene as Level).Session.GetFlag("DoNotTalk" + id)) { return; } // Determine the talker bounds and coordinates based on the first animation frame. float width = 0; float height = 0; if (textures != null && textures.Count > 0) { width = textures[0].Width * scale.X; height = textures[0].Height * scale.Y; } Add(Talker = new TalkComponent( new Rectangle(-(int)width / 2 - 48, (int)-height - 16, (int)width + 96, (int)height + 32), new Vector2(-0.5f + indicatorOffset.X, -height / 2 + indicatorOffset.Y), OnTalk )); }
public ScreenTerminal(MinigameModeScreen parent, Vector2 position) : base(position) { this.parent = parent; Depth = -8500; TalkComponent talk = new TalkComponent(new Rectangle(-24, -8, 48, 8), new Vector2(-0.5f, -20f), Interact); talk.PlayerMustBeFacing = false; Add(talk); }
private static void TalkComponent_Update(ILContext il) { ILCursor cursor = new ILCursor(il); while (cursor.TryGotoNext(MoveType.After, instr => instr.MatchStloc(1))) { Logger.Log($"{PandorasBoxMod.LoggerTag}/TalkComponent", $"Patching talk component at {cursor.Index} in CIL code for {cursor.Method.FullName}"); // this cursor.Emit(OpCodes.Ldarg, 0); // flag, the current value we are overriding cursor.Emit(OpCodes.Ldloc, 1); // this.disableDelay cursor.Emit(OpCodes.Ldarg, 0); cursor.Emit(OpCodes.Ldfld, typeof(TalkComponent).GetField("disableDelay", BindingFlags.Instance | BindingFlags.NonPublic)); cursor.EmitDelegate <Func <Object, bool, float, bool> >((talkerObject, current, disableDelay) => { TalkComponent talker = talkerObject as TalkComponent; List <Entity> players = talker.Scene.Tracker.GetEntities <Player>(); if (players.Count == 1) { return(current); } // Check based on vanilla version, except across all player entities if (disableDelay >= 0.05f) { return(false); } foreach (Player player in players) { if (player.CollideRect(new Rectangle((int)(talker.Entity.X + talker.Bounds.X), (int)(talker.Entity.Y + talker.Bounds.Y), talker.Bounds.Width, talker.Bounds.Height)) && player.OnGround() && player.Bottom < talker.Entity.Y + talker.Bounds.Bottom + 4f && player.StateMachine.State == 0 && (!talker.PlayerMustBeFacing || Math.Abs(player.X - talker.Entity.X) <= talker.Bounds.Width || player.Facing == (Facings)Math.Sign(talker.Entity.X - player.X)) && (TalkComponent.PlayerOver == null || TalkComponent.PlayerOver == talker)) { return(true); } } return(false); }); cursor.Emit(OpCodes.Stloc, 1); } }
public JournalTrigger(EntityData data, Vector2 offset) : base(data, offset) { levelset = data.Attr("levelset"); Add(talkComponent = new TalkComponent( new Rectangle(0, 0, data.Width, data.Height), data.Nodes.Length != 0 ? (data.Nodes[0] - data.Position) : new Vector2(data.Width / 2f, data.Height / 2f), player => InGameOverworldHelper.OpenJournal(player, levelset) ) { PlayerMustBeFacing = false }); }
public DrivableCar(EntityData data, Vector2 offset) : base(data.Position + offset) { // TODO - Fix this, needs a entity per depthed image this.Depth = 1; this.Add(this.bodySprite = new Monocle.Image(GFX.Game["scenery/car/body"])); this.bodySprite.Origin = new Vector2(this.bodySprite.Width / 2f, this.bodySprite.Height); this.Depth = 3; this.Add(this.wheelsSprite = new Monocle.Image(GFX.Game["scenery/car/wheels"])); this.wheelsSprite.Origin = new Vector2(this.wheelsSprite.Width / 2f, this.wheelsSprite.Height); base.Add(new PlayerCollider(new Action <Player>(this.OnPlayer))); this.Collider = new Hitbox(40, 18, -20, -18); this.Add(talker = new TalkComponent(new Rectangle(-8, -8, 16, 16), new Vector2(0.0f, -24f), this.OnTalk, null)); this.talker.Enabled = false; this.acceleration = float.Parse(data.Attr("acceleration", "256")); this.deceleration = float.Parse(data.Attr("deceleration", "384")); this.maxSpeed = float.Parse(data.Attr("maxSpeed", "384")); this.brokenDoor = bool.Parse(data.Attr("brokenDoor", "false")); this.keepCarSpeedOnExit = bool.Parse(data.Attr("keepCarSpeedOnExit", "false")); this.nitroAcceleration = float.Parse(data.Attr("nitroAcceleration", "448")); this.nitroMaxDuration = float.Parse(data.Attr("nitroMaxDuration", "3")); this.nitroRegenMultiplier = float.Parse(data.Attr("nitroRegenMultiplier", "0.2")); this.nitroDuration = this.nitroMaxDuration; this.nitroActive = false; this.breakingDuration = 0; this.facing = int.Parse(data.Attr("facing", "1")); this.onCollideH = new Collision(this.OnCollideH); this.onCollideV = new Collision(this.OnCollideV); this.prevLiftSpeed = Vector2.Zero; this.exhaustAcc = 0.0; this.springGrace = 0.3; this.enterGrace = 0.5; this.id = data.ID; this.AddTag(Tags.TransitionUpdate); }
public ChapterPanelTrigger(EntityData data, Vector2 offset) : base(data, offset) { map = data.Attr("map"); returnToLobbyMode = data.Enum("returnToLobbyMode", ReturnToLobbyMode.SetReturnToHere); savingAllowed = data.Bool("allowSaving", defaultValue: true); Add(talkComponent = new TalkComponent( new Rectangle(0, 0, data.Width, data.Height), data.Nodes.Length != 0 ? (data.Nodes[0] - data.Position) : new Vector2(data.Width / 2f, data.Height / 2f), player => InGameOverworldHelper.OpenChapterPanel(player, map, returnToLobbyMode, savingAllowed) ) { PlayerMustBeFacing = false }); }
public LuaTalker(EntityData data, Vector2 offset) : base(data.Position + offset) { this.data = data; onlyOnce = data.Bool("onlyOnce", true); filename = data.Attr("filename", ""); argumentsString = data.Attr("arguments", ""); unskippable = data.Bool("unskippable", false); wasSkipped = false; Add(talker = new TalkComponent(new Rectangle(0, 0, data.Width, data.Height), data.Nodes.First() + offset - Position, onTalk) { Enabled = true, PlayerMustBeFacing = false }); }
public JournalTrigger(EntityData data, Vector2 offset) : base(data, offset) { levelset = data.Attr("levelset"); Add(talkComponent = new TalkComponent( new Rectangle(0, 0, data.Width, data.Height), data.Nodes.Length != 0 ? (data.Nodes[0] - data.Position) : new Vector2(data.Width / 2f, data.Height / 2f), player => { showOnlyDiscovered = data.Bool("showOnlyDiscovered", defaultValue: false); vanillaJournal = data.Bool("vanillaJournal", defaultValue: false); InGameOverworldHelper.OpenJournal(player, levelset); } ) { PlayerMustBeFacing = false }); }
public Lever(EntityData data, Vector2 offset) : base(data.Position + offset) { Add((Component)(sprite = new Sprite(GFX.Game, "objects/pandorasBox/lever/lever"))); sprite.AddLoop("lever", "", 0.125f); sprite.JustifyOrigin(0.5f, 1f); sprite.Play("lever"); sprite.OnLastFrame = onLastFrame; sprite.Stop(); active = data.Bool("active", false); flag = data.Attr("flag", ""); id = data.ID; Collider = new Hitbox(sprite.Width, sprite.Height, -sprite.Width / 2, -sprite.Height); Add(talker = new TalkComponent(new Rectangle((int)(-sprite.Width / 2 - 2), -4, (int)(sprite.Width + 4), 4), new Vector2(0.0f, -18f), onTalk)); talker.Enabled = true; }
public NoOverlayLookout(EntityData data, Vector2 offset) : base(data.Position + offset) { Depth = Depths.Above; Add(talk = new TalkComponent(new Rectangle(-24, -8, 48, 8), new Vector2(-0.5f, -20f), Interact) { PlayerMustBeFacing = false, }); summit = data.Bool("summit"); onlyY = data.Bool("onlyY"); Collider = new Hitbox(4f, 4f, -2f, -4f); VertexLight vertexLight = new VertexLight(new Vector2(-1f, -11f), Color.White, 0.8f, 16, 24); Add(vertexLight); lightTween = vertexLight.CreatePulseTween(); Add(lightTween); Add(sprite = GFX.SpriteBank.Create("lookout")); sprite.OnFrameChange = delegate(string s) { switch (s) { case "idle": case "badeline_idle": case "nobackpack_idle": if (sprite.CurrentAnimationFrame == sprite.CurrentAnimationTotalFrames - 1) { lightTween.Start(); } break; } }; Vector2[] array = data.NodesOffset(offset); if (array != null && array.Length != 0) { nodes = new List <Vector2>(array); } }
public PandorasBox(EntityData data, Vector2 offset) : base(data.Position + offset) { Add(talker = new TalkComponent(new Rectangle(-8, -8, 16, 16), new Vector2(0.0f, -24f), onTalk)); talker.Enabled = true; canTalk = true; Add((Component)(boxOpen = new Sprite(GFX.Game, "objects/pandorasBox/pandorasBox/box_open"))); boxOpen.AddLoop("box_open", "", 0.25f); boxOpen.JustifyOrigin(0.5f, 1f); boxOpen.Visible = false; boxOpen.Stop(); Add((Component)(boxIdle = new Sprite(GFX.Game, "objects/pandorasBox/pandorasBox/box_idle"))); boxIdle.AddLoop("box_idle", "", 0.1f); boxIdle.Play("box_idle"); boxIdle.JustifyOrigin(0.5f, 1f); completeChapter = Boolean.Parse(data.Attr("completeChapter", "false")); dialogId = data.Attr("dialog", ""); Depth = 5; }
public FindTheoPhone(EntityData data, Vector2 offset, EntityID id) : base(offset + data.Position) { this.Add(this.Talker = new TalkComponent(new Rectangle(-12, -8, 24, 8), new Vector2(99999, 99999), this.OnTalk)); this.ID = id; }