1using System.Globalization;
14 public static string fName =
"PlayerData";
99 public float Level {
get;
set; }
108 return m_stateMachine.CurrentState ==
"PlayerDead";
152 "PlayerDataFirstUpdate",
154 loader.PlayerDataFirstUpdate(
this);
167 if (playerData !=
null) {
209 if (!(updateProgress2 < 1f)
245 catch (Exception ex) {
246 Log.
Error(
"Spawning Player Error!");
295 modLoader.OnPlayerDead(
this);
308 bool respawn =
false;
309 bool disableVanillaTapToRespawnAction =
false;
311 "UpdateDeathCameraWidget",
314 loader.UpdateDeathCameraWidget(
this, ref disableVanillaTapToRespawnAction, ref respawn);
319 if (!disableVanillaTapToRespawnAction
354 string[] second =
SubsystemPlayers.PlayersData.Select(pd => pd.CharacterSkinName).ToArray();
355 string[] array2 = array.Except(second).ToArray();
356 CharacterSkinName = array2.Length != 0 ? array2[random.
Int(0, array2.Length - 1)] : array[random.
Int(0, array.Length - 1)];
364 public static bool VerifyName(
string name) => name.Length >= 1;
372 FirstSpawnTime = valuesDictionary.GetValue(
"FirstSpawnTime", 0.0);
373 LastSpawnTime = valuesDictionary.GetValue(
"LastSpawnTime", 0.0);
374 SpawnsCount = valuesDictionary.GetValue(
"SpawnsCount", 0);
375 Name = valuesDictionary.GetValue(
"Name",
"Walter");
377 Level = valuesDictionary.GetValue(
"Level", 1f);
386 valuesDictionary.SetValue(
"SpawnsCount",
SpawnsCount);
387 valuesDictionary.SetValue(
"Name",
Name);
388 valuesDictionary.SetValue(
"PlayerClass",
PlayerClass);
389 valuesDictionary.SetValue(
"Level",
Level);
391 valuesDictionary.SetValue(
"InputDevice",
InputDevice);
396 if (componentPlayer !=
null
416 float num =
float.MinValue;
417 for (
int i = -30; i <= 30; i += 2) {
418 for (
int j = -30; j <= 30; j += 2) {
424 vector =
new Vector2(num2, num3);
429 return new Vector3(vector.
X + 0.5f, num5 + 0.01f, vector.
Y + 0.5f);
434 float num =
float.MinValue;
435 for (
int i = -8; i <= 8; i++) {
436 for (
int j = -8; j <= 8; j++) {
437 for (
int k = -8; k <= 8; k++) {
444 vector =
new Vector3(num2, num3, num4);
449 return new Vector3(vector.
X + 0.5f, vector.
Y + 0.01f, vector.
Z + 0.5f);
466 for (
int i = x - 1; i <= x + 1; i++) {
467 for (
int j = z - 1; j <= z + 1; j++) {
474 Vector3 vector2 =
new(x, num2 + 1.5f, z);
475 for (
int k = -1; k <= 1; k++) {
476 Vector3 end = vector2 +
new Vector3(30f * vector.
X, 5f * k, 30f * vector.
Y);
484 if (terrainRaycastResult.HasValue) {
487 if (cellContents2 != 18
488 && cellContents2 != 0) {
521 if (playersDatum !=
this
530 for (
int i = p.
X - 1; i < p.
X + 1; i++) {
531 for (
int j = p.
Z - 1; j < p.
Z + 1; j++) {
532 for (
int num = p.
Y; num > 0; num--) {
574 value4 = $
"{MakeClothingValue(26, 6)};{MakeClothingValue(27, 0)}";
579 value2 = $
"{MakeClothingValue(13, 7)};{MakeClothingValue(5, 0)}";
588 value4 = $
"{MakeClothingValue(26, 6)};{MakeClothingValue(8, 0)}";
592 value2 = $
"{MakeClothingValue(37, 3)};{MakeClothingValue(1, 3)}";
594 value4 = $
"{MakeClothingValue(26, 6)};{MakeClothingValue(29, 0)}";
600 value2 = $
"{MakeClothingValue(13, 0)};{MakeClothingValue(5, 0)}";
602 value4 = $
"{MakeClothingValue(26, 6)};{MakeClothingValue(29, 0)}";
609 value4 = $
"{MakeClothingValue(26, 6)};{MakeClothingValue(8, 0)}";
616 value4 = $
"{MakeClothingValue(26, 6)};{MakeClothingValue(8, 0)}";
620 value2 = $
"{MakeClothingValue(37, 0)};{MakeClothingValue(1, 9)}";
622 value4 = $
"{MakeClothingValue(26, 6)};{MakeClothingValue(29, 0)}";
624 value5 = m_subsystemGameInfo.WorldSettings.GameMode <=
GameMode.Survival ? 1 : 0;
631 {
"Clothes",
new ValuesDictionary { {
"Feet", value4 }, {
"Legs", value3 }, {
"Torso", value2 }, {
"Head", value } } }
646 if (componentMount !=
null) {
663 return "FemalePlayer";
668 public virtual void UpdateSpawnDialog(
string largeMessage,
string smallMessage,
float progress,
bool resetProgress) {
678 if (largeMessage !=
null) {
679 m_spawnDialog.LargeMessage = largeMessage;
681 if (smallMessage !=
null) {
682 m_spawnDialog.SmallMessage = smallMessage;
696 .ToString(CultureInfo.InvariantCulture);
static void Error(object message)
static int Min(int x1, int x2)
static int Max(int x1, int x2)
static float DegToRad(float degrees)
static bool PeriodicEvent(double period, double offset)
static double FrameStartTime
virtual bool IsTransparent_(int value)
virtual bool IsCollidable_(int value)
static ReadOnlyList< string > CharacterSkinsNames
static ? PlayerClass GetPlayerClass(string name)
static bool IsBuiltIn(string name)
static string GetDisplayName(string name)
static void UpdateCharacterSkinsList()
static int SetClothingColor(int data, int color)
static int SetClothingIndex(int data, int clothingIndex)
ComponentBody ComponentBody
static Vector2 FindOceanDirection(ITerrainContentsGenerator generator, Vector2 position)
static Entity CreateEntity(Project project, SpawnEntityData spawnEntityData, bool throwIfNotFound)
static void HideDialog(Dialog dialog)
static bool HasDialogs(Widget parentWidget)
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
static WorldInfo WorldInfo
static void DisposeProject()
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
void Load(ValuesDictionary valuesDictionary)
SubsystemPlayers SubsystemPlayers
float ScoreNoIntroSpawnPosition(Vector3 desiredSpawnPosition, int x, int y, int z)
void RandomizeCharacterSkin()
float ScoreIntroSpawnPosition(Vector2 desiredSpawnPosition, int x, int z)
PlayerClass m_playerClass
bool ReduceLevelUponDeath
double m_terrainWaitStartTime
SubsystemGameInfo m_subsystemGameInfo
ComponentPlayer ComponentPlayer
Vector3 FindIntroSpawnPosition(Vector2 desiredSpawnPosition)
double m_initialSpawnWaitTime
SubsystemGameWidgets SubsystemGameWidgets
double? m_playerDeathTime
double TerrainMaxWaitTime
WidgetInputDevice InputDevice
void SpawnPlayer(Vector3 position, SpawnMode spawnMode)
StateMachine m_stateMachine
SpawnDialog m_spawnDialog
static string MakeClothingValue(int index, int color)
static bool VerifyName(string name)
void Save(ValuesDictionary valuesDictionary)
SubsystemSky m_subsystemSky
Vector3 FindNoIntroSpawnPosition(Vector3 desiredSpawnPosition, bool respawn)
PlayerData(Project project)
SubsystemTerrain m_subsystemTerrain
void OnEntityRemoved(Entity entity)
string GetEntityTemplateName()
bool CheckIsPointInWater(Point3 p)
virtual void UpdateSpawnDialog(string largeMessage, string smallMessage, float progress, bool resetProgress)
void OnEntityAdded(Entity entity)
static void SwitchScreen(string name, params object[] parameters)
Vector3 GlobalSpawnPosition
bool PlayerStartedPlaying
static int ExtractContents(int value)
static int ToCell(float x)
static int MakeBlockValue(int contents)
void SetErrorHead(int headLangIndex, int adviceLangIndex)
Component FindComponent(Type type, string name, bool throwOnError)
virtual Subsystem FindSubsystem(Type type, string name, bool throwOnError)
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static Quaternion CreateFromAxisAngle(Vector3 axis, float angle)
static readonly Vector2 Zero
static readonly Vector2 UnitY
static float Angle(Vector2 v1, Vector2 v2)
static float Distance(Vector2 v1, Vector2 v2)
static float DistanceSquared(Vector3 v1, Vector3 v2)
static readonly Vector3 Zero
static float Distance(Vector3 v1, Vector3 v2)
static readonly Vector3 UnitY