public override void StartClientSide(ICoreClientAPI api) { this.capi = api; api.RegisterCommand("csc", ConstantsCore.ModPrefix + "Clear shapes cache", "", (int groupId, CmdArgs args) => { api.ObjectCache.RemoveAll((str, obj) => str.StartsWith(ConstantsCore.ModId)); }); // TODO Need move dialog to TPNetManager -.- api.RegisterCommand("tpdlg", ConstantsCore.ModPrefix + "Open teleport dialog", "", (int groupId, CmdArgs args) => { if (capi.World.Player.WorldData.CurrentGameMode != EnumGameMode.Creative) { return; } TPNetManager manager = api.ModLoader.GetModSystem <TPNetManager>(); GuiDialogTeleport dialog = new GuiDialogTeleport(capi, null); dialog.TryOpen(); }); }
private void OnGameTick(float dt) { if (animUtil?.animator?.ActiveAnimationCount == 0) { animUtil.StartAnimation(new AnimationMetaData() { Animation = "octagram", Code = "octagram", AnimationSpeed = 0.5f, EaseInSpeed = 1f, EaseOutSpeed = 1f }); animUtil.StartAnimation(new AnimationMetaData() { Animation = "gear", Code = "gear", AnimationSpeed = 0.25f, EaseInSpeed = 1f, EaseOutSpeed = 1f }); } if (!Active) { return; } toremove.Clear(); float bestSecondsPassed = 0; foreach (var val in tpingPlayers) { if (val.Value.State == EnumTeleportingEntityState.None) { if (Api.Side == EnumAppSide.Server) { IServerPlayer player = Api.World.PlayerByUid(val.Key) as IServerPlayer; TPNetManager.AddAvailableTeleport(player, Pos); } val.Value.State = EnumTeleportingEntityState.Teleporting; } val.Value.SecondsPassed += Math.Min(0.5f, dt); if (Api.World.ElapsedMilliseconds - val.Value.LastCollideMs > 300) { toremove.Add(val.Key); continue; } if (val.Value.SecondsPassed > 3 && val.Value.State == EnumTeleportingEntityState.Teleporting) { val.Value.State = EnumTeleportingEntityState.UI; if (Api.Side == EnumAppSide.Client && teleportDlg?.IsOpened() != true) { if (teleportDlg != null) { teleportDlg.Dispose(); } teleportDlg = new GuiDialogTeleport(Api as ICoreClientAPI, Pos); teleportDlg.TryOpen(); } } bestSecondsPassed = Math.Max(val.Value.SecondsPassed, bestSecondsPassed); } foreach (var playerUID in toremove) { tpingPlayers.Remove(playerUID); if (Api.Side == EnumAppSide.Client) { teleportDlg?.TryClose(); } } Active = tpingPlayers.Count > 0; if (Api.Side == EnumAppSide.Server) { for (int i = 0; i < 10; i++) { props.MinPos.Set(RandomParticleInCirclePos()); Api.World.SpawnParticles(props); } } if (Api.Side == EnumAppSide.Client) { bestSecondsPassed = Math.Min(bestSecondsPassed, 3); animUtil.activeAnimationsByAnimCode["octagram"].AnimationSpeed = (float)(0.5f * (1 + Math.Exp(bestSecondsPassed) * 0.3f)); } }