Own main menu (game's Continue/New Game/Credits/Changelog/Quit hidden, QUIT in the launcher); new server profile layout; admin items: ratchet set, battery, shop items; session shows server player limit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+44
-6
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using HutongGames.PlayMaker;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MSCO
|
||||
@@ -7,31 +8,59 @@ namespace MSCO
|
||||
/// Admin: Items spawnen. Kopiert ein vorhandenes Item des Spiels (z.B. "beer case(itemx)" aus dem Laden) und
|
||||
/// setzt die Kopie an die gewünschte Stelle. Die Kopie behält den Namen des Originals, damit sich die Spiel-Logik
|
||||
/// (Trinken, Essen, Tanken ...) wie beim echten Item verhält und der Objekt-Sync sie bei allen gleich benennt.
|
||||
/// Werkzeuge wie der Ratschenkasten sind im Spiel keine Gegenstände, sondern ein Schalter ("hat der Spieler") -
|
||||
/// die werden dem Admin direkt gegeben.
|
||||
/// </summary>
|
||||
public static class ItemSpawner
|
||||
{
|
||||
/// <summary>Auswahl im Admin-Menü (Name ohne "(itemx)").</summary>
|
||||
/// <summary>Werkzeug statt Gegenstand: globale Spielvariable, die "gekauft" bedeutet.</summary>
|
||||
public const string RatchetSet = "ratchet set";
|
||||
|
||||
/// <summary>Auswahl im Admin-Menü (Anzeigename).</summary>
|
||||
public static readonly string[] Items =
|
||||
{
|
||||
"beer case", "sausages", "pizza", "macaron box", "milk", "juice", "ground coffee", "sugar", "yeast", "booze",
|
||||
"gasoline", "diesel", "spray can", "fire extinguisher", "flashlight", "lantern", "car jack", "floor jack",
|
||||
"spanner set", "sledgehammer", "radio", "camera", "grill charcoal", "fireworks bag", "water bucket"
|
||||
// Werkzeug / Auto
|
||||
RatchetSet, "spanner set", "battery", "car jack", "floor jack", "motor hoist", "flashlight", "lantern",
|
||||
"fire extinguisher", "spray can", "sledgehammer", "ax", "digging bar",
|
||||
// Flüssigkeiten / Kraftstoff
|
||||
"motor oil", "coolant", "brake fluid", "two stroke fuel", "gasoline", "diesel", "n2o bottle",
|
||||
// Essen / Trinken / Laden
|
||||
"beer case", "beer", "booze", "vodka shot", "milk", "juice", "coffee", "ground coffee", "sugar", "yeast",
|
||||
"sausages", "pizza", "macaron box", "potato chips", "cigarettes", "mosquito spray", "grill charcoal",
|
||||
// Sonstiges
|
||||
"grill", "radio", "camera", "helmet", "bucket", "water bucket", "fireworks bag", "parts magazine"
|
||||
};
|
||||
|
||||
// Items, die im Spiel nicht "(itemx)" heißen
|
||||
static readonly Dictionary<string, string> objectNames = new Dictionary<string, string>
|
||||
{
|
||||
{ "battery", "battery(Clone)" }
|
||||
};
|
||||
|
||||
static readonly Dictionary<string, GameObject> templates = new Dictionary<string, GameObject>();
|
||||
|
||||
public static bool IsKnown(string item) { return System.Array.IndexOf(Items, item) >= 0; }
|
||||
|
||||
static string ObjectName(string item)
|
||||
{
|
||||
string name;
|
||||
return objectNames.TryGetValue(item, out name) ? name : item + "(itemx)";
|
||||
}
|
||||
|
||||
static GameObject FindTemplate(string item)
|
||||
{
|
||||
GameObject cached;
|
||||
if (templates.TryGetValue(item, out cached) && cached != null) return cached;
|
||||
|
||||
string name = item + "(itemx)";
|
||||
string name = ObjectName(item);
|
||||
GameObject best = null;
|
||||
foreach (Object o in Resources.FindObjectsOfTypeAll(typeof(GameObject)))
|
||||
{
|
||||
var go = (GameObject)o;
|
||||
if (go.name != name || go.GetComponent<Rigidbody>() == null) continue;
|
||||
if (best == null || (go.activeInHierarchy && !best.activeInHierarchy)) best = go; // am liebsten ein echtes in der Welt
|
||||
// Keine eingebauten Teile kopieren (z.B. die Batterie im Auto): nicht unter einem anderen Rigidbody
|
||||
if (go.transform.parent != null && go.transform.parent.GetComponentInParent<Rigidbody>() != null) continue;
|
||||
if (best == null || (go.activeInHierarchy && !best.activeInHierarchy)) best = go; // am liebsten eins aus der Welt
|
||||
}
|
||||
templates[item] = best;
|
||||
return best;
|
||||
@@ -60,6 +89,15 @@ namespace MSCO
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Ratschenkasten "kaufen": der Spieler hat ihn dann wie nach dem Kauf im Laden.</summary>
|
||||
public static bool GiveRatchetSet()
|
||||
{
|
||||
FsmBool has = FsmVariables.GlobalVariables.FindFsmBool("PlayerHasRatchet");
|
||||
if (has == null) return false;
|
||||
has.Value = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void ClearCache() { templates.Clear(); }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user