Skip to content

Commit

Permalink
Big boi
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal78900 committed Sep 26, 2021
1 parent 5ed813d commit 4f1f86d
Show file tree
Hide file tree
Showing 31 changed files with 311 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ public DoorObjectComponent Init(DoorObject doorObject)
{
Base = doorObject;
door = Door.Get(GetComponent<DoorVariant>());
Base.DoorType = door.Type;
Base.DoorType = door.GetDoorTypeByName();

UpdateObject();

return this;
}

/// <summary>
/// The config-base of the object containing all of it's properties.
/// </summary>
public DoorObject Base;

/// <inheritdoc cref="MapEditorObject.UpdateObject()"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Random = UnityEngine.Random;

/// <summary>
/// Used for handling ItemSpawnPoint's spawning items.
/// Component added to spawned ItemSpawnPoint. Is is used for easier idendification of the object and it's variables.
/// </summary>
public class ItemSpawnPointComponent : MapEditorObject
{
Expand All @@ -29,6 +29,9 @@ public ItemSpawnPointComponent Init(ItemSpawnPointObject itemSpawnPoint)
return this;
}

/// <summary>
/// The config-base of the object containing all of it's properties.
/// </summary>
public ItemSpawnPointObject Base;

/// <inheritdoc cref="MapEditorObject.UpdateObject()"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,25 @@
public class LightControllerComponent : MapEditorObject
{
/// <summary>
/// Instantiates <see cref="LightControllerObject"/>.
/// Instantiates <see cref="LightControllerComponent"/>.
/// </summary>
/// <param name="lightControllerObject">The <see cref="LightControllerObject"/> used for instantiating the object.</param>
/// <returns>Instance of this compoment.</returns>
public LightControllerComponent Init(LightControllerObject lightControllerObject)
{
Base = lightControllerObject;

if (Base.RoomType == RoomType.Unknown)
Base.RoomType = RoomType;

UpdateObject();

return this;
}

/// <summary>
/// The config-base of the object containing all of it's properties.
/// </summary>
public LightControllerObject Base;

/// <inheritdoc cref="MapEditorObject.UpdateObject()"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public PlayerSpawnPointComponent Init(PlayerSpawnPointObject playerSpawnPointObj
return this;
}

/// <summary>
/// The config-base of the object containing all of it's properties.
/// </summary>
public PlayerSpawnPointObject Base;

/// <inheritdoc cref="MapEditorObject.UpdateObject()"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public RagdollSpawnPointComponent Init(RagdollSpawnPointObject ragdollSpawnPoint
return this;
}

/// <summary>
/// The config-base of the object containing all of it's properties.
/// </summary>
public RagdollSpawnPointObject Base;

/// <inheritdoc cref="MapEditorObject.UpdateObject()"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public ShootingTargetComponent Init(ShootingTargetObject shootingTargetObject)
return this;
}

/// <summary>
/// The config-base of the object containing all of it's properties.
/// </summary>
public ShootingTargetObject Base;

private ShootingTarget shootingTarget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@
using Mirror;
using UnityEngine;

