示例#1
0
        public override string ToString()
        {
            var c = Cannons.OrderBy(x => x).ToArray();
            var a = Archers.OrderBy(x => x).ToArray();

            return(string.Join('-', c) + "," + string.Join('-', a));
        }
示例#2
0
 public override void PostDraw()
 {
     foreach (CannonHandler cannon in Cannons.OrderBy(x => x.drawLayer))
     {
         cannon.Draw();
     }
 }
示例#3
0
        public override void PostDraw()
        {
            foreach (CannonHandler cannon in Cannons.OrderBy(x => x.drawLayer))
            {
                if (cannon.CannonTexture != null && cannon.cannonRenderLocation != null)
                {
                    cannon.ValidateLockStatus();
                    try
                    {
                        Vector3             topVectorRotation = new Vector3(cannon.cannonRenderOffset.x, 1f, cannon.cannonRenderOffset.y).RotatedBy(cannon.TurretRotation);
                        Pair <float, float> drawOffset        = HelperMethods.ShipDrawOffset(Pawn.GetComp <CompShips>(), cannon.cannonRenderLocation.x, cannon.cannonRenderLocation.y);
                        Vector3             topVectorLocation = new Vector3(parent.DrawPos.x + drawOffset.First, parent.DrawPos.y + cannon.drawLayer, parent.DrawPos.z + drawOffset.Second);
                        Mesh cannonMesh = cannon.CannonGraphic.MeshAt(Rot4.North);

                        if (RimShipMod.mod.settings.debugDrawCannonGrid)
                        {
                            Material  debugCenterMat = MaterialPool.MatFrom("Debug/cannonCenter");
                            Matrix4x4 debugCenter    = default;
                            debugCenter.SetTRS(topVectorLocation + Altitudes.AltIncVect, Quaternion.identity, new Vector3(0.15f, 1f, 0.15f));
                            Graphics.DrawMesh(MeshPool.plane10, debugCenter, debugCenterMat, 0);
                        }

                        Graphics.DrawMesh(cannonMesh, topVectorLocation, cannon.TurretRotation.ToQuat(), cannon.CannonMaterial, 0);

                        if (cannon.CannonBaseMaterial != null && cannon.baseCannonRenderLocation != null)
                        {
                            Matrix4x4           baseMatrix         = default;
                            Pair <float, float> baseDrawOffset     = HelperMethods.ShipDrawOffset(Pawn.GetComp <CompShips>(), cannon.baseCannonRenderLocation.x, cannon.baseCannonRenderLocation.y);
                            Vector3             baseVectorLocation = new Vector3(parent.DrawPos.x + baseDrawOffset.First, parent.DrawPos.y, parent.DrawPos.z + baseDrawOffset.Second);
                            baseMatrix.SetTRS(baseVectorLocation + Altitudes.AltIncVect, parent.Rotation.AsQuat, new Vector3(cannon.baseCannonDrawSize.x, 1f, cannon.baseCannonDrawSize.y));
                            Graphics.DrawMesh(MeshPool.plane10, baseMatrix, cannon.CannonBaseMaterial, 0);
                        }

                        if (RimShipMod.mod.settings.debugDrawCannonGrid)
                        {
                            Material  debugMat  = MaterialPool.MatFrom("Debug/cannonAlignment");
                            Matrix4x4 debugGrid = default;
                            debugGrid.SetTRS(topVectorLocation + Altitudes.AltIncVect, 0f.ToQuat(), new Vector3(5f, 1f, 5f));
                            Graphics.DrawMesh(MeshPool.plane10, debugGrid, debugMat, 0);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(string.Format("Error occurred during rendering of cannon {0}. Exception: {1}", cannon.cannonDef.label, ex.Message));
                    }
                }
            }
        }