mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 11:39:45 +00:00
49 lines
2.1 KiB
C#
49 lines
2.1 KiB
C#
using MiraAPI.Roles;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace MiraAPI.Example.Roles;
|
|
|
|
[RegisterCustomRole]
|
|
public class ChameloenRole : CrewmateRole, ICustomRole
|
|
{
|
|
public string RoleName => "Chamelon";
|
|
public string RoleLongDescription => "Stay invisible while not moving.";
|
|
public string RoleDescription => RoleLongDescription;
|
|
public Color RoleColor => Palette.AcceptedGreen;
|
|
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
|
|
|
public CustomRoleConfiguration Configuration => new CustomRoleConfiguration(this)
|
|
{
|
|
OptionsScreenshot = ExampleAssets.Banner,
|
|
};
|
|
|
|
public void PlayerControlFixedUpdate(PlayerControl playerControl)
|
|
{
|
|
if (playerControl.MyPhysics.Velocity.magnitude > 0)
|
|
{
|
|
SpriteRenderer rend = playerControl.cosmetics.currentBodySprite.BodySprite;
|
|
TextMeshPro tmp = playerControl.cosmetics.nameText;
|
|
tmp.color = Color.Lerp(tmp.color, new Color(tmp.color.r, tmp.color.g, tmp.color.b, 1), Time.deltaTime * 4f);
|
|
rend.color = Color.Lerp(rend.color, new Color(1, 1, 1, 1), Time.deltaTime * 4f);
|
|
|
|
foreach (var cosmetic in playerControl.cosmetics.transform.GetComponentsInChildren<SpriteRenderer>())
|
|
{
|
|
cosmetic.color = Color.Lerp(cosmetic.color, new Color(1, 1, 1, 1), Time.deltaTime * 4f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SpriteRenderer rend = playerControl.cosmetics.currentBodySprite.BodySprite;
|
|
TextMeshPro tmp = playerControl.cosmetics.nameText;
|
|
tmp.color = Color.Lerp(tmp.color, new Color(tmp.color.r, tmp.color.g, tmp.color.b, playerControl.AmOwner ? 0.3f : 0), Time.deltaTime * 4f);
|
|
rend.color = Color.Lerp(rend.color, new Color(1, 1, 1, playerControl.AmOwner ? 0.3f : 0), Time.deltaTime * 4f);
|
|
|
|
foreach (var cosmetic in playerControl.cosmetics.transform.GetComponentsInChildren<SpriteRenderer>())
|
|
{
|
|
cosmetic.color = Color.Lerp(cosmetic.color, new Color(1, 1, 1, playerControl.AmOwner ? 0.3f : 0), Time.deltaTime * 4f);
|
|
}
|
|
}
|
|
}
|
|
}
|