/// <summary>
/// Component added to both child teleport object that were spawnwed by <see cref="TeleportControllerComponent"/>.
/// </summary>
public class TeleportComponent : MapEditorObject
{
public bool IsEntrance;

/// <summary>
/// Instantiates the teleporter.
/// </summary>
/// <param name="isEntrance">A value indicating whether the teleport is an entrance.</param>
public void Init(bool isEntrance) => IsEntrance = isEntrance;

public IEnumerator<float> FuniCoin()
/// <summary>
/// A value indicating whether the teleport is an entrance.
/// </summary>
public bool IsEntrance;

/// <inheritdoc/>
public IEnumerator<float> SlowdownCoin()
{
float num = spinCoin.Speed / 25;

Expand Down Expand Up @@ -43,8 +54,8 @@ private void Awake()
coinPedestal.Base.gameObject.GetComponent<Rigidbody>().isKinematic = true;

coinPedestal.Scale = new Vector3(10f, 10f, 10f);
if (IsEntrance)
coinPedestal.Scale = new Vector3(10f, -10f, 10f);

coinPedestal.Locked = true;

spinCoin = coinPedestal.Base.gameObject.AddComponent<ItemSpiningComponent>();
spinCoin.Speed = 200f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
using MEC;
using UnityEngine;

/// <summary>
/// Component added to spawned TeleportController. Is is used for easier idendification of the object and it's variables.
/// </summary>
public class TeleportControllerComponent : MapEditorObject
{
/// <summary>
/// Instantiates <see cref="TeleportControllerComponent"/>.
/// </summary>
/// <param name="teleportObject">The <see cref="TeleportObject"/> used for instantiating the object.</param>
/// <returns>Instance of this compoment.</returns>
public TeleportControllerComponent Init(TeleportObject teleportObject)
{
Base = teleportObject;
Expand All @@ -16,10 +24,19 @@ public TeleportControllerComponent Init(TeleportObject teleportObject)
return this;
}

/// <summary>
/// The config-base of the object containing all of it's properties.
/// </summary>
public TeleportObject Base;

/// <summary>
/// The EntranceTeleport object of the <see cref="TeleportControllerComponent"/>.
/// </summary>
public TeleportComponent EntranceTeleport;

/// <summary>
/// The ExitTeleport object of the <see cref="TeleportControllerComponent"/>.
/// </summary>
public TeleportComponent ExitTeleport;

/// <inheritdoc cref="MapEditorObject.UpdateObject()"/>
Expand All @@ -40,14 +57,20 @@ public override void UpdateObject()
}
}

/// <summary>
/// The time when the teleport was last used.
/// </summary>
public DateTime LastUsed;

/// <summary>
/// Method called when a teleport teleports something.
/// </summary>
public void OnTeleported()
{
if (Base.IsVisible)
{
Timing.RunCoroutine(EntranceTeleport.FuniCoin());
Timing.RunCoroutine(ExitTeleport.FuniCoin());
Timing.RunCoroutine(EntranceTeleport.SlowdownCoin());
Timing.RunCoroutine(ExitTeleport.SlowdownCoin());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public WorkStationObjectComponent Init(WorkStationObject workStationObject)
return this;
}

/// <summary>
/// The config-base of the object containing all of it's properties.
/// </summary>
public WorkStationObject Base;
}
}
51 changes: 25 additions & 26 deletions MapEditorReborn/API/Extenstions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,41 @@ public static class Extenstions
/// <param name="mapEditorObject">The <see cref="MapEditorObject"/> which details are gonna be shown.</param>
public static void ShowGameObjectHint(this Player player, MapEditorObject mapEditorObject)
{
/*
mapEditorObject.CurrentRoom = Map.FindParentRoom(mapEditorObject.gameObject);
Vector3 relativePosition = mapEditorObject.RelativePosition;
Vector3 relativeRotation = mapEditorObject.RelativeRotation;
Room room = Map.FindParentRoom(mapEditorObject.gameObject);
Vector3 relativePosition = Handler.GetRelativePosition(mapEditorObject.transform.position, room);
Vector3 relativeRotation = Handler.GetRelativePosition(mapEditorObject.transform.eulerAngles, room);

string message = "<size=30>Selected object type: <color=yellow><b>{objectType}</b></color></size>\n";
message += $"<size=20>" +
$"Position {string.Format("X: <color=yellow><b>{0:F3}</b></color> Y: <color=yellow><b>{1:F3}</b></color> Z: <color=yellow><b>{2:F3}</b></color>", relativePosition.x, relativePosition.y, relativePosition.z)} | " +
$"Rotation {string.Format("X: <color=yellow><b>{0:F3}</b></color> Y: <color=yellow><b>{1:F3}</b></color> Z: <color=yellow><b>{2:F3}</b></color>", relativeRotation.x, relativeRotation.y, relativeRotation.z)} | " +
$"Scale {string.Format("X: <color=yellow><b>{0:F3}</b></color> Y: <color=yellow><b>{1:F3}</b></color> Z: <color=yellow><b>{2:F3}</b></color>", mapEditorObject.Scale.x, mapEditorObject.Scale.y, mapEditorObject.Scale.z)}\n" +
$"RoomType: <color=yellow><b>{mapEditorObject.CurrentRoom.Type}</b></color></size>" +
$"RoomType: <color=yellow><b>{room.Type}</b></color></size>" +
$"</size>\n";

switch (mapEditorObject)
{
case DoorObjectComponent door:
{
message = message.Replace("{objectType}", door.DoorType.ToString());
message = message.Replace("{objectType}", door.Base.DoorType.ToString());
message += $"<size=20>" +
$"IsOpened: {(door.IsOpen ? "<color=green><b></b>TRUE</color>" : "<color=red><b></b>FALSE</color>")}\n" +
$"IsLocked: {(door.IsLocked ? "<color=green><b></b>TRUE</color>" : "<color=red><b></b>FALSE</color>")}\n" +
$"KeycardPermissions: <color=yellow><b>{door.DoorPermissions} ({(ushort)door.DoorPermissions})</b></color>\n" +
$"IgnoredDamageSources: <color=yellow><b>{door.IgnoredDamageTypes} ({(byte)door.IgnoredDamageTypes})</b></color>\n" +
$"DoorHealth: <color=yellow><b>{door.MaxHealth}</b></color>\n" +
$"OpenOnWarheadActivation: {(door.OpenOnWarheadActivation ? "<color=green><b></b>TRUE</color>" : "<color=red><b></b>FALSE</color>")}" +
$"IsOpened: {(door.Base.IsOpen ? "<color=green><b></b>TRUE</color>" : "<color=red><b></b>FALSE</color>")}\n" +
$"IsLocked: {(door.Base.IsLocked ? "<color=green><b></b>TRUE</color>" : "<color=red><b></b>FALSE</color>")}\n" +
$"KeycardPermissions: <color=yellow><b>{door.Base.KeycardPermissions} ({(ushort)door.Base.KeycardPermissions})</b></color>\n" +
$"IgnoredDamageSources: <color=yellow><b>{door.Base.IgnoredDamageSources} ({(byte)door.Base.IgnoredDamageSources})</b></color>\n" +
$"DoorHealth: <color=yellow><b>{door.Base.DoorHealth}</b></color>\n" +
$"OpenOnWarheadActivation: {(door.Base.OpenOnWarheadActivation ? "<color=green><b></b>TRUE</color>" : "<color=red><b></b>FALSE</color>")}" +
$"</size>";

break;
}

case WorkstationObjectComponent workstation:
case WorkStationObjectComponent workstation:
{
message = message.Replace("{objectType}", "Workstation");

message += $"<size=20>" +
$"IsInteractable: <color=yellow><b>{workstation.IsInteractable}</b></color>" +
$"IsInteractable: <color=yellow><b>{workstation.Base.IsInteractable}</b></color>" +
$"</size>";
break;
}
Expand Down Expand Up @@ -93,10 +92,10 @@ public static void ShowGameObjectHint(this Player player, MapEditorObject mapEdi
message = message.Replace("{objectType}", "ItemSpawnPoint");

message += $"<size=20>" +
$"ItemType: <color=yellow><b>{itemSpawnPoint.ItemName}</b></color>\n" +
$"AttachmentsCode: <color=yellow><b>{itemSpawnPoint.AttachmentsCode}</b></color>\n" +
$"SpawnChance: <color=yellow><b>{itemSpawnPoint.SpawnChance}</b></color>\n" +
$"NumberOfItems: <color=yellow><b>{itemSpawnPoint.NumberOfItems}</b></color>" +
$"Item: <color=yellow><b>{itemSpawnPoint.Base.Item}</b></color>\n" +
$"AttachmentsCode: <color=yellow><b>{itemSpawnPoint.Base.AttachmentsCode}</b></color>\n" +
$"SpawnChance: <color=yellow><b>{itemSpawnPoint.Base.SpawnChance}</b></color>\n" +
$"NumberOfItems: <color=yellow><b>{itemSpawnPoint.Base.NumberOfItems}</b></color>" +
$"</size>";

break;
Expand All @@ -107,28 +106,28 @@ public static void ShowGameObjectHint(this Player player, MapEditorObject mapEdi
message = message.Replace("{objectType}", "RagdollSpawnPoint");

message += $"<size=20>" +
$"Name: <color=yellow><b>{ragdollSpawnPoint.RagdollName}</b></color>\n" +
$"RoleType: <color=yellow><b>{ragdollSpawnPoint.RagdollRoleType}</b></color>\n" +
$"DeathCause: <color=yellow><b>{ragdollSpawnPoint.RagdollDamageType.ConvertToDamageType().Name}</b></color>" +
$"Name: <color=yellow><b>{ragdollSpawnPoint.Base.Name}</b></color>\n" +
$"RoleType: <color=yellow><b>{ragdollSpawnPoint.Base.RoleType}</b></color>\n" +
$"DeathCause: <color=yellow><b>{ragdollSpawnPoint.Base.DamageType.ConvertToDamageType().Name}</b></color>" +
$"</size>";

break;
}

case ShootingTargetComponent shootingTarget:
{
message = message.Replace("{objectType}", shootingTarget.TargetType + "ShootingTarget");
message = message.Replace("{objectType}", shootingTarget.Base.TargetType + "ShootingTarget");

message += $"<size=20>" +
$"Type: <color=yellow><b>{shootingTarget.TargetType}</b></color>" +
$"Type: <color=yellow><b>{shootingTarget.Base.TargetType}</b></color>\n" +
$"IsFunctional: <color=yellow><b>{shootingTarget.Base.IsFunctional}</b></color>" +
$"</size>";

break;
}
}
*/
// player.ShowHint(message, 9999f);
player.ShowHint("Zaznaczoned", 9999f);

player.ShowHint(message, 9999f);
}

