public void RemoveWheels(ModuleWheels wheels) { this.allSegments["WheelsRpm"].ManipulateObj(new List <object> { wheels }, "CLEAN"); this.allSegments["WheelsBrake"].ManipulateObj(new List <object> { wheels }, "CLEAN"); this.allSegments["WheelsTorque"].ManipulateObj(new List <object> { wheels }, "CLEAN"); this.allSegments["WheelsGrip"].ManipulateObj(new List <object> { wheels }, "CLEAN"); this.allSegments["WheelsSuspension"].ManipulateObj(new List <object> { wheels }, "CLEAN"); this.allSegments["WheelsTurnAngle"].ManipulateObj(new List <object> { wheels }, "CLEAN"); this.RefreshWheels(new List <ModuleWheels> { wheels }); this.wheelsListGeneric.Remove(wheels); this.wheelsList.Remove(wheels); }
static bool Prefix(ref ModuleWheels __instance) { BuffController buff = BuffController.MakeNewIfNone(__instance.block.tank); buff.RemoveWheels(__instance); return(true); }
public static void RefreshWheels(List <TankBlock> blockList) { FieldInfo field_TorqueParams = typeof(ModuleWheels) // Maybe I should find a way to compress these? .GetField("m_TorqueParams", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo field_Wheels = typeof(ModuleWheels) .GetField("m_Wheels", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo field_WheelParams = typeof(ModuleWheels) .GetField("m_WheelParams", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo field_AttachedId = typeof(ManWheels.Wheel) .GetField("attachedID", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo field_WheelState = typeof(ManWheels) .GetField("m_WheelState", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); Console.WriteLine("FFW! Update Wheels. Count: " + blockList.Count); foreach (TankBlock block in blockList) { ModuleWheels wheels = block.GetComponent <ModuleWheels>(); ManWheels.TorqueParams torque = (ManWheels.TorqueParams)field_TorqueParams.GetValue(wheels); // Read active Torque... ManWheels.WheelParams wheelparams = (ManWheels.WheelParams)field_WheelParams.GetValue(wheels); // Read active WheelParams... List <ManWheels.Wheel> value_Wheels = (List <ManWheels.Wheel>)field_Wheels.GetValue(wheels); foreach (ManWheels.Wheel wheel in value_Wheels) { Array value_WheelState = (Array)field_WheelState.GetValue(Singleton.Manager <ManWheels> .inst); int value_WheelAttachedId = (int)field_AttachedId.GetValue(wheel); // Important, determines what AttachedWheelState is associated if (value_WheelAttachedId > -1) // value is -1 if it's unloaded, I think... { object value_AttachedWheelState = value_WheelState.GetValue(value_WheelAttachedId); // AttachedWheelState is a PRIVATE STRUCT, `object` neccessary FieldInfo field_p_TorqueParams = value_AttachedWheelState.GetType() // Get types of private struct... .GetField("torqueParams", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo field_p_WheelParams = value_AttachedWheelState.GetType() .GetField("wheelParams", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); field_p_TorqueParams.SetValue(value_AttachedWheelState, torque); // Apply new Torque to ManWheels.Wheel field_p_WheelParams.SetValue(value_AttachedWheelState, wheelparams); // Apply new WheelParams... FieldInfo field_p_Inertia = value_AttachedWheelState.GetType() .GetField("inertia", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); ManWheels.WheelParams value_WheelParams = (ManWheels.WheelParams)field_WheelParams.GetValue(wheels); // Note: Keep these incase inertia read causes issues //float i = wheels.block.CurrentMass * 0.9f / (float)value_Wheels.Count * value_WheelParams.radius * value_WheelParams.radius; ModuleWheels.AttachData moduleData = new ModuleWheels.AttachData(wheels, (float)field_p_Inertia.GetValue(value_AttachedWheelState), value_Wheels.Count); wheel.UpdateAttachData(moduleData); // Update it! Live! Do it! } } } }