Skip to main content

GymnasiumOnDemandPrefabSpawner

A class in Root.Township, ATT.FeatureTestGymnasium.

Board of buttons in the feature test gymnasium, one per configured prefab plus Destroy All. Server spawns the prefabs in a spawn area; the button layout syncs to clients.

Constructors​

MemberWhat it is
GymnasiumOnDemandPrefabSpawner()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

8 private and internal fields
MemberWhat it is
private Vector3 backgroundSizeSize of the board background, used for the button layout.
private Transform boardTransform the buttons are placed on.
private LabelledButtonWrapper buttonPrefabLabelled button prefab.
private Vector3 buttonPrefabSizeSize of one button, used for the layout.
private uint[] prefabsToSpawnNetwork prefab hashes to make buttons for.
private SpawnArea spawnAreaArea spawned prefabs are placed in.
private readonly List<NetworkEntity> spawnedNetworkPrefabsEntities this board has spawned, for Destroy All.
private MethodSync syncButtonSetupSync for the button setup.

Methods​

MemberWhat it is
override void Initialize()Creates the button setup sync.
void Load(GymnasiumOnDemandPrefabSpawnerData data, ISerializeChildren childSerializer)Loads the prefab list and board position from save, and builds the buttons.
override void OnConnected(Player player)Sends the button setup to the new player.
GymnasiumOnDemandPrefabSpawnerData Save(ISerializeChildren childSerializer)Saves the board position and prefab list.
6 private and internal methods
MemberWhat it is
private LabelledButtonWrapper CreateButton(Vector3 position, float scale)Instantiates a button on the board at a position and scale.
private void DestroyNetworkPrefabs()Server: destroys everything this board has spawned.
private void SetupButton(LabelledButtonWrapper button, Action action, string label)Server: hooks the button's action. Client: sets its label.
private void SetupSpawnButtons()Lays out one button per prefab, named after it, plus a Destroy All button.
private void SpawnNetworkPrefabWithId(uint networkPrefabId)Spawns the prefab at a random point in the spawn area and tracks it.
private void SyncButtonSetup(IPlayer player, Stream stream)Sends the prefab list and board position; clients rebuild the buttons from it.