Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
PlayerData.cs
浏览该文件的文档.
1using System.Globalization;
2using Engine;
5
6namespace Game {
7 public class PlayerData : IDisposable {
13
14 public static string fName = "PlayerData";
15
17
19
21
23
25
27
29
30 public string m_name;
31
33
34 public double? m_playerDeathTime;
35
37 public double TerrainMaxWaitTime { get; set; } = 15;
38
40
41 public float m_progress;
42 public int PlayerIndex { get; set; }
43
45
47
48 public ComponentPlayer ComponentPlayer { get; set; }
49
50 public Entity LastDeadPlayer { get; set; }
51
53 get {
54 if (m_gameWidget == null) {
55 foreach (GameWidget gameWidget in SubsystemGameWidgets.GameWidgets) {
56 if (gameWidget.PlayerData == this) {
57 m_gameWidget = gameWidget;
58 break;
59 }
60 }
61 if (m_gameWidget == null) {
62 throw new InvalidOperationException(LanguageControl.Get(fName, 11));
63 }
64 }
65 return m_gameWidget;
66 }
67 }
68
69 public Vector3 SpawnPosition { get; set; }
70
71 public double FirstSpawnTime { get; set; }
72
73 public double LastSpawnTime { get; set; }
74
75 public int SpawnsCount { get; set; }
76
77 public string Name {
78 get => m_name;
79 set {
80 if (value != m_name) {
81 m_name = value;
82 IsDefaultName = false;
83 }
84 }
85 }
86
87 public bool IsDefaultName { get; set; }
88
90 get => m_playerClass;
91 set {
92 if (SubsystemPlayers.PlayersData.Contains(this)) {
93 throw new InvalidOperationException(LanguageControl.Get(fName, 1));
94 }
95 m_playerClass = value;
96 }
97 }
98
99 public float Level { get; set; }
100 public bool ReduceLevelUponDeath = true;
101 public string CharacterSkinName { get; set; }
102
103 public WidgetInputDevice InputDevice { get; set; }
104
105 public bool IsReadyForPlaying {
106 get {
107 if (m_stateMachine.CurrentState != "Playing") {
108 return m_stateMachine.CurrentState == "PlayerDead";
109 }
110 return true;
111 }
112 }
113
114 public double m_initialSpawnWaitTime = 0;
115 public double m_respawnWaitTime = 2.0;
116
125
126 public PlayerData(Project project) {
127 m_project = project;
134 Level = 1f;
135 FirstSpawnTime = -1.0;
136 LastSpawnTime = -1.0;
138 ResetName();
140 m_stateMachine.AddState(
141 "FirstUpdate",
142 null,
143 delegate {
144 if (ComponentPlayer != null) {
145 UpdateSpawnDialog(string.Format(LanguageControl.Get(fName, 4), Name, MathF.Floor(Level)), null, 0f, true);
146 m_stateMachine.TransitionTo("WaitForTerrain");
147 }
148 else {
149 m_stateMachine.TransitionTo("PrepareSpawn");
150 }
152 "PlayerDataFirstUpdate",
153 loader => {
154 loader.PlayerDataFirstUpdate(this);
155 return false;
156 }
157 );
158 },
159 null
160 );
161 m_stateMachine.AddState(
162 "PrepareSpawn",
163 delegate {
164 if (SpawnPosition == Vector3.Zero) {
165 if (SubsystemPlayers.GlobalSpawnPosition == Vector3.Zero) {
166 PlayerData playerData = SubsystemPlayers.PlayersData.FirstOrDefault(pd => pd.SpawnPosition != Vector3.Zero);
167 if (playerData != null) {
168 if (playerData.ComponentPlayer != null) {
170 m_spawnMode = SpawnMode.InitialNoIntro;
171 }
172 else {
173 SpawnPosition = playerData.SpawnPosition;
174 m_spawnMode = SpawnMode.InitialNoIntro;
175 }
176 }
177 else {
178 SpawnPosition = m_subsystemTerrain.TerrainContentsGenerator.FindCoarseSpawnPosition();
179 m_spawnMode = SpawnMode.InitialIntro;
180 }
182 }
183 else {
184 SpawnPosition = SubsystemPlayers.GlobalSpawnPosition;
185 m_spawnMode = SpawnMode.InitialNoIntro;
186 }
187 }
188 else {
189 m_spawnMode = SpawnMode.Respawn;
190 }
191 if (m_spawnMode == SpawnMode.Respawn) {
193 string.Format(LanguageControl.Get(fName, 2), Name, MathF.Floor(Level)),
195 0f,
196 true
197 );
198 }
199 else {
200 UpdateSpawnDialog(string.Format(LanguageControl.Get(fName, 4), Name, MathF.Floor(Level)), null, 0f, true);
201 }
202 m_subsystemTerrain.TerrainUpdater.SetUpdateLocation(PlayerIndex, SpawnPosition.XZ, 0f, 64f);
204 },
205 delegate {
206 if (Time.PeriodicEvent(0.1, 0.0)) {
207 float updateProgress2 = m_subsystemTerrain.TerrainUpdater.GetUpdateProgress(PlayerIndex, 0f, 64f);
208 UpdateSpawnDialog(null, null, 0.5f * updateProgress2, false);
209 if (!(updateProgress2 < 1f)
211 switch (m_spawnMode) {
212 case SpawnMode.InitialIntro: SpawnPosition = FindIntroSpawnPosition(SpawnPosition.XZ); break;
213 case SpawnMode.InitialNoIntro: SpawnPosition = FindNoIntroSpawnPosition(SpawnPosition, false); break;
215 default: throw new InvalidOperationException(LanguageControl.Get(fName, 5));
216 }
217 m_stateMachine.TransitionTo("WaitForTerrain");
218 }
219 }
220 },
221 null
222 );
223 m_stateMachine.AddState(
224 "WaitForTerrain",
225 delegate {
227 Vector2 center = ComponentPlayer != null ? ComponentPlayer.ComponentBody.Position.XZ : SpawnPosition.XZ;
228 m_subsystemTerrain.TerrainUpdater.SetUpdateLocation(PlayerIndex, center, MathUtils.Min(m_subsystemSky.VisibilityRange, 64f), 0f);
229 },
230 delegate {
231 if (Time.PeriodicEvent(0.1, 0.0)) {
232 float updateProgress = m_subsystemTerrain.TerrainUpdater.GetUpdateProgress(
234 MathUtils.Min(m_subsystemSky.VisibilityRange, 64f),
235 0f
236 );
237 UpdateSpawnDialog(null, null, 0.5f + 0.5f * updateProgress, false);
238 if ((updateProgress >= 1f && IsTimeReadyToSpawn)
240 if (ComponentPlayer == null) {
241 try {
244 }
245 catch (Exception ex) {
246 Log.Error("Spawning Player Error!");
247 Log.Error(ex);
249 ViewGameLogDialog dialog = new();
250 dialog.SetErrorHead(12, 10);
251 DialogsManager.ShowDialog(null, dialog);
253 }
254 }
255 if (m_playerDeathTime.HasValue
256 || ComponentPlayer?.ComponentHealth.Health <= 0f) {
258 m_stateMachine.TransitionTo("PlayerDead");
259 }
260 else {
261 m_stateMachine.TransitionTo("Playing");
262 }
263 }
264 }
265 },
266 null
267 );
268 m_stateMachine.AddState(
269 "Playing",
271 delegate {
272 if (ComponentPlayer == null) {
273 m_stateMachine.TransitionTo("PrepareSpawn");
274 }
275 else if (m_playerDeathTime.HasValue) {
276 m_stateMachine.TransitionTo("PlayerDead");
277 }
278 else {
279 lock (ComponentPlayer.ComponentHealth) {
280 if (ComponentPlayer.ComponentHealth.Health <= 0f) {
282 }
283 }
284 }
285 },
286 null
287 );
288 m_stateMachine.AddState(
289 "PlayerDead",
290 delegate {
293 "OnPlayerDead",
294 modLoader => {
295 modLoader.OnPlayerDead(this);
296 return false;
297 }
298 );
299 if (ReduceLevelUponDeath && m_stateMachine.PreviousState == "Playing") {
300 Level = MathUtils.Max(MathF.Floor(Level / 2f), 1f);
301 }
302 },
303 delegate {
304 if (ComponentPlayer == null) {
305 m_stateMachine.TransitionTo("PrepareSpawn");
306 return;
307 }
308 bool respawn = false;
309 bool disableVanillaTapToRespawnAction = false;
311 "UpdateDeathCameraWidget",
312 loader => {
313 // ReSharper disable AccessToModifiedClosure
314 loader.UpdateDeathCameraWidget(this, ref disableVanillaTapToRespawnAction, ref respawn);
315 // ReSharper restore AccessToModifiedClosure
316 return false;
317 }
318 );
319 if (!disableVanillaTapToRespawnAction
320 && Time.RealTime - (m_playerDeathTime ?? 0) > 1.5
322 && ComponentPlayer.GameWidget.Input.Any) {
323 if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Cruel) {
325 }
326 else if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Adventure
327 && !m_subsystemGameInfo.WorldSettings.IsAdventureRespawnAllowed) {
328 ScreensManager.SwitchScreen("GameLoading", GameManager.WorldInfo, "AdventureRestart");
329 }
330 else {
331 respawn = true;
332 }
333 }
334 if (respawn) {
336 ComponentPlayer = null;
337 }
338 },
339 null
340 );
341 m_stateMachine.TransitionTo("FirstUpdate");
342 }
343
344 public void Dispose() {
346 }
347
349 Random random = new();
353 .ToArray();
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)];
357 }
358
363
364 public static bool VerifyName(string name) => name.Length >= 1;
365
366 public virtual void Update() {
367 m_stateMachine.Update();
368 }
369
370 public void Load(ValuesDictionary valuesDictionary) {
371 SpawnPosition = valuesDictionary.GetValue("SpawnPosition", Vector3.Zero);
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");
376 PlayerClass = valuesDictionary.GetValue("PlayerClass", PlayerClass.Male);
377 Level = valuesDictionary.GetValue("Level", 1f);
378 CharacterSkinName = valuesDictionary.GetValue("CharacterSkinName", CharacterSkinsManager.CharacterSkinsNames[0]);
379 InputDevice = valuesDictionary.GetValue("InputDevice", InputDevice);
380 }
381
382 public void Save(ValuesDictionary valuesDictionary) {
383 valuesDictionary.SetValue("SpawnPosition", SpawnPosition);
384 valuesDictionary.SetValue("FirstSpawnTime", FirstSpawnTime);
385 valuesDictionary.SetValue("LastSpawnTime", LastSpawnTime);
386 valuesDictionary.SetValue("SpawnsCount", SpawnsCount);
387 valuesDictionary.SetValue("Name", Name);
388 valuesDictionary.SetValue("PlayerClass", PlayerClass);
389 valuesDictionary.SetValue("Level", Level);
390 valuesDictionary.SetValue("CharacterSkinName", CharacterSkinName);
391 valuesDictionary.SetValue("InputDevice", InputDevice);
392 }
393
394 public void OnEntityAdded(Entity entity) {
395 ComponentPlayer componentPlayer = entity.FindComponent<ComponentPlayer>();
396 if (componentPlayer != null
397 && componentPlayer.PlayerData == this) {
398 //多维世界mod会提前为PlayerData.ComponentPlayer赋值,原版行为会在SubsystemPlayers.OnEntityAdded再次赋值
399 //为阻止再次赋值时引发异常所以加了条ComponentPlayer != componentPlayer判断
400 if (ComponentPlayer != null && ComponentPlayer != componentPlayer) {
401 throw new InvalidOperationException(string.Format(LanguageControl.Get(fName, 10), PlayerIndex));
402 }
403 ComponentPlayer = componentPlayer;
405 GameWidget.Target = componentPlayer;
406 if (FirstSpawnTime < 0.0) {
407 FirstSpawnTime = m_subsystemGameInfo.TotalElapsedGameTime;
408 }
409 }
410 }
411
412 public void OnEntityRemoved(Entity entity) { }
413
414 public Vector3 FindIntroSpawnPosition(Vector2 desiredSpawnPosition) {
415 Vector2 vector = Vector2.Zero;
416 float num = float.MinValue;
417 for (int i = -30; i <= 30; i += 2) {
418 for (int j = -30; j <= 30; j += 2) {
419 int num2 = Terrain.ToCell(desiredSpawnPosition.X) + i;
420 int num3 = Terrain.ToCell(desiredSpawnPosition.Y) + j;
421 float num4 = ScoreIntroSpawnPosition(desiredSpawnPosition, num2, num3);
422 if (num4 > num) {
423 num = num4;
424 vector = new Vector2(num2, num3);
425 }
426 }
427 }
428 float num5 = m_subsystemTerrain.Terrain.CalculateTopmostCellHeight(Terrain.ToCell(vector.X), Terrain.ToCell(vector.Y)) + 1;
429 return new Vector3(vector.X + 0.5f, num5 + 0.01f, vector.Y + 0.5f);
430 }
431
432 public Vector3 FindNoIntroSpawnPosition(Vector3 desiredSpawnPosition, bool respawn) {
433 Vector3 vector = Vector3.Zero;
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++) {
438 int num2 = Terrain.ToCell(desiredSpawnPosition.X) + i;
439 int num3 = Terrain.ToCell(desiredSpawnPosition.Y) + j;
440 int num4 = Terrain.ToCell(desiredSpawnPosition.Z) + k;
441 float num5 = ScoreNoIntroSpawnPosition(desiredSpawnPosition, num2, num3, num4);
442 if (num5 > num) {
443 num = num5;
444 vector = new Vector3(num2, num3, num4);
445 }
446 }
447 }
448 }
449 return new Vector3(vector.X + 0.5f, vector.Y + 0.01f, vector.Z + 0.5f);
450 }
451
452 public float ScoreIntroSpawnPosition(Vector2 desiredSpawnPosition, int x, int z) {
453 float num = -0.01f * Vector2.Distance(new Vector2(x, z), desiredSpawnPosition);
454 int num2 = m_subsystemTerrain.Terrain.CalculateTopmostCellHeight(x, z);
455 if (num2 < 64
456 || num2 > 85) {
457 num -= 5f;
458 }
459 if (m_subsystemTerrain.Terrain.GetSeasonalTemperature(x, z) < 8) {
460 num -= 5f;
461 }
462 int cellValue = m_subsystemTerrain.Terrain.GetCellValue(x, num2, z);
463 if (BlocksManager.Blocks[Terrain.ExtractContents(cellValue)].IsTransparent_(cellValue)) {
464 num -= 5f;
465 }
466 for (int i = x - 1; i <= x + 1; i++) {
467 for (int j = z - 1; j <= z + 1; j++) {
468 if (m_subsystemTerrain.Terrain.GetCellContents(i, num2 + 2, j) != 0) {
469 num -= 1f;
470 }
471 }
472 }
473 Vector2 vector = ComponentIntro.FindOceanDirection(m_subsystemTerrain.TerrainContentsGenerator, new Vector2(x, z));
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);
477 TerrainRaycastResult? terrainRaycastResult = m_subsystemTerrain.Raycast(
478 vector2,
479 end,
480 false,
481 true,
482 (value, _) => Terrain.ExtractContents(value) != 0
483 );
484 if (terrainRaycastResult.HasValue) {
485 CellFace cellFace = terrainRaycastResult.Value.CellFace;
486 int cellContents2 = m_subsystemTerrain.Terrain.GetCellContents(cellFace.X, cellFace.Y, cellFace.Z);
487 if (cellContents2 != 18
488 && cellContents2 != 0) {
489 num -= 2f;
490 }
491 }
492 }
493 return num;
494 }
495
496 public float ScoreNoIntroSpawnPosition(Vector3 desiredSpawnPosition, int x, int y, int z) {
497 float num = -0.01f * Vector3.Distance(new Vector3(x, y, z), desiredSpawnPosition);
498 if (y < 1
499 || y >= 255) {
500 num -= 100f;
501 }
502 int objvalue = m_subsystemTerrain.Terrain.GetCellValue(x, y - 1, z);
503 int blockvalue = m_subsystemTerrain.Terrain.GetCellValue(x, y, z);
504 int block2value = m_subsystemTerrain.Terrain.GetCellValue(x, y + 1, z);
506 Block block = BlocksManager.Blocks[Terrain.ExtractContents(blockvalue)];
507 Block block2 = BlocksManager.Blocks[Terrain.ExtractContents(block2value)];
508 if (obj.IsTransparent_(objvalue)) {
509 num -= 10f;
510 }
511 if (!obj.IsCollidable_(objvalue)) {
512 num -= 10f;
513 }
514 if (block.IsCollidable_(blockvalue)) {
515 num -= 10f;
516 }
517 if (block2.IsCollidable_(block2value)) {
518 num -= 10f;
519 }
520 foreach (PlayerData playersDatum in SubsystemPlayers.PlayersData) {
521 if (playersDatum != this
522 && Vector3.DistanceSquared(playersDatum.SpawnPosition, new Vector3(x, y, z)) < MathUtils.Sqr(2)) {
523 num -= 1f;
524 }
525 }
526 return num;
527 }
528
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--) {
533 int cellValue = m_subsystemTerrain.Terrain.GetCellValue(p.X, num, p.Z);
535 if (block.IsCollidable_(cellValue)) {
536 return false;
537 }
538 if (block is WaterBlock) {
539 break;
540 }
541 }
542 }
543 }
544 return true;
545 }
546
547 public void SpawnPlayer(Vector3 position, SpawnMode spawnMode) {
548 if (LastDeadPlayer != null) {
549 m_project.RemoveEntity(LastDeadPlayer, false);
550 }
551 m_playerDeathTime = null;
552 ComponentMount componentMount = null;
553 if (spawnMode != SpawnMode.Respawn
554 && CheckIsPointInWater(Terrain.ToCell(position))) {
555 Entity entity = DatabaseManager.CreateEntity(m_project, "Boat", true);
556 entity.FindComponent<ComponentBody>(true).Position = position;
558 componentMount = entity.FindComponent<ComponentMount>(true);
559 m_project.AddEntity(entity);
560 position.Y += entity.FindComponent<ComponentBody>(true).BoxSize.Y;
561 }
562 string value = "";
563 string value2 = "";
564 string value3 = "";
565 string value4 = "";
566 int value5 = 0;
567 if (spawnMode != SpawnMode.Respawn) {
568 if (PlayerClass == PlayerClass.Female) {
570 && CharacterSkinName.Contains("2")) {
571 value = "";
572 value2 = MakeClothingValue(37, 2);
573 value3 = MakeClothingValue(16, 14);
574 value4 = $"{MakeClothingValue(26, 6)};{MakeClothingValue(27, 0)}";
575 }
577 && CharacterSkinName.Contains("3")) {
578 value = MakeClothingValue(31, 0);
579 value2 = $"{MakeClothingValue(13, 7)};{MakeClothingValue(5, 0)}";
580 value3 = MakeClothingValue(17, 15);
581 value4 = MakeClothingValue(29, 0);
582 }
584 && CharacterSkinName.Contains("4")) {
585 value = MakeClothingValue(30, 7);
586 value2 = MakeClothingValue(14, 6);
587 value3 = MakeClothingValue(25, 7);
588 value4 = $"{MakeClothingValue(26, 6)};{MakeClothingValue(8, 0)}";
589 }
590 else {
591 value = MakeClothingValue(30, 12);
592 value2 = $"{MakeClothingValue(37, 3)};{MakeClothingValue(1, 3)}";
593 value3 = MakeClothingValue(0, 12);
594 value4 = $"{MakeClothingValue(26, 6)};{MakeClothingValue(29, 0)}";
595 }
596 }
598 && CharacterSkinName.Contains("2")) {
599 value = "";
600 value2 = $"{MakeClothingValue(13, 0)};{MakeClothingValue(5, 0)}";
601 value3 = MakeClothingValue(25, 8);
602 value4 = $"{MakeClothingValue(26, 6)};{MakeClothingValue(29, 0)}";
603 }
605 && CharacterSkinName.Contains("3")) {
606 value = MakeClothingValue(32, 0);
607 value2 = MakeClothingValue(37, 5);
608 value3 = MakeClothingValue(0, 15);
609 value4 = $"{MakeClothingValue(26, 6)};{MakeClothingValue(8, 0)}";
610 }
612 && CharacterSkinName.Contains("4")) {
613 value = MakeClothingValue(31, 0);
614 value2 = MakeClothingValue(15, 14);
615 value3 = MakeClothingValue(0, 0);
616 value4 = $"{MakeClothingValue(26, 6)};{MakeClothingValue(8, 0)}";
617 }
618 else {
619 value = MakeClothingValue(32, 0);
620 value2 = $"{MakeClothingValue(37, 0)};{MakeClothingValue(1, 9)}";
621 value3 = MakeClothingValue(0, 12);
622 value4 = $"{MakeClothingValue(26, 6)};{MakeClothingValue(29, 0)}";
623 }
624 value5 = m_subsystemGameInfo.WorldSettings.GameMode <= GameMode.Survival ? 1 : 0;
625 }
626 ValuesDictionary overrides = new() {
627 { "Player", new ValuesDictionary { { "PlayerIndex", PlayerIndex } } },
628 { "Intro", new ValuesDictionary { { "PlayIntro", spawnMode == SpawnMode.InitialIntro } } }, {
629 "Clothing",
630 new ValuesDictionary {
631 { "Clothes", new ValuesDictionary { { "Feet", value4 }, { "Legs", value3 }, { "Torso", value2 }, { "Head", value } } }
632 }
633 }, {
634 "Inventory",
635 new ValuesDictionary {
636 { "Slots", new ValuesDictionary { { "Slot1", new ValuesDictionary { { "Contents", 162 }, { "Count", value5 } } } } }
637 }
638 }
639 };
640 Vector2 v = ComponentIntro.FindOceanDirection(m_subsystemTerrain.TerrainContentsGenerator, position.XZ);
641 string entityTemplateName = PlayerClass == PlayerClass.Male ? "MalePlayer" : "FemalePlayer";
642 Entity entity2 = DatabaseManager.CreateEntity(m_project, entityTemplateName, overrides, true);
643 entity2.FindComponent<ComponentBody>(true).Position = position;
645 m_project.AddEntity(entity2);
646 if (componentMount != null) {
647 entity2.FindComponent<ComponentRider>(true).StartMounting(componentMount);
648 }
649 LastSpawnTime = m_subsystemGameInfo.TotalElapsedGameTime;
650 ++SpawnsCount;
652 "OnPlayerSpawned",
653 modLoader => {
654 modLoader.OnPlayerSpawned(spawnMode, entity2.FindComponent<ComponentPlayer>(), position);
655 return false;
656 }
657 );
658 LastDeadPlayer = null;
659 }
660
661 public string GetEntityTemplateName() {
662 if (PlayerClass != 0) {
663 return "FemalePlayer";
664 }
665 return "MalePlayer";
666 }
667
668 public virtual void UpdateSpawnDialog(string largeMessage, string smallMessage, float progress, bool resetProgress) {
669 if (resetProgress) {
670 m_progress = 0f;
671 }
672 m_progress = MathUtils.Max(progress, m_progress);
673 if (m_spawnDialog == null) {
676 }
677 m_spawnDialog.TimeOfYear = m_subsystemGameInfo.WorldSettings.TimeOfYear;
678 if (largeMessage != null) {
679 m_spawnDialog.LargeMessage = largeMessage;
680 }
681 if (smallMessage != null) {
682 m_spawnDialog.SmallMessage = smallMessage;
683 }
684 m_spawnDialog.Progress = m_progress;
685 }
686
687 public void HideSpawnDialog() {
688 if (m_spawnDialog != null) {
690 m_spawnDialog = null;
691 }
692 }
693
694 public static string MakeClothingValue(int index, int color) => Terrain
696 .ToString(CultureInfo.InvariantCulture);
697 }
698}
Engine.Vector3 Vector3
static void Error(object message)
定义 Log.cs:80
static int Min(int x1, int x2)
static int Max(int x1, int x2)
static int Sqr(int x)
static float DegToRad(float degrees)
static double RealTime
定义 Time.cs:38
static bool PeriodicEvent(double period, double offset)
定义 Time.cs:63
static double FrameStartTime
定义 Time.cs:42
virtual bool IsTransparent_(int value)
virtual bool IsCollidable_(int value)
static ReadOnlyList< string > CharacterSkinsNames
static ? PlayerClass GetPlayerClass(string name)
static string GetDisplayName(string name)
static int SetClothingColor(int data, int color)
static int SetClothingIndex(int data, int clothingIndex)
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)
float ScoreIntroSpawnPosition(Vector2 desiredSpawnPosition, int x, int z)
PlayerClass m_playerClass
PlayerClass PlayerClass
double m_terrainWaitStartTime
SubsystemGameInfo m_subsystemGameInfo
ComponentPlayer ComponentPlayer
Vector3 FindIntroSpawnPosition(Vector2 desiredSpawnPosition)
SubsystemGameWidgets SubsystemGameWidgets
WidgetInputDevice InputDevice
void SpawnPlayer(Vector3 position, SpawnMode spawnMode)
GameWidget GameWidget
StateMachine m_stateMachine
SpawnDialog m_spawnDialog
static string MakeClothingValue(int index, int color)
static string fName
static bool VerifyName(string name)
virtual void Update()
void Save(ValuesDictionary valuesDictionary)
SubsystemSky m_subsystemSky
Vector3 FindNoIntroSpawnPosition(Vector3 desiredSpawnPosition, bool respawn)
GameWidget m_gameWidget
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)
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)
PlayerData PlayerData
Camera ActiveCamera
ComponentCreature Target
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