Open SirPolaris opened 1 month ago
From RHS. Saved incase code base changes.
override void EOnPostFixedFrame(IEntity owner, float timeSlice)
{
vector ownerPosition = owner.GetOrigin(), velocity = m_Physics.GetVelocity();
if (m_WeatherManager)
{
vector force;
force = {0, m_WeatherManager.GetWindDirection(), 0};
force = force.AnglesToVector();
force = {force[1], 0, force[2]};
force *= m_WeatherManager.GetWindSpeed();
m_vWindForce = force * (-m_fWindInfluenceMultiplier);
}
RandomGenerator generator = new RandomGenerator();
generator.SetSeed(m_RplComponent.Id() + m_WeatherManager.GetEngineTime());
float randomInfluence;
if (m_fRandomWindInfluence != 0)
randomInfluence = generator.RandFloatXY(-m_fRandomWindInfluence, m_fRandomWindInfluence);
velocity[0] = velocity[0] + m_vWindForce[0] * timeSlice + randomInfluence;
//velocity[1] = Math.Clamp(velocity[1], -20, 20);
velocity[2] = velocity[2] + m_vWindForce[2] * timeSlice + randomInfluence;
m_Physics.SetVelocity(velocity);
if (ownerPosition[1] + 1 <= owner.GetWorld().GetSurfaceY(ownerPosition[0], ownerPosition[2]))
{
ClearEventMask(owner, EntityEvent.POSTFRAME);
Deploy();
}
if (float.AlmostEqual(velocity[1], 0, 0.5))
{
ClearEventMask(owner, EntityEvent.POSTFRAME);
Deploy();
}
}
Code dynamic wind/wind affecting munitions