public static void WarpPlayerToTrain(Player player) { if (!SaveableEntityComponent.HaveAllEntitiesLoaded) { throw new HamstarException("OnARail.TrainEntityHandler.WarpPlayerToTrain - Entities not loaded."); } var myplayer = player.GetModPlayer <OnARailPlayer>(); if (myplayer.MyTrainWho == -1) { throw new HamstarException("OnARail.TrainEntityHandler.WarpPlayerToTrain - Player " + player.name + " (" + player.whoAmI + ") has no train."); } CustomEntity train_ent = CustomEntityManager.GetEntityByWho(myplayer.MyTrainWho); if (train_ent == null) { throw new HamstarException("OnARail.TrainEntityHandler.WarpPlayerToTrain - Player " + player.name + " (" + player.whoAmI + ") has no train entity."); } PlayerHelpers.Teleport(player, train_ent.Core.Center - new Vector2(player.width / 2, (player.height / 2) + 16)); int train_buff_id = OnARailMod.Instance.BuffType <TrainMountBuff>(); player.AddBuff(train_buff_id, 30); }
private void SetupClientOnConnect() { this.ClearChat(); SendClientMessage(Color.White, "SERWER: Witaj {0} na serwerze Mrucznik RolePlay!", Name); if (PlayerHelpers.IsNameFormatCorrect(Name) == false) { SendClientMessage(Color.Red, "SERWER: Twój nick jest niepoprawny! Nick musi posiadać formę: Imię_Nazwisko!"); Kick(); } ToggleClock(true); var sounds = new[] { 1187, 171, 176, 1076, 1187, 157, 162, 169, 178, 180, 181, 147, 140 }; PlaySound(sounds[new Random().Next(sounds.Length)]); Task.Delay(1000).ContinueWith(t => { if (!IsConnected) { return; } Position = new Vector3(-2819.9297f, 1134.0607f, 26.0766f); Angle = 326.0f; CameraPosition = new Vector3(-2801.6691f, 1151.7545f, 31.5482f); SetCameraLookAt(new Vector3(-2819.05078f, 1141.4909f, 23.3147f)); }); ShowAuthFlow(); }
public static Entity GetLocalSimPlayerEntity(ExternalSimWorldAccessor simulationWorld) { if (PlayerRepertoireSystem.Instance == null) { return(Entity.Null); } return(PlayerHelpers.GetSimPlayerFromPlayer(PlayerRepertoireSystem.Instance.GetLocalPlayerInfo(), simulationWorld)); }
protected override void ReceiveOnClient() { Player player = Main.player[this.PlayerWho]; if (player == null || !player.active) { LogHelpers.Log("ModHelpers.PlayerPermaDeathProtocol.ReceiveWithClient - Inactive player indexed as " + this.PlayerWho); return; } PlayerHelpers.ApplyPermaDeath(player, this.Msg); }
protected virtual void Teleport(Player player, Vector2 dest) { var mymod = WormholesMod.Instance; WormholesPlayer myplayer = player.GetModPlayer <WormholesPlayer>(mymod); if (myplayer.MyPortal == null || (myplayer.MyPortal != null && this.ID != myplayer.MyPortal.ID)) { myplayer.ChartedLinks.Add(this.ID); } PlayerHelpers.Teleport(player, dest); if (player.FindBuffIndex(88) != -1) { int def = player.statDefense; player.statDefense = 0; var dmg = player.Hurt(PlayerDeathReason.ByOther(13), player.statLifeMax2 / 7, 0); player.statDefense = def; } player.AddBuff(164, (int)(60f * 2.5f)); // Distorted player.AddBuff(88, 60 * 10); // Chaos State float vel_x = player.velocity.X * 3; float vel_y = player.velocity.Y * 3; if (vel_x > 0 && vel_x < 1) { vel_x = 1; } else if (vel_x < 0 && vel_x > 1) { vel_x = -1; } if (vel_y > 0 && vel_y < 1) { vel_y = 1; } else if (vel_y < 0 && vel_y > 1) { vel_y = -1; } for (int i = 0; i < 24; i++) { Dust.NewDust(player.position, player.width, player.height, 245, vel_x, vel_y); } //Main.PlaySound( 2, player.position, 100 ); var snd = SoundID.Item100.WithVolume(mymod.Config.WormholeEntrySoundVolume); Main.PlaySound(snd, player.position); }
private void UpdateTrainWarp() { if (Vector2.Distance(this.player.position, PlayerHelpers.GetSpawnPoint(this.player)) <= 8) // is at spawn { if (Vector2.Distance(this.player.position, this.PrevPosition) > 16 * 4) // is 4+ blocks away since prev tick { this.HandleRecall(); } } this.PrevPosition = this.player.position; }
public override void PreUpdate() { var mymod = (InjuryMod)this.mod; if (!mymod.Config.Enabled) { return; } this.Logic.UpdateBleeding(this.player); // Fall impact staggering if (this.player.velocity.Y == 0f) { int dmg = PlayerHelpers.ComputeImpendingFallDamage(this.player); if (dmg != 0) { this.player.AddBuff(mod.BuffType("ImpactTrauma"), (int)((float)dmg * mymod.Config.FallLimpDurationMultiplier)); } } this.Logic.UpdateHarm(this.player); this.Logic.UpdateTemporaryHealth(this.player); if (this.HeartstringsEffectDuration > 0) { this.HeartstringsEffectDuration--; } if (this.LifeVestPresence > 0) { this.LifeVestPresence--; } if (mymod.Config.InjuryOnDeath) { if (!this.AmDead) { if (player.dead) { this.AmDead = true; float harmBufferPercent = this.Logic.ComputeHarmBufferPercent(this.player); float harm = this.Logic.ComputeHarmBufferCapacity(player) * (1f - harmBufferPercent); this.Logic.AfflictHarm(this.player, harm + 0.001f); } } else if (!player.dead) { this.AmDead = false; } } }
public static Entity GetLocalSimPawnEntity(ExternalSimWorldAccessor simulationWorld) { Entity localPlayerEntity = PlayerHelpers.GetLocalSimPlayerEntity(simulationWorld); // player is controlling an entity if (localPlayerEntity != Entity.Null && simulationWorld.TryGetComponent(localPlayerEntity, out ControlledEntity controlledEntity)) { // entity still exists and is controllable if (simulationWorld.Exists(controlledEntity.Value) && simulationWorld.HasComponent <Controllable>(controlledEntity.Value)) { return(controlledEntity.Value); } } return(Entity.Null); }
//////////////// private void ResetPlayer(Player replayer) { PlayerHelpers.FullVanillaReset(replayer); PlayerModHelpers.ModdedExtensionsReset(replayer, new HashSet <string>() { "Rewards" }); if (Main.netMode == 0) { this.BeginSessionForPlayer(replayer); this.RefundRewardsSpendings(replayer); } else if (Main.netMode == 1) { PlayerResetConfirmProtocol.QuickRequest(); } }
private void HandleRecall() { CustomEntity ent = CustomEntityManager.GetEntityByWho(this.MyTrainWho); var train_comp = ent.GetComponentByType <TrainBehaviorEntityComponent>(); if (train_comp.IsMountedBy != -1) { PlayerHelpers.Teleport(this.player, this.PrevPosition); // return to train's last position } else { if (((OnARailMod)this.mod).Config.DebugModeInfo) { Main.NewText("Warping to train..."); } TrainEntity.WarpPlayerToTrain(player); // return to train } }
private void UpdatePlayerState() { if (this.player.dead) { return; } this.IsInInitLockdown = !LoadHelpers.IsWorldSafelyBeingPlayed(); if (this.IsInInitLockdown) { PlayerHelpers.LockdownPlayerPerTick(this.player); } var args = new PlayerPromiseArguments { Who = this.player.whoAmI }; Promises.TriggerValidatedPromise(OnARailPlayer.PlayerFuncsValidator, OnARailPlayer.MyValidatorKey, args); }
private void DrawLocationInfo(SpriteBatch b) { var yPos = _inventory.yPositionOnScreen + _inventory.height + GenericHeightSpacing; var text = $"Location: {LocationHelper.GetFriendlyLocationName(Player.currentLocation.Name)} "; if (PlayerHelpers.IsPlayerOffline(PlayerId)) { text = "(Offline)"; } var font = Game1.smallFont; var textWidth = font.MeasureString(text).X; var xPos = _inventory.xPositionOnScreen + (_inventory.width * 3 / 4) - (textWidth / 2); _locationPos = new Vector2(xPos, yPos); b.DrawString(font, text, _locationPos, Color.Black); }