2019-02-01 17:19:20 +00:00
|
|
|
|
using RobloxFiles.Enums;
|
2019-02-01 18:40:39 +00:00
|
|
|
|
using RobloxFiles.Utility;
|
2019-01-26 00:39:37 +00:00
|
|
|
|
|
2019-02-01 17:19:20 +00:00
|
|
|
|
namespace RobloxFiles.DataTypes
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
public class PhysicalProperties
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
public readonly float Density = 1.0f;
|
|
|
|
|
public readonly float Friction = 1.0f;
|
|
|
|
|
public readonly float Elasticity = 0.5f;
|
2019-01-26 00:39:37 +00:00
|
|
|
|
|
2019-02-01 18:40:39 +00:00
|
|
|
|
public readonly float FrictionWeight = 1.0f;
|
|
|
|
|
public readonly float ElasticityWeight = 1.0f;
|
2019-01-26 00:39:37 +00:00
|
|
|
|
|
2019-11-01 02:40:31 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{Density}, {Friction}, {Elasticity}, {FrictionWeight}, {ElasticityWeight}";
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-26 00:39:37 +00:00
|
|
|
|
public PhysicalProperties(Material material)
|
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
if (MaterialInfo.FrictionWeightMap.ContainsKey(material))
|
|
|
|
|
FrictionWeight = MaterialInfo.FrictionWeightMap[material];
|
|
|
|
|
|
2019-01-26 00:39:37 +00:00
|
|
|
|
Density = MaterialInfo.DensityMap[material];
|
|
|
|
|
Friction = MaterialInfo.FrictionMap[material];
|
|
|
|
|
Elasticity = MaterialInfo.ElasticityMap[material];
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-01 18:40:39 +00:00
|
|
|
|
public PhysicalProperties(float density, float friction, float elasticity, float frictionWeight = 1f, float elasticityWeight = 1f)
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
|
|
|
|
Density = density;
|
|
|
|
|
Friction = friction;
|
|
|
|
|
Elasticity = elasticity;
|
|
|
|
|
|
|
|
|
|
FrictionWeight = frictionWeight;
|
|
|
|
|
ElasticityWeight = elasticityWeight;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-01 02:40:31 +00:00
|
|
|
|
internal PhysicalProperties(Attribute attr)
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
2020-09-14 16:20:34 +00:00
|
|
|
|
Density = attr.ReadFloat();
|
|
|
|
|
Friction = attr.ReadFloat();
|
|
|
|
|
Elasticity = attr.ReadFloat();
|
2019-11-01 02:40:31 +00:00
|
|
|
|
|
2020-09-14 16:20:34 +00:00
|
|
|
|
FrictionWeight = attr.ReadFloat();
|
|
|
|
|
ElasticityWeight = attr.ReadFloat();
|
2019-01-26 00:39:37 +00:00
|
|
|
|
}
|
2020-09-13 01:16:19 +00:00
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
int hash = Density.GetHashCode()
|
|
|
|
|
^ Friction.GetHashCode()
|
|
|
|
|
^ Elasticity.GetHashCode()
|
|
|
|
|
^ FrictionWeight.GetHashCode()
|
|
|
|
|
^ ElasticityWeight.GetHashCode();
|
|
|
|
|
|
|
|
|
|
return hash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
2021-02-18 19:15:08 +00:00
|
|
|
|
if (!(obj is PhysicalProperties other))
|
2020-09-13 01:16:19 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!Density.Equals(other.Density))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!Friction.Equals(other.Friction))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!Elasticity.Equals(other.Elasticity))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!FrictionWeight.Equals(other.FrictionWeight))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!ElasticityWeight.Equals(other.ElasticityWeight))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-01-26 00:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|