Beispiel #1
0
        private void ReadMaterialModifierSection()
        {
            MaterialModifiers = new List <MaterialModifier>();

            int nbrMaterialModifiers = ReadLineAsInt();

            for (int i = 0; i < nbrMaterialModifiers; i++)
            {
                MaterialModifier modifier = new MaterialModifier
                {
                    CarWallFriction  = ReadLineAsFloat(false),
                    TyreRoadFriction = Math.Min(1, ReadLineAsFloat(false)),      /* deal with weird (wrong?) settings for grass on cityb maps*/
                    Downforce        = ReadLineAsFloat(false),
                    Bumpiness        = ReadLineAsFloat(false),
                    TyreSoundIndex   = ReadLineAsInt(),
                    CrashSoundIndex  = ReadLineAsInt(),
                    ScrapeSoundIndex = ReadLineAsInt(),
                    Sparkiness       = ReadLineAsFloat(false),
                    SmokeTableIndex  = ReadLineAsInt()
                };

                string matName = ReadLine();
                if (matName != "none")
                {
                    if (!File.Exists(GameVars.BasePath + "material\\" + matName))
                    {
                        matName = "SKIDMARK.MAT"; //default skidmark if invalid (in indust maps, this is "1" and skidmarks aren't shown)
                    }
                    MatFile matFile = new MatFile(matName);
                    modifier.SkidMaterial = matFile.Materials[0];
                    modifier.SkidMaterial.ResolveTexture();
                }
                MaterialModifiers.Add(modifier);
            }
        }
Beispiel #2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (IsPartOfMasks(col.gameObject.layer, collisionMasks))
        {
            return;
        }

        if (IsPartOfMasks(col.gameObject.layer, targetMasks))
        {
            Health health = col.transform.root.GetComponent <Health>();


            if (health && health.IsAlive())
            {
                MaterialModifier modifier = col.transform.root.GetComponentInChildren <MaterialModifier>();
                if (modifier)
                {
                    modifier.SetTintColor(new Color(1, 0, 0, 1f));
                }

                health.ChangeHealth(-damage);
                CinemachineShake.Instance.ShakeCamera(5, 0.2f);
            }
        }

        GameObject effect = FindObjectsOfType <EffectPooler>()
                            .First(pooler => pooler.effectType == collisionEffectType)
                            .GetPooledObject();

        effect.transform.position = transform.position;
        effect.gameObject.SetActive(true);
        effect.GetComponent <DesactivateObject>().Desactivate(.25f);
        gameObject.SetActive(false);
    }
Beispiel #3
0
    public IEnumerator FadeHud(float targetFade)
    {
        fadeValue = 1 - targetFade;

        List <MaskableGraphic> images   = hudCanvas.GetComponentsInChildren <MaskableGraphic>(true).ToList();
        MaterialModifier       modifier = playerProfile.GetComponent <MaterialModifier>();

        if (modifier)
        {
            modifier.SetMainColor(new Color(1, 1, 1, fadeValue), 2.5f);
        }

        if (images.Count == 0)
        {
            yield break;
        }
        while (Mathf.Abs(fadeValue - targetFade) > 0.01f)
        {
            fadeValue = Mathf.Lerp(fadeValue, targetFade, 0.125f);
            foreach (var img in images)
            {
                Color color = img.color;
                color.a   = fadeValue;
                img.color = color;
            }

            yield return(new WaitForSeconds(0.005f));
        }
    }
    void Start()
    {
        health        = GetComponent <Health>();
        towerAnimator = towerGFX.GetComponent <Animator>();
        modifier      = GetComponentInChildren <MaterialModifier>();

        currentEvolution = TowerEvolutions.Evolution1;
        currentSettings  = GetTowerSettings(currentEvolution);
    }
Beispiel #5
0
    //Event handler for health change
    public void OnPlayerHit()
    {
        MaterialModifier modifier = playerProfile.GetComponent <MaterialModifier>();

        if (modifier)
        {
            modifier.SetTintColor(new Color(1, 0, 0, 1f));
        }
    }
    IEnumerator TiltColor()
    {
        while (true)
        {
            MaterialModifier modifier = GetComponentInChildren <MaterialModifier>();

            modifier.SetTintColor(new Color(1, 1, 1, 1f));
            yield return(new WaitForSeconds(0.2f));
        }
    }
