forked from ExMod-Team/EXILED
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathText.cs
More file actions
119 lines (104 loc) · 5.1 KB
/
Copy pathText.cs
File metadata and controls
119 lines (104 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// -----------------------------------------------------------------------
// <copyright file="Text.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------
namespace Exiled.API.Features.Toys
{
using AdminToys;
using Exiled.API.Enums;
using Exiled.API.Interfaces;
using UnityEngine;
/// <summary>
/// A wrapper class for <see cref="TextToy"/>.
/// </summary>
public class Text : AdminToy, IWrapper<TextToy>
{
/// <summary>
/// Initializes a new instance of the <see cref="Text"/> class.
/// </summary>
/// <param name="textToy">The <see cref="TextToy"/> of the toy.</param>
internal Text(TextToy textToy)
: base(textToy, AdminToyType.TextToy) => Base = textToy;
/// <summary>
/// Gets the prefab.
/// </summary>
public static TextToy Prefab { get; } = PrefabHelper.GetPrefab<TextToy>(PrefabType.TextToy);
/// <summary>
/// Gets the base <see cref="TextToy"/>.
/// </summary>
public TextToy Base { get; }
/// <summary>
/// Gets or sets the Text shown.
/// </summary>
public string TextFormat
{
get => Base.Network_textFormat;
set => Base.Network_textFormat = value;
}
/// <summary>
/// Gets or sets the size of the Display Size of the Text.
/// </summary>
public Vector2 DisplaySize
{
get => Base.Network_displaySize;
set => Base.Network_displaySize = value;
}
/// <summary>
/// Creates a new <see cref="Text"/> at the specified position.
/// </summary>
/// <param name="position">The local position of the <see cref="Text"/>.</param>
/// <param name="text">The text content to display.</param>
/// <returns>The new <see cref="Text"/>.</returns>
public static Text Create(Vector3 position, string text) => Create(position: position, text: text, spawn: true);
/// <summary>
/// Creates a new <see cref="Text"/> with a specific position, text, and display size.
/// </summary>
/// <param name="position">The local position of the <see cref="Text"/>.</param>
/// <param name="text">The text content to display.</param>
/// <param name="displaySize">The display size of the text.</param>
/// <returns>The new <see cref="Text"/>.</returns>
public static Text Create(Vector3 position, string text, Vector2 displaySize) => Create(position: position, text: text, displaySize: displaySize, spawn: true);
/// <summary>
/// Creates a new <see cref="Text"/> based on a Transform.
/// </summary>
/// <param name="transform">The transform to spawn at.</param>
/// <param name="text">The text content to display.</param>
/// <returns>The new <see cref="Text"/>.</returns>
public static Text Create(Transform transform, string text) => Create(parent: transform, text: text, spawn: true);
/// <summary>
/// Creates a new <see cref="Text"/> based on a Transform with custom size.
/// </summary>
/// <param name="transform">The transform to spawn at.</param>
/// <param name="text">The text content to display.</param>
/// <param name="displaySize">The display size of the text.</param>
/// <returns>The new <see cref="Text"/>.</returns>
public static Text Create(Transform transform, string text, Vector2 displaySize) => Create(parent: transform, text: text, displaySize: displaySize, spawn: true);
/// <summary>
/// Creates a new <see cref="Text"/>.
/// </summary>
/// <param name="position">The local position of the <see cref="Text"/>.</param>
/// <param name="rotation">The local rotation of the <see cref="Text"/>.</param>
/// <param name="scale">The local scale of the <see cref="Text"/>.</param>
/// <param name="text">The text content to display.</param>
/// <param name="displaySize">The display size of the text.</param>
/// <param name="parent">The transform to create this <see cref="Text"/> on.</param>
/// <param name="spawn">Whether the <see cref="Text"/> should be initially spawned.</param>
/// <returns>The new <see cref="Text"/>.</returns>
public static Text Create(Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, string text = "Default Text", Vector2? displaySize = null, Transform parent = null, bool spawn = true)
{
Text textToy = new(Object.Instantiate(Prefab, parent))
{
TextFormat = text,
DisplaySize = displaySize ?? new Vector3(50, 50),
LocalPosition = position ?? Vector3.zero,
LocalRotation = rotation ?? Quaternion.identity,
Scale = scale ?? Vector3.one,
};
if (spawn)
textToy.Spawn();
return textToy;
}
}
}