/// <summary>
Expand Down
24 changes: 24 additions & 0 deletions MapEditorReborn/API/Objects/TeleportObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using Exiled.API.Enums;
using UnityEngine;

/// <summary>
/// Represents <see cref="Handler.TeleporterObj"/> used by the plugin to spawn and save LightControllers to a file.
/// </summary>
[Serializable]
public class TeleportObject
{
Expand All @@ -14,18 +17,39 @@ public TeleportObject()
{
}

/// <summary>
/// Gets or sets the entrance teleport's position.
/// </summary>
public Vector3 EntranceTeleporterPosition { get; set; } = Vector3.zero;

/// <summary>
/// Gets or sets the <see cref="RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// </summary>
public RoomType EntranceTeleporterRoomType { get; set; } = RoomType.Unknown;

/// <summary>
/// Gets or sets the exit teleport's position.
/// </summary>
public Vector3 ExitTeleporterPosition { get; set; } = Vector3.zero;

/// <summary>
/// Gets or sets the <see cref="RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// </summary>
public RoomType ExitTeleporterRoomType { get; set; } = RoomType.Unknown;

/// <summary>
/// Gets or sets the teleport's teleport cooldown.
/// </summary>
public float TeleportCooldown { get; set; } = 10f;

/// <summary>
/// Gets or sets a value indicating whether the teleport can teleport in both ways (exit will behave like the entrance).
/// </summary>
public bool BothWayMode { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether the teleport is visible by the players.
/// </summary>
public bool IsVisible { get; set; } = true;
}
}
3 changes: 2 additions & 1 deletion MapEditorReborn/Commands/MapEditorParrentCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class MapEditorParrentCommand : ParentCommand
public override void LoadGeneratedCommands()
{
RegisterCommand(new CreateObject());
RegisterCommand(new SelectObject());
RegisterCommand(new DeleteObject());

RegisterCommand(new ToolGun());
Expand Down Expand Up @@ -54,7 +55,7 @@ protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSe
{
if (player.CheckPermission($"mpr.{command.Command}"))
{
response += $"- {command.Command} ({command.Aliases[0]})\n{command.Description}\n\n";
response += $"- {command.Command} ({string.Join(", ", command.Aliases)})\n{command.Description}\n\n";
}
}

Expand Down
Loading

0 comments on commit 4f1f86d

Please sign in to comment.