Beispiel #7
0
 internal void AddMaterialModifier(SniperMaterial materialMask, MaterialModifier modifier)
 {
     foreach (KeyValuePair <SniperMaterial, List <MaterialModifier> > kv in this.materialModifiers)
     {
         if (materialMask.Flag(kv.Key))
         {
             kv.Value.Add(modifier);
         }
     }
 }
    //Apply explosion effect and cast ripple that deal damage to players inside the radisu
    IEnumerator CastExplosion()
    {
        //This time corresponds to the duration of the explosion animation
        yield return(new WaitForSeconds(.9f));

        GameObject rippleEffect = FindObjectsOfType <EffectPooler>()
                                  .First(pooler => pooler.effectType == EffectType.Shockwave)
                                  .GetPooledObject();

        rippleEffect.transform.position = transform.position;
        rippleEffect.SetActive(true);
        rippleEffect.GetComponent <DesactivateObject>().Desactivate(.45f);
        CinemachineShake.Instance.ShakeCamera(10, 0.25f);

        RaycastHit2D[] explosionHits = Physics2D.CircleCastAll(transform.position, enemySettings.explosionRadius, Vector2.up, enemySettings.explosionRadius, targetsMask);
        foreach (RaycastHit2D hit in explosionHits)
        {
            Health health = hit.transform.GetComponent <Health>();
            if (health && health.IsAlive())
            {
                MaterialModifier modifier = hit.transform.root.GetComponentInChildren <MaterialModifier>();
                if (modifier)
                {
                    modifier.SetTintColor(new Color(1, 0, 0, 1f));
                }
                health.ChangeHealth(-enemySettings.explosionDamage);
            }
        }

        yield return(new WaitForSeconds(0.5f));

        GameManager.Instance.OnMobKilled.Invoke(EnemyType.Slime);


        //Drop Health Potion
        ItemPooler itemPooler = FindObjectsOfType <ItemPooler>().ToList().First(pooler => pooler.itemType == ItemType.Health);

        if (Random.Range(0f, 1f) > 0.5f)
        {
            if (itemPooler != null)
            {
                var healthPotion = itemPooler.GetPooledObject();
                healthPotion.transform.position = transform.position;
                healthPotion.SetActive(true);
            }
        }


        gameObject.SetActive(false);
    }
Beispiel #9
0
        public void Update()
        {
            WheelContactData wcd = Shape.GetContactData();

            UpdateMatrices(wcd);
            ContactPoint = wcd.ContactPoint;

            SmokeEmitter.Enabled = false;
            IsSkiddingLat        = IsSkiddingLng = ShouldPlaySkidSound = false;

            if (wcd.ContactForce != 0)
            {
                int materialIndex = (int)wcd.OtherShapeMaterialIndex;
                MaterialModifier materialModifier = Race.Current.ConfigFile.MaterialModifiers[materialIndex];
                materialModifier.UpdateWheelShape(_chassis, this);

                LatSlip = wcd.LateralSlip;

                if (_chassis.Speed > 10 && (_handbrake == 1 || Math.Abs(wcd.LateralSlip) > 0.23f))
                {
                    IsSkiddingLat        = true;
                    SmokeEmitter.Enabled = true;
                }
                else if (_chassis.Speed > 3 && Shape.MotorTorque != 0 && CActor.IsDriven && wcd.LongitudalSlip > 0.04f)
                {
                    IsSkiddingLng        = true;
                    SmokeEmitter.Enabled = true;
                }

                // Setup tire functions taking into account handbrake and terrain
                float latExtremum = _defaultLatExtremum;
                if (IsRear)
                {
                    latExtremum = MathHelper.Lerp(1.9f, 1.05f, _handbrake);
                }
                latExtremum *= materialModifier.TyreRoadFriction;
                _latTireFn.ExtremumValue = latExtremum;

                _lngTireFn.ExtremumValue          = _defaultLngExtremum * materialModifier.TyreRoadFriction;
                Shape.LateralTireForceFunction    = _latTireFn;
                Shape.LongitudalTireForceFunction = _lngTireFn;

                ShouldPlaySkidSound = IsSkiddingLat | IsSkiddingLng && materialIndex == 0;
                SmokeEmitter.Update(wcd.ContactPoint);
            }
        }
