public static Graphic GhostGraphicFor(this VehicleDef vehicleDef, VehicleTurret cannon, Color ghostColor) { int num = 0; num = Gen.HashCombine(num, vehicleDef); num = Gen.HashCombine(num, cannon); num = Gen.HashCombineStruct(num, ghostColor); if (!cachedGhostGraphics.TryGetValue(num, out Graphic graphic)) { cannon.ResolveCannonGraphics(vehicleDef, true); graphic = cannon.CannonGraphic; GraphicData graphicData = new GraphicData(); AccessTools.Method(typeof(GraphicData), "Init").Invoke(graphicData, new object[] { }); graphicData.CopyFrom(graphic.data); graphicData.shadowData = null; graphic = GraphicDatabase.Get(graphic.GetType(), graphic.path, ShaderTypeDefOf.EdgeDetect.Shader, graphic.drawSize, ghostColor, Color.white, graphicData, null); cachedGhostGraphics.Add(num, graphic); } return(graphic); }
public void Initialize(VehicleTurret turret) { this.turret = turret; }
void Reset() { body = GetComponentInChildren <VehicleBody>(); turret = GetComponentInChildren <VehicleTurret>(); }
protected virtual void Awake() { m_hForward = false; m_hBackward = false; m_hRight = false; m_hLeft = false; m_hWheels = new List<Wheel>(); m_hRigidbody = this.GetComponent<Rigidbody>(); m_hRigidbody.interpolation = RigidbodyInterpolation.None; //Initialize effective wheels List<Transform> gfxPos = this.GetComponentsInChildren<Transform>().Where(hT => hT.GetComponent<WheelCollider>() == null).ToList(); this.GetComponentsInChildren<WheelCollider>().ToList().ForEach(hW => m_hWheels.Add(new Wheel(hW, gfxPos.OrderBy(hP => Vector3.Distance(hP.position, hW.transform.position)).First().gameObject))); m_hWheels = m_hWheels.OrderByDescending(hW => hW.Collider.transform.localPosition.z).ToList(); //Initialize extra wheels m_hFakeWheels = GetComponentsInChildren<FakeWheel>().ToList(); //Initialize VehicleTurret m_hTurret = GetComponentInChildren<VehicleTurret>(); //Initialize IWeapon m_hCurrentWeapon = GetComponentInChildren<IWeapon>(); m_hActor = GetComponent<Actor>(); //Initialize Drive/Brake System switch (DriveType) { case DriveType.AWD: m_hEngine = new AwdDrive(Hp, m_hWheels); break; case DriveType.RWD: m_hEngine = new RearDrive(Hp, m_hWheels); break; case DriveType.FWD: m_hEngine = new ForwardDrive(Hp, m_hWheels); break; default: break; } m_hConstanForce = this.GetComponent<ConstantForce>(); m_hReverseCOM = new Vector3(0.0f, -2.0f, 0.0f); m_hOriginalCOM = m_hRigidbody.centerOfMass; GroundState hGroundState = new GroundState(this); FlyState hFlyState = new FlyState(this); TurnedState hTurned = new TurnedState(this, m_hReverseCOM); hGroundState.Next = hFlyState; hFlyState.Grounded = hGroundState; hFlyState.Turned = hTurned; hTurned.Next = hFlyState; m_hFlyState = hFlyState; }