mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-13 19:27:46 -04:00
Fixed some small formatting issues
This commit is contained in:
committed by
Julien Lavocat
parent
7909f1adb2
commit
dac1883ae8
@@ -727,61 +727,61 @@ using UnityEngine;
|
||||
|
||||
public abstract class EntityController : MonoBehaviour
|
||||
{
|
||||
const float LERP_DURATION_SEC = 0.1f;
|
||||
const float LERP_DURATION_SEC = 0.1f;
|
||||
|
||||
private static readonly int ShaderColorProperty = Shader.PropertyToID("_Color");
|
||||
private static readonly int ShaderColorProperty = Shader.PropertyToID("_Color");
|
||||
|
||||
[DoNotSerialize] public uint EntityId;
|
||||
[DoNotSerialize] public uint EntityId;
|
||||
|
||||
protected float LerpTime;
|
||||
protected Vector3 LerpStartPosition;
|
||||
protected Vector3 LerpTargetPosition;
|
||||
protected Vector3 TargetScale;
|
||||
protected float LerpTime;
|
||||
protected Vector3 LerpStartPosition;
|
||||
protected Vector3 LerpTargetPosition;
|
||||
protected Vector3 TargetScale;
|
||||
|
||||
protected virtual void Spawn(uint entityId)
|
||||
{
|
||||
EntityId = entityId;
|
||||
protected virtual void Spawn(uint entityId)
|
||||
{
|
||||
EntityId = entityId;
|
||||
|
||||
var entity = GameManager.Conn.Db.Entity.EntityId.Find(entityId);
|
||||
LerpStartPosition = LerpTargetPosition = transform.position = (Vector2)entity.Position;
|
||||
transform.localScale = Vector3.one;
|
||||
TargetScale = MassToScale(entity.Mass);
|
||||
}
|
||||
var entity = GameManager.Conn.Db.Entity.EntityId.Find(entityId);
|
||||
LerpStartPosition = LerpTargetPosition = transform.position = (Vector2)entity.Position;
|
||||
transform.localScale = Vector3.one;
|
||||
TargetScale = MassToScale(entity.Mass);
|
||||
}
|
||||
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
GetComponent<SpriteRenderer>().material.SetColor(ShaderColorProperty, color);
|
||||
}
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
GetComponent<SpriteRenderer>().material.SetColor(ShaderColorProperty, color);
|
||||
}
|
||||
|
||||
public virtual void OnEntityUpdated(Entity newVal)
|
||||
{
|
||||
LerpTime = 0.0f;
|
||||
LerpStartPosition = transform.position;
|
||||
LerpTargetPosition = (Vector2)newVal.Position;
|
||||
TargetScale = MassToScale(newVal.Mass);
|
||||
}
|
||||
public virtual void OnEntityUpdated(Entity newVal)
|
||||
{
|
||||
LerpTime = 0.0f;
|
||||
LerpStartPosition = transform.position;
|
||||
LerpTargetPosition = (Vector2)newVal.Position;
|
||||
TargetScale = MassToScale(newVal.Mass);
|
||||
}
|
||||
|
||||
public virtual void OnDelete(EventContext context)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
public virtual void OnDelete(EventContext context)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
// Interpolate position and scale
|
||||
LerpTime = Mathf.Min(LerpTime + Time.deltaTime, LERP_DURATION_SEC);
|
||||
transform.position = Vector3.Lerp(LerpStartPosition, LerpTargetPosition, LerpTime / LERP_DURATION_SEC);
|
||||
transform.localScale = Vector3.Lerp(transform.localScale, TargetScale, Time.deltaTime * 8);
|
||||
}
|
||||
public virtual void Update()
|
||||
{
|
||||
// Interpolate position and scale
|
||||
LerpTime = Mathf.Min(LerpTime + Time.deltaTime, LERP_DURATION_SEC);
|
||||
transform.position = Vector3.Lerp(LerpStartPosition, LerpTargetPosition, LerpTime / LERP_DURATION_SEC);
|
||||
transform.localScale = Vector3.Lerp(transform.localScale, TargetScale, Time.deltaTime * 8);
|
||||
}
|
||||
|
||||
public static Vector3 MassToScale(uint mass)
|
||||
{
|
||||
var diameter = MassToDiameter(mass);
|
||||
return new Vector3(diameter, diameter, 1);
|
||||
}
|
||||
public static Vector3 MassToScale(uint mass)
|
||||
{
|
||||
var diameter = MassToDiameter(mass);
|
||||
return new Vector3(diameter, diameter, 1);
|
||||
}
|
||||
|
||||
public static float MassToRadius(uint mass) => Mathf.Sqrt(mass);
|
||||
public static float MassToDiameter(uint mass) => MassToRadius(mass) * 2;
|
||||
public static float MassToRadius(uint mass) => Mathf.Sqrt(mass);
|
||||
public static float MassToDiameter(uint mass) => MassToRadius(mass) * 2;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -799,18 +799,18 @@ using UnityEngine;
|
||||
|
||||
namespace SpacetimeDB.Types
|
||||
{
|
||||
public partial class DbVector2
|
||||
{
|
||||
public static implicit operator Vector2(DbVector2 vec)
|
||||
{
|
||||
return new Vector2(vec.X, vec.Y);
|
||||
}
|
||||
public partial class DbVector2
|
||||
{
|
||||
public static implicit operator Vector2(DbVector2 vec)
|
||||
{
|
||||
return new Vector2(vec.X, vec.Y);
|
||||
}
|
||||
|
||||
public static implicit operator DbVector2(Vector2 vec)
|
||||
{
|
||||
return new DbVector2(vec.x, vec.y);
|
||||
}
|
||||
}
|
||||
public static implicit operator DbVector2(Vector2 vec)
|
||||
{
|
||||
return new DbVector2(vec.x, vec.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user