public void UpdateVehiclePosition(NitroxId id, NitroxVector3 position) { if (vehiclesById.TryGetValue(id, out VehicleModel vehicleModel)) { vehicleModel.Position = position; } }
public void Prepare(Entity entity, Entity parentEntity, DeterministicBatchGenerator deterministicBatchGenerator) { for (int spawnPointCounter = 0; spawnPointCounter < LocalCreatureSpawnPoints.Count; spawnPointCounter++) { NitroxVector3 localSpawnPosition = LocalCreatureSpawnPoints[spawnPointCounter]; float targetProbabilitySum = (float)deterministicBatchGenerator.NextDouble() * creatureProbabiltySum; float probabilitySum = 0; foreach (ReefbackEntity creature in SpawnableCreatures) { probabilitySum += creature.probability; if (probabilitySum >= targetProbabilitySum) { int totalToSpawn = deterministicBatchGenerator.NextInt(creature.minNumber, creature.maxNumber + 1); for (int i = 0; i < totalToSpawn; i++) { NitroxId id = deterministicBatchGenerator.NextId(); Entity child = new Entity(localSpawnPosition, new NitroxQuaternion(0, 0, 0, 1), new NitroxVector3(1, 1, 1), creature.techType.ToDto(), entity.Level, creature.classId, true, id, null, parentEntity); entity.ChildEntities.Add(child); } break; } } } }
public Player CreatePlayer(NitroxConnection connection, string reservationKey, out bool wasBrandNewPlayer) { lock (assetsByConnection) { ConnectionAssets assetPackage = assetsByConnection[connection]; PlayerContext playerContext = reservations[reservationKey]; Validate.NotNull(playerContext); wasBrandNewPlayer = playerContext.WasBrandNewPlayer; // Load previously persisted data for this player. NitroxVector3 position = playerData.GetPosition(playerContext.PlayerName); Optional <NitroxId> subRootId = playerData.GetSubRootId(playerContext.PlayerName); // Load a NitroxID for the newly connected Player NitroxId id = playerData.GetNitroxId(playerContext.PlayerName); Player player = new Player(playerContext, connection, position, id, subRootId); assetPackage.Player = player; assetPackage.ReservationKey = null; reservations.Remove(reservationKey); return(player); } }
public void UpdateVehicleColours(int index, NitroxId id, NitroxVector3 hsb) { if (vehiclesById.TryGetValue(id, out VehicleModel vehicleModel)) { vehicleModel.HSB[index] = hsb; } }
public void UpdateVehicleColours(int index, NitroxId id, NitroxVector3 hsb) { if (vehiclesById.ContainsKey(id)) { vehiclesById[id].HSB[index] = hsb; } }
public PlayerTeleported(string playerName, NitroxVector3 destinationFrom, NitroxVector3 destinationTo, Optional <NitroxId> subRootID) { PlayerName = playerName; DestinationFrom = destinationFrom; DestinationTo = destinationTo; SubRootID = subRootID; }
public void UpdateVehiclePosition(NitroxId id, NitroxVector3 position) { if (vehiclesById.ContainsKey(id)) { vehiclesById[id].Position = position; } }
public VehicleColorChange(int index, NitroxId id, NitroxVector3 hsb, NitroxColor color) { Id = id; Index = index; HSB = hsb; Color = color; }
public NeptuneRocketModel(NitroxTechType techType, NitroxId id, NitroxVector3 position, NitroxQuaternion rotation, List <InteractiveChildObjectIdentifier> interactiveChildIdentifiers, Optional <NitroxId> dockingBayId, string name, NitroxVector3[] hsb, float health) : base(techType, id, position, rotation, interactiveChildIdentifiers, dockingBayId, name, hsb, health) { CurrentStage = 0; ElevatorUp = false; PreflightChecks = new ThreadSafeCollection <PreflightCheck>(); }
public CorridorBuilderMetadata(NitroxVector3 position, int rotation, bool hasTargetBase, NitroxInt3 targetCell) : base(typeof(BaseAddCorridorGhost)) { Position = position; Rotation = rotation; HasTargetBase = hasTargetBase; Cell = targetCell; }
public NeptuneRocketModel(NitroxTechType techType, NitroxId id, NitroxVector3 position, NitroxQuaternion rotation, List <InteractiveChildObjectIdentifier> interactiveChildIdentifiers, Optional <NitroxId> dockingBayId, string name, NitroxVector3[] hsb, float health) : base(techType, id, position, rotation, interactiveChildIdentifiers, dockingBayId, name, hsb, health) { CurrentStage = 0; ElevatorUp = false; ConstructorId = new NitroxId(); //The ID will be set forever and will be fetched once a rocket base platform starts (see Rocket_Start_Patch) }
public Optional <AbsoluteEntityCell> UpdateEntityPosition(NitroxId id, NitroxVector3 position, NitroxQuaternion rotation) { Optional <Entity> opEntity = GetEntityById(id); if (!opEntity.HasValue) { Log.Debug("Could not update entity position because it was not found (maybe it was recently picked up)"); return(Optional.Empty); } Entity entity = opEntity.Value; AbsoluteEntityCell oldCell = entity.AbsoluteEntityCell; entity.Transform.Position = position; entity.Transform.Rotation = rotation; AbsoluteEntityCell newCell = entity.AbsoluteEntityCell; if (oldCell != newCell) { EntitySwitchedCells(entity, oldCell, newCell); } return(Optional.Of(newCell)); }
public void Teleport(NitroxVector3 destination) { PlayerTeleported playerTeleported = new PlayerTeleported(Name, Position, destination); SendPacket(playerTeleported); Position = playerTeleported.DestinationTo; LastStoredPosition = playerTeleported.DestinationFrom; }
public UweWorldEntity(NitroxTechType techType, NitroxVector3 scale, string classId, string slotType, int cellLevel) { TechType = techType; Scale = scale; ClassId = classId; SlotType = slotType; CellLevel = cellLevel; }
public SeamothModulesAction(NitroxTechType techType, int slotID, NitroxId id, NitroxVector3 forward, NitroxQuaternion rotation) { TechType = techType; SlotID = slotID; Id = id; Forward = forward; Rotation = rotation; }
public VehicleColorChange(int index, NitroxId parentId, NitroxId vehicleId, NitroxVector3 hsb, NitroxColor color) { ParentId = Optional.OfNullable(parentId); VehicleId = vehicleId; Index = index; HSB = hsb; Color = color; }
public PlayFMODAsset(string assetPath, NitroxVector3 position, float volume, float radius, bool isGlobal) { AssetPath = assetPath; Position = position; Volume = volume; Radius = radius; IsGlobal = isGlobal; }
public static Matrix4x4 Compose(NitroxVector3 localPosition, NitroxQuaternion localRotation, NitroxVector3 localScale) { Matrix4x4 translationMatrix = Matrix4x4.CreateTranslation(localPosition.X, localPosition.Y, localPosition.Z); Matrix4x4 rotationMatrix = Matrix4x4.CreateFromQuaternion((Quaternion)localRotation); Matrix4x4 scaleMatrix = Matrix4x4.CreateScale(localScale.X, localScale.Y, localScale.Z); return(scaleMatrix * rotationMatrix * translationMatrix); }
public DroppedItem(NitroxId id, Optional <NitroxId> waterParkId, NitroxTechType techType, NitroxVector3 itemPosition, NitroxQuaternion itemRotation, byte[] bytes) { Id = id; WaterParkId = waterParkId; ItemPosition = itemPosition; ItemRotation = itemRotation; TechType = techType; Bytes = bytes; }
public void Teleport(NitroxVector3 destination, Optional <NitroxId> subRootID) { PlayerTeleported playerTeleported = new PlayerTeleported(Name, Position, destination, subRootID); Position = playerTeleported.DestinationTo; LastStoredPosition = playerTeleported.DestinationFrom; LastStoredSubRootID = subRootID; SendPacket(playerTeleported); }
public EntitySpawnPoint(AbsoluteEntityCell absoluteEntityCell, NitroxVector3 localPosition, NitroxQuaternion localRotation, NitroxVector3 scale, string classId) { AbsoluteEntityCell = absoluteEntityCell; ClassId = classId; Density = 1; LocalPosition = localPosition; Scale = scale; LocalRotation = localRotation; }
public EntitySpawnPoint(AbsoluteEntityCell absoluteEntityCell, NitroxVector3 localPosition, NitroxQuaternion localRotation, List <string> allowedTypes, float density, string biomeType) { AbsoluteEntityCell = absoluteEntityCell; LocalPosition = localPosition; LocalRotation = localRotation; BiomeType = biomeType; Density = density; AllowedTypes = allowedTypes; }
protected override void Execute(CallArgs args) { Validate.IsTrue(args.Sender.HasValue, "This command can't be used by CONSOLE"); NitroxVector3 position = new NitroxVector3(args.Get <int>(0), args.Get <int>(1), args.Get <int>(2)); args.Sender.Value.Teleport(position, Optional.Empty); SendMessage(args.Sender, $"Teleported to {position}"); }
public Movement(ushort playerId, NitroxVector3 position, NitroxVector3 velocity, NitroxQuaternion bodyRotation, NitroxQuaternion aimingRotation) { PlayerId = playerId; Position = position; Velocity = velocity; BodyRotation = bodyRotation; AimingRotation = aimingRotation; DeliveryMethod = NitroxDeliveryMethod.DeliveryMethod.UNRELIABLE_SEQUENCED; UdpChannel = UdpChannelId.PLAYER_MOVEMENT; }
public static NitroxVector3 Transform(this Matrix4x4 m, NitroxVector3 v) { float x = v.X * m.M11 + v.Y * m.M21 + v.Z * m.M31 + m.M41; float y = v.X * m.M12 + v.Y * m.M22 + v.Z * m.M32 + m.M42; float z = v.X * m.M13 + v.Y * m.M23 + v.Z * m.M33 + m.M43; float w = v.X * m.M14 + v.Y * m.M24 + v.Z * m.M34 + m.M44; w = 1f / w; return(new NitroxVector3(x * w, y * w, z * w)); }
public CyclopsModel(NitroxTechType techType, NitroxId id, NitroxVector3 position, NitroxQuaternion rotation, List <InteractiveChildObjectIdentifier> interactiveChildIdentifiers, Optional <NitroxId> dockingBayId, string name, NitroxVector3[] hsb, float health) : base(techType, id, position, rotation, interactiveChildIdentifiers, dockingBayId, name, hsb, health) { FloodLightsOn = true; InternalLightsOn = true; SilentRunningOn = false; ShieldOn = false; SonarOn = false; EngineState = false; EngineMode = CyclopsMotorMode.CyclopsMotorModes.Standard; }
public override void Process(PlayFMODAsset packet, Player sendingPlayer) { foreach (Player player in playerManager.GetConnectedPlayers()) { float distance = NitroxVector3.Distance(player.Position, packet.Position); if (player != sendingPlayer && (packet.IsGlobal || player.SubRootId.Equals(sendingPlayer.SubRootId)) && distance <= packet.Radius) { packet.Volume -= (1 - distance / packet.Radius) * packet.Volume; // Non realistic volume calculation but enough for us player.SendPacket(packet); } } }
public object Draw(object target) { return(target switch { Vector2 vector2 => DrawVector2(vector2), Vector3 vector3 => DrawVector3(vector3), NitroxVector3 nitroxVector3 => DrawVector3(nitroxVector3.ToUnity()).ToDto(), Vector4 vector4 => DrawVector4(vector4), NitroxVector4 nitroxVector4 => DrawVector4(nitroxVector4.ToUnity()).ToDto(), Quaternion quaternion => DrawQuaternion(quaternion), Int3 int3 => DrawInt3(int3), _ => null });
private NitroxVector3 GetStartPosition() { Random rnd = new Random(seed.GetHashCode()); NitroxVector3 position = randomStart.GenerateRandomStartPosition(rnd); if (EscapePods.Count == 0) { return(position); } foreach (EscapePodModel escapePodModel in EscapePods) { if (position == NitroxVector3.Zero) { break; } if (escapePodModel.Location != position) { return(position); } } float xNormed = (float)rnd.NextDouble(); float zNormed = (float)rnd.NextDouble(); if (xNormed < 0.3f) { xNormed = 0.3f; } else if (xNormed > 0.7f) { xNormed = 0.7f; } if (zNormed < 0.3f) { zNormed = 0.3f; } else if (zNormed > 0.7f) { zNormed = 0.7f; } NitroxVector3 lastEscapePodPosition = EscapePods[EscapePods.Count - 1].Location; float x = xNormed * 100 - 50; float z = zNormed * 100 - 50; return(new NitroxVector3(lastEscapePodPosition.X + x, 0, lastEscapePodPosition.Z + z)); }
public static NitroxVector3[] ToDto(this Vector3[] v) { if (v == null) { return(Array.Empty <NitroxVector3>()); } NitroxVector3[] result = new NitroxVector3[v.Length]; for (int i = 0; i < v.Length; i++) { result[i] = v[i].ToDto(); } return(result); }