public void PlayerDisconnected(int Id) { Console.Log($"Player '{Id}' disconnected"); if (Players.ContainsKey(Id)) //May be disconnecting from a client which did not fully connect { Players[Id].Plr.MatchSome( (Plr) => Plr.QueueFree() ); Players.Remove(Id); } if (Nicknames.ContainsKey(Id)) { Nicknames.Remove(Id); Game.PossessedPlayer.MatchSome( (Plr) => Plr.HUDInstance.RemoveNickLabel(Id) ); } World.ChunkLoadDistances.Remove(Id); World.RemoteLoadedChunks.Remove(Id); }
public override void DropData(Vector2 Pos, object Data) { Game.PossessedPlayer.MatchSome( (Plr) => { if (Data is int FromSlot && From != null) { Game.PossessedPlayer.MatchSome( (Plr) => { if (Plr.Inventory[FromSlot] != null) { Plr.SfxManager.FpThrow(); Plr.SetCooldown(0, Player.SlotSwitchCooldown, false); Vector3 Vel = Plr.CalcThrowVelocity(); Entities.ThrowSlotFromAt(Plr, FromSlot, From.CountMode, Plr.Cam.GlobalTransform.origin, Vel); } } ); } } ); }
public override void _PhysicsProcess(float Delta) { if (Frozen) { return; } if (Possessed && !Dying && Health <= 0) { Entities.Self.PleaseDestroyMe(Name); Dying = true; } if (Dying) { return; } var OriginalChunkTuple = World.GetChunkTuple(Translation); if (Net.Work.IsNetworkServer()) { List <DroppedItem> ToPickUpList = new List <DroppedItem>(); foreach (DroppedItem Item in World.ItemList) { if (Translation.DistanceTo(Item.Translation) <= ItemPickupDistance && Item.Life >= DroppedItem.MinPickupLife) { PhysicsDirectSpaceState State = GetWorld().DirectSpaceState; Godot.Collections.Dictionary Results = State.IntersectRay(Translation, Item.Translation, new Godot.Collections.Array { this }, 4); if (Results.Count <= 0) { ToPickUpList.Add(Item); } } } if (ToPickUpList.Count > 0) { foreach (DroppedItem Item in ToPickUpList) { Net.Players[Id].Plr.MatchSome( (Plr) => { var Instance = new Items.Instance(Item.Type); Option <int[]> Slots = Plr.ItemGive(Instance); //TODO: Grab ungiven count from Instance to only pick up part of stack //Dropped items currently are only one item though Slots.MatchSome( (ActualSlots) => { Plr.NotifyPickedUpItem(); Entities.SendDestroy(Item.Name); Item.Destroy(); } ); } ); } } Entities.AsServerMaybePhaseOut(this); } if (!Possessed) { return; } CurrentCooldown = Clamp(CurrentCooldown + (100 * Delta), 0, CurrentMaxCooldown); if (JumpAxis > 0 && OnFloor && !Ads) { Momentum.y = JumpStartForce; IsJumping = true; } if (!OnFloor && !FlyMode) { Momentum.y = Clamp(Momentum.y - Gravity * Delta, -MaxVerticalSpeed, MaxVerticalSpeed); } if (FlyMode && JumpAxis <= 0 && !IsCrouching) { //In flymode and jump is not being held if (Momentum.y > 0) { Momentum.y = Mathf.Clamp(Momentum.y - FlyFriction * Delta, 0, MaxVerticalSpeed); } else if (Momentum.y < 0) { Momentum.y = Mathf.Clamp(Momentum.y + FlyFriction * Delta, -MaxVerticalSpeed, 0); } } if (OnFloor && !WasOnFloor && Abs(LastMomentumY) > SfxMinLandMomentumY) { float Volume = Abs(Clamp(LastMomentumY, -MaxVerticalSpeed, 0)) / 4 - 30; SfxManager.FpLand(Volume); } WasOnFloor = OnFloor; if (!IsJumping && (OnFloor || FlyMode)) { float SpeedLimit = MovementSpeed * GetAdsMovementMultiplyer(); if (FlyMode && IsFlySprinting) { SpeedLimit *= FlySprintMultiplier; } else if (IsCrouching) { SpeedLimit = (MovementSpeed * GetAdsMovementMultiplyer()) / CrouchMovementDivisor; } float X = 0, Z = 0; if (RightAxis > 0) { X = -RightSens; } else if (RightAxis < 0) { X = LeftSens; } if (ForwardAxis > 0) { Z = ForwardSens; } else if (ForwardAxis < 0) { Z = -BackwardSens; } float Speed = Momentum.Flattened().Length(); if (Speed > 0) { if (FlyMode) { Speed = Clamp(Speed - FlyFriction * Delta, 0, Speed); } else if (IsCrouching && Speed > SpeedLimit) { Speed = Clamp(Speed - (Friction / SlideFrictionDivisor) * Delta, 0, Speed); } else { Speed = Clamp(Speed - Friction * Delta, 0, Speed); } Vector3 HorzMomentum = Momentum.Flattened().Normalized() * Speed; Momentum.x = HorzMomentum.x; Momentum.z = HorzMomentum.z; } { Vector3 WishDir = ClampVec3(new Vector3(X, 0, Z), 0, 1) * SpeedLimit; WishDir = WishDir.Rotated(new Vector3(0, 1, 0), Deg2Rad(LookHorizontal)); float Multiplier = Clamp(SpeedLimit - Momentum.Flattened().Length(), 0, SpeedLimit) / SpeedLimit; WishDir *= Multiplier; Momentum.x += WishDir.x; Momentum.z += WishDir.z; } } else { float X = 0, Z = 0; if (RightAxis > 0) { X = -RightSens; } else if (RightAxis < 0) { X = LeftSens; } if (ForwardAxis > 0) { Z = ForwardSens; } else if (ForwardAxis < 0) { Z = -BackwardSens; } Vector3 WishDir = new Vector3(X, 0, Z); WishDir = WishDir.Rotated(new Vector3(0, 1, 0), Deg2Rad(LookHorizontal)); Momentum = AirAccelerate(Momentum, WishDir, Delta); } LastMomentumY = Momentum.y; if (FlyMode) { Move( Momentum.Flattened() .Rotated(new Vector3(0, 1, 0), Deg2Rad(LoopRotation(-LookHorizontal))) .Rotated(new Vector3(1, 0, 0), Deg2Rad(LoopRotation(-ActualLookVertical))) .Rotated(new Vector3(0, 1, 0), Deg2Rad(LoopRotation(LookHorizontal))), Delta, 1, 60f, 0f ); Move( new Vector3(0, Momentum.y, 0) .Rotated(new Vector3(0, 1, 0), Deg2Rad(LoopRotation(LookHorizontal))), Delta, 1, 60f, 0f ); } else { Momentum = Move(Momentum, Delta, 1, 60f, MovementSpeed); } if (CrouchAxis == 0) { PhysicsDirectSpaceState State = GetWorld().DirectSpaceState; Godot.Collections.Dictionary DownResults = State.IntersectRay(Translation, Translation - new Vector3(0, RequiredUncrouchHeight, 0), new Godot.Collections.Array { this }, 1); Godot.Collections.Dictionary UpResults = State.IntersectRay(Translation, Translation + new Vector3(0, RequiredUncrouchHeight, 0), new Godot.Collections.Array { this }, 1); bool UnCrouch = false; if (UpResults.Count == 0) { UnCrouch = true; } else if (UpResults.Count > 0 && DownResults.Count == 0) { UnCrouch = true; } else if (UpResults.Count > 0 && DownResults.Count > 0) { float UpY = ((Vector3)UpResults["position"]).y; float DownY = ((Vector3)DownResults["position"]).y; if (UpY - DownY >= RequiredUncrouchHeight) { UnCrouch = true; } } if (UnCrouch) { IsCrouching = false; TickUncrouch(Delta); } else { TickCrouch(Delta); } } else if (IsCrouching) { TickCrouch(Delta); } Entities.MovedTick(this, OriginalChunkTuple); { Items.ID ItemId; if (Inventory[InventorySlot] != null) { ItemId = Inventory[InventorySlot].Id; } else { ItemId = Items.ID.ERROR; } Entities.ClientSendUpdate( Name, this.Transform, ActualLookVertical, IsJumping, IsCrouching, Health, ItemId, Momentum.Rotated(new Vector3(0, 1, 0), Deg2Rad(LoopRotation(-LookHorizontal))).z ); } if (!World.GetChunkTuple(Translation).Equals(DepreciatedCurrentChunk)) { DepreciatedCurrentChunk = World.GetChunkTuple(Translation); World.UnloadAndRequestChunks(Translation, Game.ChunkRenderDistance); } }
public void Annoy() { GeneralUtils.SendNotification(Plr.GetAPIUser().id, ApiNotification.NotificationType.Invite, "wha memes?", null, null, null); ConsoleUtils.Success($"Successfully annoyed User: {Plr.GetAPIUser().displayName}."); }
public void HandleEvent(Objective_Type Type, uint Entry, int Count) { if (Stage == null) { return; } foreach (PQuestObjective Objective in Stage.Objectives) { if (Objective.IsDone()) { continue; } if (Objective.Objective.Type != (int)Type) { continue; } bool CanAdd = false; int NewCount = Objective.Count; if (Type == Objective_Type.QUEST_SPEACK_TO || Type == Objective_Type.QUEST_KILL_MOB || Type == Objective_Type.QUEST_PROTECT_UNIT) { if (Objective.Objective.Creature != null && Entry == Objective.Objective.Creature.Entry) { CanAdd = true; NewCount += Count; } } else if (Type == Objective_Type.QUEST_USE_GO) { if (Objective.Objective.GameObject != null && Entry == Objective.Objective.GameObject.Entry) { CanAdd = true; NewCount += Count; } } else if (Type == Objective_Type.QUEST_UNKNOWN) { if (Objective.Objective.Guid == Entry) { CanAdd = true; NewCount += Count; } } if (CanAdd) { Objective.Count = NewCount; foreach (Player Plr in Players) { //PQ UPDATE KILLS PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_UPDATE); Out.WriteUInt32(Info.Entry); Out.WriteByte((byte)Plr.Realm); Out.WriteByte(Info.Type); Out.WriteUInt32(Objective.Objective.Guid); //(0x000002F3); Out.WriteByte((byte)Objective.Objective.Dotupdater); // some kind of reset ?// 1= update 2nd counter dot Out.WriteUInt16((ushort)Objective.Count); // kill counter DispatchPacket(Out, true); // SENDS THE 100 INFLUNCE ? Out = new PacketOut((byte)Opcodes.F_INFLUENCE_UPDATE); Out.WriteUInt16((ushort)48); //AreaInfluence);// 48 info.infuluce id table player influnce id Out.WriteUInt16(0); Out.WriteUInt32(0x00000064); //(Info.infuluce);// 64 =100 c8 =200 influnce Out.WriteByte(1); // 1 Out.Fill(0, 3); DispatchPacket(Out, true); Plr.SendLocalizeString(Objective.Objective.Objective + " " + Objective.Count + "/" + Objective.Objective.Count, GameData.Localized_text.CHAT_TAG_MONSTER_EMOTE); } } } if (Stage.IsDone()) { NextStage(); } }
public static void InventorySlot8() => Game.PossessedPlayer.MatchSome((Plr) => Plr.InventorySlotSelect(8));
public static void ToggleFly() { Game.PossessedPlayer.MatchSome( (Plr) => Plr.SetFly(!Plr.FlyMode) ); }
public static void InputReset() { Game.PossessedPlayer.MatchSome( (Plr) => Plr.Reset() ); }
public override void _Process(float Delta) { Game.PossessedPlayer.Match( none: () => GhostMesh.Visible = false, some: (Plr) => { if (Plr.Inventory[Plr.InventorySlot] == null) { GhostMesh.Visible = false; CurrentMeshType = Items.ID.NONE; return; } CurrentMeshType = Plr.Inventory[Plr.InventorySlot].Id; GhostMesh.Mesh = Items.Meshes[CurrentMeshType]; var BuildRayCast = Plr.GetNode <RayCast>("SteelCamera/RayCast"); if (BuildRayCast.IsColliding() && BuildRayCast.GetCollider() is Tile Base) { Vector3?GhostPosition = Items.TryCalculateBuildPosition(CurrentMeshType, Base, Plr.RotationDegrees.y, Plr.BuildRotation, BuildRayCast.GetCollisionPoint()); if (GhostPosition != null) { GhostMesh.Visible = true; Vector3 GhostRotation = Items.CalculateBuildRotation(CurrentMeshType, Base, Plr.RotationDegrees.y, Plr.BuildRotation, BuildRayCast.GetCollisionPoint()); Translation = (Vector3)GhostPosition; RotationDegrees = GhostRotation; GhostMesh.Translation = (Vector3)GhostPosition; GhostMesh.RotationDegrees = GhostRotation; CanBuild = true; if (GetOverlappingBodies().Count > 0) { foreach (Node Body in GetOverlappingBodies()) { Items.ID[] DisallowedCollisions = Items.IdInfos[CurrentMeshType].DisallowedCollisions; if (DisallowedCollisions != null && Body is Tile Branch && DisallowedCollisions.Contains(Branch.ItemId)) { CanBuild = false; } } } if (CanBuild) { GhostMesh.MaterialOverride = GreenMat; } else { GhostMesh.MaterialOverride = RedMat; } return; } } CanBuild = false; GhostMesh.Visible = false; } ); }