Ejemplo n.º 1
0
        // ===================== Setup Work =====================
        /// <summary>
        /// Initialize instance variables.
        /// </summary>
        ///
        public override void SpawnSetup()
        {
            base.SpawnSetup();

            // Force field covered cells initialization.
            this.coveredCells = Building_ForceFieldGenerator.GetCoveredCells(this.Position, this.Rotation);

            // Force field effect positions.
            Vector3 effectCell = new Vector3();

            effectCell = this.Position.ToVector3Shifted() + new Vector3(-2.1f, 0f, 0.1f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);
            effectCell = this.Position.ToVector3Shifted() + new Vector3(-1.2f, 0f, 0.8f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);
            effectCell = this.Position.ToVector3Shifted() + new Vector3(0f, 0f, 1f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);
            effectCell = this.Position.ToVector3Shifted() + new Vector3(1.2f, 0f, 0.8f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);
            effectCell = this.Position.ToVector3Shifted() + new Vector3(2.1f, 0f, 0.1f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);

            // Components initialization.
            powerComp = base.GetComp <CompPowerTrader>();

            // Textures initialization.
            forceFieldMatrix.SetTRS(base.DrawPos + Altitudes.AltIncVect + new Vector3(0f, 0f, 0.5f).RotatedBy(this.Rotation.AsAngle), this.Rotation.AsAngle.ToQuat(), forceFieldScale);
            forceFieldAbsorbtionMatrix.SetTRS(base.DrawPos + Altitudes.AltIncVect + new Vector3(0f, 0.1f, 0.5f).RotatedBy(this.Rotation.AsAngle), this.Rotation.AsAngle.ToQuat(), forceFieldScale);
        }
Ejemplo n.º 2
0
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            base.DrawGhost(def, center, rot, ghostCol, thing);
            // Display effect zone.
            List <IntVec3> coveredCells = Building_ForceFieldGenerator.GetCoveredCells(center, rot);

            GenDraw.DrawFieldEdges(coveredCells);
        }
Ejemplo n.º 3
0
        // ===================== Setup Work =====================
        /// <summary>
        /// Initialize instance variables.
        /// </summary>
        ///
        public override void SpawnSetup()
        {
            base.SpawnSetup();

            // Force field covered cells initialization.
            this.coveredCells = Building_ForceFieldGenerator.GetCoveredCells(this.Position, this.Rotation);

            // Force field effect positions.
            Vector3 effectCell = new Vector3();

            effectCell = this.Position.ToVector3Shifted() + new Vector3(-2.1f, 0f, 0.1f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);
            effectCell = this.Position.ToVector3Shifted() + new Vector3(-1.2f, 0f, 0.8f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);
            effectCell = this.Position.ToVector3Shifted() + new Vector3(0f, 0f, 1f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);
            effectCell = this.Position.ToVector3Shifted() + new Vector3(1.2f, 0f, 0.8f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);
            effectCell = this.Position.ToVector3Shifted() + new Vector3(2.1f, 0f, 0.1f).RotatedBy(this.Rotation.AsAngle);
            effectCells.Add(effectCell);

            // Components initialization.
            powerComp = base.GetComp <CompPowerTrader>();

            // Get parameters from XML.
            this.forceFieldProperties = this.def as ForceField.ThingDef_ForceFieldGeneratorProperties;

            // Textures initialization.
            forceFieldTexture[0] = MaterialPool.MatFrom("Effects/ForceField1", ShaderDatabase.Transparent);
            forceFieldTexture[1] = MaterialPool.MatFrom("Effects/ForceField2", ShaderDatabase.Transparent);
            forceFieldTexture[2] = MaterialPool.MatFrom("Effects/ForceField3", ShaderDatabase.Transparent);
            forceFieldTexture[3] = MaterialPool.MatFrom("Effects/ForceField4", ShaderDatabase.Transparent);
            forceFieldTexture[4] = MaterialPool.MatFrom("Effects/ForceField5", ShaderDatabase.Transparent);
            forceFieldMatrix.SetTRS(base.DrawPos + Altitudes.AltIncVect + new Vector3(0f, 0f, 0.5f).RotatedBy(this.Rotation.AsAngle), this.Rotation.AsAngle.ToQuat(), forceFieldScale);
            forceFieldAbsorbtionTexture[0] = MaterialPool.MatFrom("Effects/ForceFieldAbsorbtion1", ShaderDatabase.Transparent);
            forceFieldAbsorbtionTexture[1] = MaterialPool.MatFrom("Effects/ForceFieldAbsorbtion2", ShaderDatabase.Transparent);
            forceFieldAbsorbtionTexture[2] = MaterialPool.MatFrom("Effects/ForceFieldAbsorbtion3", ShaderDatabase.Transparent);
            forceFieldAbsorbtionTexture[3] = MaterialPool.MatFrom("Effects/ForceFieldAbsorbtion4", ShaderDatabase.Transparent);
            forceFieldAbsorbtionTexture[4] = MaterialPool.MatFrom("Effects/ForceFieldAbsorbtion5", ShaderDatabase.Transparent);
            forceFieldAbsorbtionMatrix.SetTRS(base.DrawPos + Altitudes.AltIncVect + new Vector3(0f, 0.1f, 0.5f).RotatedBy(this.Rotation.AsAngle), this.Rotation.AsAngle.ToQuat(), forceFieldScale);
        }
        /// <summary>
        /// Checks if a new force field generator can be built at this location.
        /// - must not be too near from another force field generator (or it would perturb other fields).
        /// </summary>
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null)
        {
            // Check if another force field generator is not too close.
            List <Thing>        forceFieldGeneratorList = new List <Thing>();
            IEnumerable <Thing> list = map.listerThings.ThingsOfDef(ThingDef.Named("ForceFieldGenerator"));

            foreach (Thing generator in list)
            {
                forceFieldGeneratorList.Add(generator);
            }
            list = map.listerThings.ThingsOfDef(ThingDef.Named("ForceFieldGenerator").blueprintDef);
            foreach (Thing generator in list)
            {
                forceFieldGeneratorList.Add(generator);
            }
            list = map.listerThings.ThingsOfDef(ThingDef.Named("ForceFieldGenerator").frameDef);
            foreach (Thing generator in list)
            {
                forceFieldGeneratorList.Add(generator);
            }

            foreach (Thing generator in forceFieldGeneratorList)
            {
                if (generator.Position.InHorDistOf(loc, minDistanceBetweenTwoForceFieldGenerators))
                {
                    return(new AcceptanceReport("An other force field generator is too close (it would generate perturbations)."));
                }
            }

            // Display effect zone.
            List <IntVec3> coveredCells = Building_ForceFieldGenerator.GetCoveredCells(loc, rot);

            GenDraw.DrawFieldEdges(coveredCells);

            return(true);
        }