Beispiel #10
0
    void Start()
    {
        Camera.main.FadeIn(5f, Easing.Type.CircularIn);

        mobPooler = FindObjectOfType <EnemyPooler>();
        health    = GetComponent <Health>();
        modifier  = GetComponentInChildren <MaterialModifier>();

        //Collect all tiles locations from patrol tilemap
        BoundsInt mapBounds = patrolMap.cellBounds;

        foreach (var pos in mapBounds.allPositionsWithin)
        {
            Vector3Int localPlace = new Vector3Int(pos.x, pos.y, pos.z);
            Vector3    place      = patrolMap.CellToWorld(localPlace);
            if (patrolMap.HasTile(localPlace))
            {
                tilemapLocations.Add(place);
            }
        }
    }
Beispiel #11
0
        public void Save(string path)
        {
            using (DocumentWriter dw = new DocumentWriter(path))
            {
                dw.WriteLine($"VERSION {Version}", Version > 1 ? "V1 expects map checkpoint rectangles" : null);
                if (Version >= 2)
                {
                    dw.WriteLine(null, "V2 and above expect map checkpoint points");
                }
                if (Version >= 3)
                {
                    dw.WriteLine(null, "V3 and above expect splash file stuff at the end");
                }
                if (Version >= 4)
                {
                    dw.WriteLine(null, "V4 and above expect two sets of PIX and MAT and ped substitution entry");
                }
                dw.WriteLine();

                if (Version == 1)
                {
                    dw.WriteLine();
                    dw.WriteLine("//////////// GLOBAL LIGHTING DATA ///////////");
                    dw.WriteLine();
                    dw.WriteLine($"{LightColour.X},{LightColour.Y},{LightColour.Z}", "RGB for main directional light-source");
                    dw.WriteLine($"{DiffuseLight0.X:F1},{DiffuseLight0.Y:F1}", "Ambient/Diffuse light to be used when plaything ambient says 0				}--- Neither of these have smooth lighting effecs applied");
                    dw.WriteLine($"{DiffuseLight1.X:F1},{DiffuseLight1.Y:F1}", "Ambient/Diffuse light to be used when plaything ambient says 1				}");
                    dw.WriteLine($"{DiffuseLightOther.X:F1},{DiffuseLightOther.Y:F1}", "Ambient/Diffuse light to be used when plaything ambient says anything else");
                    dw.WriteLine();
                    dw.WriteLine("/////////////////////////////////////////////");
                    dw.WriteLine();
                }

                dw.WriteLine();

                dw.WriteLine($"{GridPosition.X},{GridPosition.Y},{GridPosition.Z}", "Position of centre of start of grid");
                dw.WriteLine($"{GridRotation}", "Direction that grid faces in");

                dw.WriteLine();
                dw.WriteLine("// Laps, checkpoints etc");
                dw.WriteLine();

                dw.WriteLine($"{Checkpoints.Count}", "# checkpoints");
                for (int i = 0; i < Checkpoints.Count; i++)
                {
                    Checkpoint checkpoint = Checkpoints[i];

                    dw.WriteLine($"// Checkpoint #{i + 1}");
                    dw.WriteLine($"{checkpoint.TimerIncrements.X},{checkpoint.TimerIncrements.Y},{checkpoint.TimerIncrements.Z}", "Timer increment for each skill level (ped mode)");
                    dw.WriteLine($"{checkpoint.Points.Count / 4}", "# quads for this checkpoint");

                    for (int j = 0; j < checkpoint.Points.Count; j++)
                    {
                        Vector3 point = checkpoint.Points[j];

                        dw.WriteLine($"{point.X},{point.Y},{point.Z}", $"Point #{j}");
                    }
                }

                dw.WriteLine();
                dw.WriteLine("// Smashable environment specs");
                dw.WriteLine();

                dw.WriteLine($"{Smashables.Count}", "Number of smash specs");
                dw.WriteLine();

                foreach (SmashData smash in Smashables)
                {
                    dw.WriteLine("// Start of smashable item");
                    dw.WriteLine($"{smash.Flags}", "Flags");
                    dw.WriteLine($"{smash.Trigger}", "Name of trigger material");
                    dw.WriteLine($"{smash.TriggerMode}", "Mode");

                    switch (smash.TriggerMode)
                    {
                    case SmashData.SmashTriggerMode.nochange:
                    case SmashData.SmashTriggerMode.remove:
                        dw.WriteLine($"{smash.RemovalThreshold}", "Removal threshold");
                        dw.IncreaseIndent();
                        smash.Connotations.Write(dw);
                        dw.DecreaseIndent();
                        break;

                    case SmashData.SmashTriggerMode.replacemodel:
                        dw.WriteLine($"{smash.RemovalThreshold}", "Removal threshold");
                        dw.WriteLine();
                        dw.IncreaseIndent();
                        smash.Connotations.Write(dw);
                        dw.DecreaseIndent();
                        dw.WriteLine($"{smash.NewModel}", "new model");
                        dw.WriteLine($"{smash.ChanceOfFire}", "%chance fire");

                        if (smash.ChanceOfFire > 0)
                        {
                            dw.WriteLine($"{smash.NumFires}");
                            dw.WriteLine($"{string.Join(",", smash.SmokeLevel)}");
                        }
                        break;

                    case SmashData.SmashTriggerMode.texturechange:
                        dw.WriteLine($"{smash.IntactMaterial}", "Intact pixelmap");
                        dw.WriteLine($"{smash.Levels.Count}", "Number of levels");

                        int j = 1;

                        foreach (SmashDataTextureLevel textureLevel in smash.Levels)
                        {
                            dw.WriteLine();
                            dw.WriteLine($"{textureLevel.TriggerThreshold}", "Trigger threshold");
                            dw.WriteLine($"{textureLevel.Flags}", "Flags");
                            dw.WriteLine($"{textureLevel.CollisionType}", "Collision type");
                            dw.IncreaseIndent();
                            textureLevel.Connotations.Write(dw);
                            dw.DecreaseIndent();
                            dw.WriteLine();
                            dw.WriteLine($"{textureLevel.Pixelmaps.Count}", "Number of pixelmap");
                            foreach (string pixelmap in textureLevel.Pixelmaps)
                            {
                                dw.WriteLine($"{pixelmap}", $"Pixelmap");
                            }

                            j++;
                        }
                        break;
                    }

                    dw.WriteLine($"{smash.Reserved1}", "reserved 1");
                    dw.WriteLine($"{smash.Reserved2}", "reserved 2");
                    dw.WriteLine($"{smash.Reserved3}", "reserved 3");
                    dw.WriteLine($"{smash.Reserved4}", "reserved 4");
                }

                dw.WriteLine();
                dw.WriteLine("// Ped specs");
                dw.WriteLine();

                dw.WriteLine($"{PedSpecs.Count}");

                foreach (PedSpec pedspec in PedSpecs)
                {
                    dw.WriteLine();
                    dw.WriteLine($"{pedspec.MaterialName}", "Material name");
                    dw.WriteLine($"{pedspec.MovementIndex}", "Movement index");
                    dw.WriteLine($"{pedspec.GroupIndex}", "Group index");
                    dw.WriteLine($"{pedspec.PedsPer100SquareMetres}", "Peds per 100 square metres");
                    dw.WriteLine($"{pedspec.ExclusionMaterials.Count}", "Number of exclusion materials");

                    foreach (PedExclusionMaterial pedExclusionMaterial in pedspec.ExclusionMaterials)
                    {
                        dw.WriteLine($"{pedExclusionMaterial.Flags}", "Exclusion flags (1 = OK when scared)");
                        dw.WriteLine($"{pedExclusionMaterial.Name}", "Exclusion material #1 name");
                    }

                    dw.WriteLine($"{pedspec.ExceptionMaterials.Count}", "Number of exception materials");
                }

                dw.WriteLine();

                dw.WriteLine($"{AdditionalActor}", "Additional actor");

                dw.WriteLine();
                dw.WriteLine("// HORIZON STUFF");
                dw.WriteLine();

                dw.WriteLine($"{SkyPixelmap}", @"Name of sky texture pixelmap (or ""none"")");
                dw.WriteLine($"{HorizontalRepetitions}", "Horizontal repetitions of sky texture");
                dw.WriteLine($"{VerticalSize}", "Vertical size of sky texture (degrees)");
                dw.WriteLine($"{PositionOfHorizon}", "Position of horizon (pixels below top)");
                dw.WriteLine($"{DepthCueMode}", @"Depth cue mode (""none"", ""dark"" or ""fog"")");
                dw.WriteLine($"{FogDarkness.X},{FogDarkness.Y}", "Degree of fog/darkness");
                dw.WriteLine($"{DepthCueColour.X},{DepthCueColour.Y},{DepthCueColour.Z}", "Depth cue colour (red, green, blue )");

                dw.WriteLine();
                dw.WriteLine("// DEFAULT ENGINE NOISE");
                dw.WriteLine();

                dw.WriteLine($"{DefaultEngineNoise}");

                dw.WriteLine();
                dw.WriteLine("// SPECIAL EFFECTS VOLUMES");
                dw.WriteLine();

                dw.WriteLine($"{SpecialVolumes.Count}", "# special effects volumes");

                foreach (SpecialEffectVolume volume in SpecialVolumes)
                {
                    dw.WriteLine();
                    dw.WriteLine($"{volume.Type}");

                    foreach (Vector3 corner in volume.Corners)
                    {
                        dw.WriteLine($"{corner.X:F3}, {corner.Y:F3}, {corner.Z:F3}");
                    }

                    dw.WriteLine($"{volume.GravityMultiplier:F2}", "gravity multiplier");
                    dw.WriteLine($"{volume.ViscosityMultiplier:F2}", "viscosity multiplier");
                    dw.WriteLine($"{volume.CarDamagePerMillisecond:F2}", "Car damage per millisecond");
                    dw.WriteLine($"{volume.PedDamagePerMillisecond:F2}", "Pedestrian damage per millisecond");
                    dw.WriteLine($"{volume.CameraEffectIndex}", "camera effect index");
                    dw.WriteLine($"{volume.SkyColour}", "sky colour");
                    dw.WriteLine($"{volume.WindscreenMaterial}", "Windscreen texture to use");
                    dw.WriteLine($"{volume.EntrySoundID}", "Sound ID of entry noise");
                    dw.WriteLine($"{volume.ExitSoundID}", "Sound ID of exit noise");
                    dw.WriteLine($"{volume.EngineNoiseIndex}", "Engine noise index");
                    dw.WriteLine($"{volume.MaterialIndex}", "material index");

                    if (volume.Type.ToUpper() == "BOX")
                    {
                        dw.WriteLine($"{volume.SoundType}", "Sound type");

                        if (volume.SoundType != SpecialEffectVolume.SpecVolSoundType.NONE)
                        {
                            volume.SoundSpec.Write(dw);
                        }
                    }
                }

                dw.WriteLine();
                dw.WriteLine("// SOUND GENERATORS");
                dw.WriteLine();

                dw.WriteLine($"{SoundGenerators.Count}", "Number of generators");

                dw.WriteLine();
                dw.WriteLine("// REFLECTIVE WINDSCREEN SPECIFICATIONS");
                dw.WriteLine();

                dw.WriteLine($"{MaterialDefault}", "Material to use for default screens");
                dw.WriteLine($"{MaterialDarkness}", "Material to use for default screens during darkness");
                dw.WriteLine($"{MaterialFog}", "Material to use for default screens during fog");

                dw.WriteLine();

                dw.WriteLine("0", "(ignore) # areas with different screens");

                dw.WriteLine();
                dw.WriteLine("// MAP DETAILS");
                dw.WriteLine();

                dw.WriteLine($"{MapPixelmap}", "Map pixelmap name");
                dw.WriteLine();
                dw.WriteLine($"{WorldMapTransform.M11,7:0.###},{WorldMapTransform.M12,11:0.###},{WorldMapTransform.M13,11:0.###}", "World->map transformation matrix");
                dw.WriteLine($"{WorldMapTransform.M21,7:0.###},{WorldMapTransform.M22,11:0.###},{WorldMapTransform.M23,11:0.###}");
                dw.WriteLine($"{WorldMapTransform.M31,7:0.###},{WorldMapTransform.M32,11:0.###},{WorldMapTransform.M33,11:0.###}");
                dw.WriteLine($"{WorldMapTransform.M41,7:0.###},{WorldMapTransform.M42,11:0.###},{WorldMapTransform.M43,11:0.###}");

                dw.WriteLine();
                dw.WriteLine("// ****** START OF FUNK AND GROOVE STUFF ******");
                dw.WriteLine();

                dw.WriteLine();
                dw.WriteLine("START OF FUNK");
                dw.WriteLine();

                for (int i = 0; i < Funks.Count; i++)
                {
                    Funk funk = Funks[i];

                    dw.WriteLine($"{funk.Material}");
                    dw.WriteLine($"{funk.Mode}");
                    dw.WriteLine($"{funk.MatrixModType}");
                    if (funk.MatrixModType != FunkMatrixMode.None)
                    {
                        dw.WriteLine($"{funk.MatrixModMode}");
                    }

                    switch (funk.MatrixModType)
                    {
                    case FunkMatrixMode.roll:
                        dw.WriteLine($"{funk.RollPeriods.X},{funk.RollPeriods.Y}");
                        break;

                    case FunkMatrixMode.slither:
                        dw.WriteLine($"{funk.SlitherSpeed.X},{funk.SlitherSpeed.Y}");
                        dw.WriteLine($"{funk.SlitherAmount.X},{funk.SlitherAmount.Y}");
                        break;

                    case FunkMatrixMode.spin:
                        dw.WriteLine($"{funk.SpinPeriod}");
                        break;
                    }

                    dw.WriteLine($"{funk.LightingMode}");
                    dw.WriteLine($"{funk.AnimationType}");

                    switch (funk.AnimationType)
                    {
                    case FunkAnimationType.frames:
                        dw.WriteLine($"{funk.Framerate}");
                        dw.WriteLine($"{funk.FrameMode}");

                        switch (funk.FrameMode)
                        {
                        case FrameType.texturebits:
                            dw.WriteLine($"{funk.TextureBitMode}");
                            break;

                        case FrameType.continuous:
                            dw.WriteLine($"{funk.FrameSpeed}");
                            break;
                        }

                        dw.WriteLine($"{funk.Frames.Count}");
                        foreach (string frame in funk.Frames)
                        {
                            dw.WriteLine($"{frame}");
                        }
                        break;
                    }

                    if (i + 1 != Funks.Count)
                    {
                        dw.WriteLine();
                        dw.WriteLine("NEXT FUNK");
                        dw.WriteLine();
                    }
                }

                dw.WriteLine();
                dw.WriteLine("END OF FUNK");
                dw.WriteLine();

                dw.WriteLine();
                dw.WriteLine("START OF GROOVE");
                dw.WriteLine();

                for (int i = 0; i < Grooves.Count; i++)
                {
                    Groove groove = Grooves[i];

                    dw.WriteLine($"{groove.Part}", "Actor name of moving part");
                    dw.WriteLine($"{groove.LollipopMode}");
                    dw.WriteLine($"{groove.Mode}");
                    dw.WriteLine($"{groove.PathType}");
                    if (groove.PathType != GroovePathNames.None)
                    {
                        dw.WriteLine($"{groove.PathMode}");
                    }

                    switch (groove.PathType)
                    {
                    case GroovePathNames.straight:
                        dw.WriteLine($"{groove.PathCentre.X},{groove.PathCentre.Y},{groove.PathCentre.Z}");
                        dw.WriteLine($"{groove.PathPeriod}");
                        dw.WriteLine($"{groove.PathDelta.X},{groove.PathDelta.Y},{groove.PathDelta.Z}");
                        break;
                    }

                    dw.WriteLine($"{groove.AnimationType}");
                    if (groove.AnimationType != GrooveAnimation.None)
                    {
                        dw.WriteLine($"{groove.AnimationMode}");
                    }

                    switch (groove.AnimationType)
                    {
                    case GrooveAnimation.rock:
                        dw.WriteLine($"{groove.AnimationPeriod}");
                        dw.WriteLine($"{groove.AnimationCentre.X},{groove.AnimationCentre.Y},{groove.AnimationCentre.Z}");
                        dw.WriteLine($"{groove.AnimationAxis}");
                        dw.WriteLine($"{groove.RockMaxAngle}");
                        break;

                    case GrooveAnimation.shear:
                        dw.WriteLine($"{groove.ShearPeriod.X},{groove.ShearPeriod.Y},{groove.ShearPeriod.Z}");
                        dw.WriteLine($"{groove.AnimationCentre.X},{groove.AnimationCentre.Y},{groove.AnimationCentre.Z}");
                        dw.WriteLine($"{groove.ShearMagnitude.X},{groove.ShearMagnitude.Y},{groove.ShearMagnitude.Z}");
                        break;

                    case GrooveAnimation.spin:
                        dw.WriteLine($"{groove.AnimationPeriod}");
                        dw.WriteLine($"{groove.AnimationCentre.X},{groove.AnimationCentre.Y},{groove.AnimationCentre.Z}");
                        dw.WriteLine($"{groove.AnimationAxis}");
                        break;
                    }

                    if (i + 1 != Grooves.Count)
                    {
                        dw.WriteLine();
                        dw.WriteLine("NEXT GROOVE");
                        dw.WriteLine();
                    }
                }

                dw.WriteLine();
                dw.WriteLine("END OF GROOVE");
                dw.WriteLine();
                dw.WriteLine("START OF OPPONENT PATHS");
                dw.WriteLine();

                dw.WriteLine($"{Nodes.Count}", "Number of path nodes");

                int n = 0;
                foreach (Vector3 node in Nodes)
                {
                    dw.WriteLine($"{node.X,9:F3},{node.Y,9:F3},{node.Z,9:F3}", $"Node #{n}");
                    n++;
                }

                dw.WriteLine();

                dw.WriteLine($"{Paths.Count}", "Number of path sections");

                n = 0;
                foreach (OpponentPathSection pathSection in Paths)
                {
                    dw.WriteLine($"{pathSection.StartNode,4},{pathSection.EndNode,4},{pathSection.Unknown1,4},{pathSection.Unknown2,4},{pathSection.Unknown3,4},{pathSection.Unknown4,4},{pathSection.Width,7:F1},{pathSection.SectionType,5}", $"Section #{n}");
                    n++;
                }

                dw.WriteLine();

                dw.WriteLine($"{CopStartPoints.Count}", "Number of cop start points");

                dw.WriteLine();
                dw.WriteLine("END OF OPPONENT PATHS");
                dw.WriteLine();

                dw.WriteLine();
                dw.WriteLine("START OF DRONE PATHS");
                dw.WriteLine();

                dw.WriteLine($"{DronePathVersion}", "version");
                dw.WriteLine($"{DronePaths.Count}", "n_nodes");

                for (int i = 0; i < DronePaths.Count; i++)
                {
                    DronePathNode node = DronePaths[i];

                    dw.WriteLine();
                    dw.WriteLine($"// {i}:");
                    dw.IncreaseIndent();
                    dw.WriteLine($"{node.Position.X:F3}, {node.Position.Y:F3}, {node.Position.Z:F3}");
                    dw.WriteLine($"{node.DroneName}");
                    dw.WriteLine($"{node.UnknownInt}");
                    dw.WriteLine($"{node.Destinations.Count}");
                    dw.IncreaseIndent();
                    foreach (string destination in node.Destinations)
                    {
                        dw.WriteLine($"{destination}");
                    }
                    dw.DecreaseIndent();
                    dw.DecreaseIndent();
                }

                dw.WriteLine();
                dw.WriteLine("END OF DRONE PATHS");
                dw.WriteLine();

                dw.WriteLine($"{MaterialModifiers.Count}", "number of material modifiers");

                for (int i = 0; i < MaterialModifiers.Count; i++)
                {
                    dw.WriteLine($"// {(i == 0 ? "default material" : $"material '{i - 1}'")}");

                    MaterialModifier materialModifier = MaterialModifiers[i];
                    dw.WriteLine($"{materialModifier.CarWallFriction:0.0##}", "car wall friction");
                    dw.WriteLine($"{materialModifier.TyreRoadFriction:0.0##}", "tyre road friction");
                    dw.WriteLine($"{materialModifier.DownForce:0.0##}", "down force");
                    dw.WriteLine($"{materialModifier.Bumpiness:0.0##}", "bumpiness");
                    dw.WriteLine($"{materialModifier.TyreSoundIndex}", "tyre sound index");
                    dw.WriteLine($"{materialModifier.CrashSoundIndex}", "crash sound index");
                    dw.WriteLine($"{materialModifier.ScrapeNoiseIndex}", "scrape noise index");
                    dw.WriteLine($"{materialModifier.Sparkiness:0.0##}", "sparkiness");
                    dw.WriteLine($"{materialModifier.RoomForExpansion}", "room for expansion");
                    dw.WriteLine($"{materialModifier.SkidmarkMaterial}", "skid mark material");
                }

                dw.WriteLine();
                dw.WriteLine("// Non CarObjects");
                dw.WriteLine($"{Noncars.Count}");
                foreach (string noncar in Noncars)
                {
                    dw.WriteLine($"{noncar}");
                }

                dw.WriteLine();

                dw.WriteLine($"{ShadeTables.Count}", "number of dust shade tables");
                foreach (ShadeTable shade in ShadeTables)
                {
                    dw.WriteLine($"{shade.RGB.X}, {shade.RGB.Y}, {shade.RGB.Z}", "r g b values");
                    dw.WriteLine($"{shade.Strengths.X}, {shade.Strengths.Y}, {shade.Strengths.Z}", @"quarter, half and three quarter ""strength""");
                }

                dw.WriteLine();

                dw.WriteLine($"{NetworkStarts.Count}", "Number of network start points");
                n = 0;
                foreach (NetworkStart start in NetworkStarts)
                {
                    dw.WriteLine();
                    dw.WriteLine($"{start.Position.X:F3}, {start.Position.Y:F3}, {start.Position.Z:F3}", $"{n}");
                    dw.WriteLine($"{start.Rotation}");
                    n++;
                }

                dw.WriteLine();

                dw.WriteLine($"{SplashFiles.Count}", "number of splash files");
                foreach (string splash in SplashFiles)
                {
                    dw.WriteLine($"{splash}", "name of pixelmapfile for splashes");
                }

                dw.WriteLine();

                dw.WriteLine($"{TxtFiles.Count}");
                foreach (string txt in TxtFiles)
                {
                    dw.WriteLine($"{txt}");
                }
            }
Beispiel #12
0
        private void ReadMaterialModifierSection()
        {
            MaterialModifiers = new List<MaterialModifier>();

            int nbrMaterialModifiers = ReadLineAsInt();
            for (int i = 0; i < nbrMaterialModifiers; i++)
            {
                MaterialModifier modifier = new MaterialModifier
                    {
                        CarWallFriction = ReadLineAsFloat(false),
                        TyreRoadFriction = Math.Min(1, ReadLineAsFloat(false)),  /* deal with weird (wrong?) settings for grass on cityb maps*/
                        Downforce = ReadLineAsFloat(false),
                        Bumpiness = ReadLineAsFloat(false),
                        TyreSoundIndex = ReadLineAsInt(),
                        CrashSoundIndex = ReadLineAsInt(),
                        ScrapeSoundIndex = ReadLineAsInt(),
                        Sparkiness = ReadLineAsFloat(false),
                        SmokeTableIndex = ReadLineAsInt()
                    };

                string matName = ReadLine();
                if (matName != "none")
                {
                    if (!File.Exists(GameVars.BasePath + "material\\" + matName))
                    {
                        matName = "SKIDMARK.MAT"; //default skidmark if invalid (in indust maps, this is "1" and skidmarks aren't shown)
                    }
                    MatFile matFile = new MatFile(matName);
                    modifier.SkidMaterial = matFile.Materials[0];
                    modifier.SkidMaterial.ResolveTexture();
                }
                MaterialModifiers.Add(modifier);
            }
        }