Esempio n. 1
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (Ambient != null)
         {
             hashCode = hashCode * 59 + Ambient.GetHashCode();
         }
         if (Diffuse != null)
         {
             hashCode = hashCode * 59 + Diffuse.GetHashCode();
         }
         if (Specular != null)
         {
             hashCode = hashCode * 59 + Specular.GetHashCode();
         }
         if (Roughness != null)
         {
             hashCode = hashCode * 59 + Roughness.GetHashCode();
         }
         if (Fresnel != null)
         {
             hashCode = hashCode * 59 + Fresnel.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Determines whether the specified <see cref="MaterialPalette"/> is equal to the current <see cref="UFLT.Records.MaterialPalette"/>.
        /// </summary>
        /// <param name='other'>
        /// The <see cref="MaterialPalette"/> to compare with the current <see cref="UFLT.Records.MaterialPalette"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="MaterialPalette"/> is equal to the current
        /// <see cref="UFLT.Records.MaterialPalette"/>; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(MaterialPalette other)
        {
            // Check color fields
            if (!Ambient.Equals(other.Ambient))
            {
                return(false);
            }
            if (!Diffuse.Equals(other.Diffuse))
            {
                return(false);
            }
            if (!Specular.Equals(other.Specular))
            {
                return(false);
            }
            if (!Emissive.Equals(other.Emissive))
            {
                return(false);
            }

            if (Mathf.Approximately(Shininess, other.Shininess))
            {
                return(false);
            }
            if (Mathf.Approximately(Alpha, other.Alpha))
            {
                return(false);
            }

            return(true);
        }
        public void Save(SaveContext saveContext)
        {
            var utility = saveContext.Utility;

            CGFXDebug.SaveStart(this, saveContext);

            EmissionF.Save(utility);
            AmbientF.Save(utility);
            DiffuseF.Save(utility);
            Specular0F.Save(utility);
            Specular1F.Save(utility);
            Constant0F.Save(utility);
            Constant1F.Save(utility);
            Constant2F.Save(utility);
            Constant3F.Save(utility);
            Constant4F.Save(utility);
            Constant5F.Save(utility);

            Emission.Save(utility);
            Ambient.Save(utility);
            Diffuse.Save(utility);
            Specular0.Save(utility);
            Specular1.Save(utility);
            Constant0.Save(utility);
            Constant1.Save(utility);
            Constant2.Save(utility);
            Constant3.Save(utility);
            Constant4.Save(utility);
            Constant5.Save(utility);

            utility.Write(CommandCache);
        }
        public void CreateBabylonMaterial(BabylonScene scene)
        {
            var babylonMaterial = new BabylonMaterial();

            scene.MaterialsList.Add(babylonMaterial);

            // Guid
            babylonMaterial.id = ID.ToString();

            // Name
            babylonMaterial.name = Name;

            // Data
            babylonMaterial.backFaceCulling = BackFaceCulling;
            babylonMaterial.diffuse         = Diffuse.ToArray();
            babylonMaterial.emissive        = Emissive.ToArray();
            babylonMaterial.specular        = Specular.ToArray();
            babylonMaterial.specularPower   = SpecularPower;
            babylonMaterial.alpha           = Alpha;

            if (string.IsNullOrEmpty(DiffuseTexture))
            {
                babylonMaterial.diffuseTexture = null;
                return;
            }

            babylonMaterial.diffuseTexture      = new BabylonTexture();
            babylonMaterial.diffuseTexture.name = Path.GetFileName(DiffuseTexture);

            scene.AddTexture(DiffuseTexture);
        }
Esempio n. 5
0
 public bool Equals(Material other)
 {
     return(Color.Equals(other.Color) &&
            Ambient.Equals(other.Ambient) &&
            Diffuse.Equals(other.Diffuse) &&
            Specular.Equals(other.Specular) &&
            Shininess.Equals(other.Shininess));
 }
 public void Dispose()
 {
     Diffuse?.Dispose();
     Ambient?.Dispose();
     Normal?.Dispose();
     Specular?.Dispose();
     Reflection?.Dispose();
 }
        public RayScattered Scatter(Diffuse diffuse, Ray ray, RayHitpoint hitpoint, Color rayColor)
        {
            var target   = hitpoint.Point + hitpoint.Normal + Maths.GetRandomInSphere();
            var newRay   = new Ray(hitpoint.Point, target - hitpoint.Point);
            var newColor = new Color(rayColor.Value * diffuse.Albedo);

            return(new RayScattered(newRay, newColor));
        }
 public virtual void Visit(MaterialGeneratorContext context)
 {
     Surface.Visit(context);
     MicroSurface.Visit(context);
     Diffuse.Visit(context);
     DiffuseModel.Visit(context);
     Specular.Visit(context);
     SpecularModel.Visit(context);
 }
Esempio n. 9
0
 public override int GetHashCode()
 {
     return((int)(
                (Name.GetHashCode() * 3) +
                (Ambient.GetHashCode() * 5) +
                (Diffuse.GetHashCode() * 7) +
                (Specular.GetHashCode() * 11) +
                (Emissive.GetHashCode() * 13) +
                (Reflectivity * 17) +
                (Opacity * 19)));
 }
Esempio n. 10
0
        public void DiffuseMaterialShouldPassItsColorWhenScatter()
        {
            Color     albedo  = Color.FromColor4(Color4.Beige);
            IMaterial diffuse = new Diffuse(albedo);
            HitInfo   i       = new HitInfo();
            Ray       r       = new Ray();

            diffuse.Scatter(ref r, ref i, out Color attenuation, out Ray ray);

            attenuation.Should().Be(albedo);
        }
        public override void Accept(ShaderGeneratorContext context)
        {
            base.Accept(context);

            Surface.Accept(context);
            MicroSurface.Accept(context);
            Diffuse.Accept(context);
            DiffuseModel.Accept(context);
            Specular.Accept(context);
            SpecularModel.Accept(context);
        }
Esempio n. 12
0
        public odfMaterialPropertySet Clone()
        {
            odfMaterialPropertySet prop = new odfMaterialPropertySet();

            prop.Unknown1      = Unknown1;
            prop.Diffuse       = new Color4(Diffuse.ToVector4());
            prop.Ambient       = new Color4(Ambient.ToVector4());
            prop.Specular      = new Color4(Specular.ToVector4());
            prop.Emissive      = new Color4(Emissive.ToVector4());
            prop.SpecularPower = SpecularPower;
            return(prop);
        }
Esempio n. 13
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Ambient.GetHashCode();
         hashCode = (hashCode * 397) ^ Color.Truncate().GetHashCode();
         hashCode = (hashCode * 397) ^ Diffuse.Truncate().GetHashCode();
         hashCode = (hashCode * 397) ^ Shininess.Truncate().GetHashCode();
         hashCode = (hashCode * 397) ^ Specular.Truncate().GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 14
0
        public override int GetHashCode()
        {
            int hashCode = -2043694805;

            hashCode = hashCode * -1521134295 + Ambient.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <Color> .Default.GetHashCode(Color);

            hashCode = hashCode * -1521134295 + Diffuse.GetHashCode();
            hashCode = hashCode * -1521134295 + Shininess.GetHashCode();
            hashCode = hashCode * -1521134295 + Specular.GetHashCode();
            return(hashCode);
        }
Esempio n. 15
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Pattern != null ? Pattern.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Ambient.GetHashCode();
         hashCode = (hashCode * 397) ^ Diffuse.GetHashCode();
         hashCode = (hashCode * 397) ^ Specular.GetHashCode();
         hashCode = (hashCode * 397) ^ Reflective.GetHashCode();
         hashCode = (hashCode * 397) ^ Shininess;
         return(hashCode);
     }
 }
Esempio n. 16
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Color != null?Color.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ Ambient.GetHashCode();
                hashCode = (hashCode * 397) ^ Diffuse.GetHashCode();
                hashCode = (hashCode * 397) ^ Specular.GetHashCode();
                hashCode = (hashCode * 397) ^ Shininess.GetHashCode();
                return(hashCode);
            }
        }
Esempio n. 17
0
 public override int GetHashCode()
 {
     return
         (Color.GetHashCode() ^
          Ambient.GetHashCode() ^
          Diffuse.GetHashCode() ^
          Specular.GetHashCode() ^
          Shininess.GetHashCode() ^
          Pattern.GetHashCode() ^
          Reflective.GetHashCode() ^
          Transparency.GetHashCode() ^
          RefractiveIndex.GetHashCode());
 }
Esempio n. 18
0
        public override void Save(asStream stream)
        {
            stream.PutString(Name, 32);

            Emission.CopyTo(stream);

            Ambient.CopyTo(stream);
            Diffuse.CopyTo(stream);

            Specular.CopyTo(stream);

            stream.Put(Shininess);
            stream.Put(Reserved);
        }
Esempio n. 19
0
        public override bool Equals(object obj)
        {
            var other = obj as Material;

            return((other != null) &&
                   (Color.Equals(other.Color)) &&
                   (Ambient.IsEqual(other.Ambient)) &&
                   (Diffuse.IsEqual(other.Diffuse)) &&
                   (Specular.IsEqual(other.Specular)) &&
                   (Shininess.IsEqual(other.Shininess)) &&
                   (Reflective.IsEqual(other.Reflective)) &&
                   (Transparency.IsEqual(other.Transparency)) &&
                   (RefractiveIndex.IsEqual(other.RefractiveIndex)));
        }
Esempio n. 20
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Lighting other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     VertexNormalsEpsilon == other.VertexNormalsEpsilon ||
                     VertexNormalsEpsilon != null &&
                     VertexNormalsEpsilon.Equals(other.VertexNormalsEpsilon)
                     ) &&
                 (
                     FaceNormalsEpsilon == other.FaceNormalsEpsilon ||
                     FaceNormalsEpsilon != null &&
                     FaceNormalsEpsilon.Equals(other.FaceNormalsEpsilon)
                 ) &&
                 (
                     Ambient == other.Ambient ||
                     Ambient != null &&
                     Ambient.Equals(other.Ambient)
                 ) &&
                 (
                     Diffuse == other.Diffuse ||
                     Diffuse != null &&
                     Diffuse.Equals(other.Diffuse)
                 ) &&
                 (
                     Specular == other.Specular ||
                     Specular != null &&
                     Specular.Equals(other.Specular)
                 ) &&
                 (
                     Roughness == other.Roughness ||
                     Roughness != null &&
                     Roughness.Equals(other.Roughness)
                 ) &&
                 (
                     Fresnel == other.Fresnel ||
                     Fresnel != null &&
                     Fresnel.Equals(other.Fresnel)
                 ));
        }
        public override PSOutput PSMain(PSInput input)
        {
            PSOutput output = base.PSMain(input);

            Surface.Compute();
            MicroSurface.Compute();
            Diffuse.Compute();
            Specular.Compute();

            ComputeSurfaceLightingAndShading();

            ShaderBaseStream.ColorTarget = new Vector4(MaterialPixelShadingStream.ShadingColor, MaterialPixelShadingStream.ShadingColorAlpha);
            output.ColorTarget           = ShaderBaseStream.ColorTarget;

            return(output);
        }
Esempio n. 22
0
 public bool Equals(Material other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return
         (Ambient.IsEquivalentTo(other.Ambient) &&
          Color.IsEquivalentTo(other.Color) &&
          Diffuse.IsEquivalentTo(other.Diffuse) &&
          Shininess.IsEquivalentTo(other.Shininess) &&
          Specular.IsEquivalentTo(other.Specular));
 }
Esempio n. 23
0
        public DxLight GetLight()
        {
            DxLight light = new DxLight
            {
                Type        = LightType,
                Position    = Position.ToVector3(),
                Direction   = Direction.ToVector3(),
                Ambient     = Ambient.ToVector4(),
                Diffuse     = Diffuse.ToVector4(),
                Specular    = Specular.ToVector4(),
                Attenuation = new Vector3(0.0f, 0.005f, 0.0f),
                SpotPower   = 0.001f,
                Range       = 1000f
            };

            return(light);
        }
Esempio n. 24
0
 public override void Apply(Matrix world)
 {
     base.Apply(world);
     Effect.CurrentTechnique = Effect.Techniques[0];
     Effect.Parameters["World"].SetValue(world);
     Effect.Parameters["View"].SetValue(Camera.Current.View);
     Effect.Parameters["Projection"].SetValue(Camera.Current.Projection);
     Effect.Parameters["LightPosition"].SetValue(Light.Current.Transform.Position);
     Effect.Parameters["CameraPosition"].SetValue(Camera.Current.Transform.Position);
     Effect.Parameters["Shininess"].SetValue(Shininess);
     Effect.Parameters["AmbientColor"].SetValue(Ambient.ToVector4() * Light.Current.Ambient.ToVector4());
     Effect.Parameters["DiffuseColor"].SetValue(Diffuse.ToVector4() * Light.Current.Diffuse.ToVector4());
     Effect.Parameters["SpecularColor"].SetValue(Specular.ToVector4() * Light.Current.Specular.ToVector4());
     Effect.Parameters["Tiling"].SetValue(Tiling);
     Effect.Parameters["Offset"].SetValue(Offset);
     Effect.Parameters["DiffuseTexture"].SetValue(Texture);
     Effect.CurrentTechnique.Passes[0].Apply();
 }
Esempio n. 25
0
 public void Validate()
 {
     if (!Color.IsColor())
     {
         throw new ArgumentException("Color is not a color", nameof(Color));
     }
     if (!Ambient.IsInUnitRange())
     {
         throw new ArgumentOutOfRangeException(nameof(Ambient));
     }
     if (!Diffuse.IsInUnitRange())
     {
         throw new ArgumentOutOfRangeException(nameof(Diffuse));
     }
     if (!Specular.IsInUnitRange())
     {
         throw new ArgumentOutOfRangeException(nameof(Specular));
     }
     if (!Shininess.IsPositive())
     {
         throw new ArgumentOutOfRangeException(nameof(Shininess));
     }
 }
Esempio n. 26
0
        public override int GetHashCode()
        {
            var hashCode = 412502415;

            hashCode = hashCode * -1521134295 + EqualityComparer <Pattern> .Default.GetHashCode(pattern);

            hashCode = hashCode * -1521134295 + EqualityComparer <Color> .Default.GetHashCode(color);

            hashCode = hashCode * -1521134295 + ambient.GetHashCode();
            hashCode = hashCode * -1521134295 + diffuse.GetHashCode();
            hashCode = hashCode * -1521134295 + specular.GetHashCode();
            hashCode = hashCode * -1521134295 + shinniness.GetHashCode();
            hashCode = hashCode * -1521134295 + reflective.GetHashCode();
            hashCode = hashCode * -1521134295 + refractiveIndex.GetHashCode();
            hashCode = hashCode * -1521134295 + transparency.GetHashCode();
            hashCode = hashCode * -1521134295 + Ambient.GetHashCode();
            hashCode = hashCode * -1521134295 + Diffuse.GetHashCode();
            hashCode = hashCode * -1521134295 + Specular.GetHashCode();
            hashCode = hashCode * -1521134295 + Shinniness.GetHashCode();
            hashCode = hashCode * -1521134295 + Reflective.GetHashCode();
            hashCode = hashCode * -1521134295 + RefracIndex.GetHashCode();
            hashCode = hashCode * -1521134295 + Transparency.GetHashCode();
            return(hashCode);
        }
        public override PSOutput PSMain(PSInput input)
        {
            PSOutput output = base.PSMain(input);

            SamplingContext samplingContext;

            samplingContext.Sampler           = Sampler;
            samplingContext.TextureCoordinate = input.TextureCoordinate;

            uint      actualId    = input.InstanceId / RenderTargetCount;
            Matrix4x4 worldMatrix = WorldMatrices[actualId];

            ViewProjectionTransform viewProjectionTransform = ViewProjectionTransforms[input.TargetId];
            Matrix4x4 inverseViewMatrix = viewProjectionTransform.InverseViewMatrix;

            Vector3 eyePosition   = inverseViewMatrix.Translation;
            Vector4 positionWS    = input.PositionWS;
            Vector3 worldPosition = new Vector3(positionWS.X, positionWS.Y, positionWS.Z);
            Vector3 viewWS        = Vector3.Normalize(eyePosition - worldPosition);

            Vector3 materialNormal        = Surface.ComputeNormal(samplingContext);
            float   roughness             = MicroSurface.ComputeRoughness(samplingContext);
            Vector4 diffuseColorWithAlpha = Diffuse.ComputeDiffuseColor(samplingContext);
            Vector3 diffuseColor          = new Vector3(diffuseColorWithAlpha.X, diffuseColorWithAlpha.Y, diffuseColorWithAlpha.Z);
            Vector3 specularColor         = Specular.ComputeSpecularColor(samplingContext, ref diffuseColor);

            Matrix4x4 tangentToWorldMatrix = GetTangentToWorldMatrix(worldMatrix, input.Normal, input.Tangent);
            Vector3   normalWS             = Vector3.Normalize(Vector3.TransformNormal(materialNormal, tangentToWorldMatrix));

            if (!input.IsFrontFace)
            {
                normalWS = -normalWS;
            }

            Vector3 directLightingContribution = Vector3.Zero;

            for (int i = 0; i < DirectionalLights.LightCount; i++)
            {
                Vector3 lightColor     = DirectionalLights.ComputeLightColor(i);
                Vector3 lightDirection = DirectionalLights.ComputeLightDirection(i);

                MaterialShadingContext context;
                context.H              = Vector3.Normalize(viewWS + lightDirection);
                context.NDotL          = Math.Max(Vector3.Dot(normalWS, lightDirection), 0.0001f);
                context.NDotV          = Math.Max(Vector3.Dot(normalWS, viewWS), 0.0001f);
                context.NDotH          = Vector3.Dot(normalWS, context.H);
                context.LDotH          = Vector3.Dot(lightDirection, context.H);
                context.LightColor     = lightColor;
                context.DiffuseColor   = diffuseColor;
                context.SpecularColor  = specularColor;
                context.AlphaRoughness = Math.Max(roughness * roughness, 0.001f);

                directLightingContribution += DiffuseModel.ComputeDirectLightContribution(context);
                directLightingContribution += SpecularModel.ComputeDirectLightContribution(context);
            }

            Vector3 shadingColor = Vector3.Zero;

            shadingColor += directLightingContribution * (float)Math.PI;

            output.ColorTarget = new Vector4(shadingColor, diffuseColorWithAlpha.W);

            return(output);
        }
Esempio n. 28
0
 public override string ToString()
 {
     return($@"Name: {Name}, Diffuse: {Diffuse.ToString()}");
 }
Esempio n. 29
0
    void GenerateBTv010()
    {
        BTNode f0 = new FallbackNode(unit);

        BTNode s0 = new SequenceNode(unit);

        f0.children.Add(s0);

        BTNode c0 = new IsCommandIdle(unit);

        s0.children.Add(c0);

        BTNode s1 = new SequenceNode(unit);

        s0.children.Add(s1);

        BTNode c1 = new BeingShotAt(unit);

        s1.children.Add(c1);

        BTNode f1 = new FallbackNode(unit);

        s1.children.Add(f1);

        BTNode a0 = new TakeCover(unit, emptySlot);

        f1.children.Add(a0);

        BTNode a1 = new RunToTheHills(unit);

        f1.children.Add(a1);

        BTNode s2 = new SequenceNode(unit);

        f0.children.Add(s2);

        BTNode c2 = new IsCommandHoldPosition(unit);

        s2.children.Add(c2);

        BTNode f2 = new FallbackNode(unit);

        s2.children.Add(f2);

        BTNode s3 = new SequenceNode(unit);

        f2.children.Add(s3);

        BTNode c3 = new IsEnemyNearby(unit);

        s3.children.Add(c3);

        BTNode f3 = new FallbackNode(unit);

        s3.children.Add(f3);

        BTNode a2 = new TakeCover(unit, emptySlot);

        f3.children.Add(a2);

        BTNode a3 = new PushForward(unit);

        f3.children.Add(a3);

        BTNode f4 = new FallbackNode(unit);

        f2.children.Add(f4);

        BTNode s4 = new SequenceNode(unit);

        f4.children.Add(s4);

        BTNode c4 = new AwayFromTargetLocation(unit);

        s4.children.Add(c4);

        BTNode a4 = new GoTowardsTargetLocation(unit);

        s4.children.Add(a4);

        BTNode s10 = new SequenceNode(unit);

        f4.children.Add(s10);

        BTNode a5 = new Diffuse(unit, emptySlot);

        s10.children.Add(a5);

        BTNode a10 = new MakeUnitInPosition(unit);

        s10.children.Add(a10);

        BTNode s9 = new SequenceNode(unit);

        f0.children.Add(s9);

        BTNode c9 = new IsCommandInPosition(unit);

        s9.children.Add(c9);

        BTNode s5 = new SequenceNode(unit);

        f0.children.Add(s5);

        BTNode c5 = new IsCommandMove(unit);

        s5.children.Add(c5);

        BTNode f5 = new FallbackNode(unit);

        s5.children.Add(f5);

        BTNode s6 = new SequenceNode(unit);

        f5.children.Add(s6);

        BTNode c6 = new BeingShotAt(unit);

        s6.children.Add(c6);

        BTNode f6 = new FallbackNode(unit);

        s6.children.Add(f6);

        BTNode s7 = new SequenceNode(unit);

        f6.children.Add(s7);

        BTNode c7 = new IsEnemyWeakerThanUs(unit);

        s7.children.Add(c7);

        BTNode a6 = new PushForward(unit);

        s7.children.Add(a6);

        BTNode a7 = new RunToTheHills(unit);

        f6.children.Add(a7);

        BTNode s8 = new SequenceNode(unit);

        f5.children.Add(s8);

        BTNode c8 = new NotAtTargetLocation(unit);

        s8.children.Add(c8);

        BTNode a8 = new GoTowardsTargetLocation(unit);

        s8.children.Add(a8);

        BTNode a9 = new MakeUnitIdle(unit);

        f5.children.Add(a9);

        root = f0;
    }
Esempio n. 30
0
    void GenerateMarineBTv100()
    {
        BTNode f0 = new FallbackNode(unit);

        BTNode s0 = new SequenceNode(unit);

        f0.children.Add(s0);

        BTNode c0 = new IsCommandIdle(unit);

        s0.children.Add(c0);

        BTNode c1 = new BeingShotAt(unit);

        s0.children.Add(c1);

        BTNode sf0 = new RSF0(unit);

        s0.children.Add(sf0);

        BTNode f1 = new FallbackNode(unit);

        sf0.children.Add(f1);

        BTNode a0 = new TakeCover(unit, emptySlot);

        f1.children.Add(a0);

        BTNode a1 = new Charge(unit);

        f1.children.Add(a1);

        BTNode a2 = new Charge(unit);

        sf0.children.Add(a2);

        BTNode s1 = new SequenceNode(unit);

        f0.children.Add(s1);

        BTNode c2 = new IsCommandMove(unit);

        s1.children.Add(c2);

        BTNode f2 = new FallbackNode(unit);

        s1.children.Add(f2);

        BTNode s2 = new SequenceNode(unit);

        f2.children.Add(s2);

        BTNode c3 = new BeingShotAt(unit);

        s2.children.Add(c3);

        BTNode sf1 = new CSF0(unit, 70f);

        s2.children.Add(sf1);

        BTNode a3 = new RunToTheHills(unit);

        sf1.children.Add(a3);

        BTNode f3 = new FallbackNode(unit);

        sf1.children.Add(f3);

        BTNode s3 = new SequenceNode(unit);

        f3.children.Add(s3);

        BTNode c4 = new Overwhelmed(unit);

        s3.children.Add(c4);

        BTNode f4 = new FallbackNode(unit);

        s3.children.Add(f4);

        BTNode a4 = new TakeCover(unit, emptySlot);

        f4.children.Add(a4);

        BTNode a5 = new RunToTheHills(unit);

        f4.children.Add(a5);

        BTNode a6 = new PushForward(unit);

        f3.children.Add(a6);

        BTNode s4 = new SequenceNode(unit);

        f2.children.Add(s4);

        BTNode w0 = new InverterNode(unit);

        s4.children.Add(w0);

        BTNode c5 = new AtTargetLocation(unit);

        w0.children.Add(c5);

        BTNode a7 = new GoTowardsTargetLocation(unit);

        s4.children.Add(a7);

        BTNode a8 = new MakeUnitIdle(unit);

        f2.children.Add(a8);

        BTNode s5 = new SequenceNode(unit);

        f0.children.Add(s5);

        BTNode c6 = new IsCommandHoldPosition(unit);

        s5.children.Add(c6);

        BTNode f5 = new FallbackNode(unit);

        s5.children.Add(f5);

        BTNode s6 = new SequenceNode(unit);

        f5.children.Add(s6);

        BTNode f6 = new FallbackNode(unit);

        s6.children.Add(f6);

        BTNode c7 = new BeingShotAt(unit);

        f6.children.Add(c7);

        BTNode c8 = new IsEnemyNearby(unit);

        f6.children.Add(c8);

        BTNode f7 = new FallbackNode(unit);

        s6.children.Add(f7);

        BTNode a9 = new TakeCover(unit, emptySlot);

        f7.children.Add(a9);

        BTNode a10 = new PushForward(unit);

        f7.children.Add(a10);

        BTNode s7 = new SequenceNode(unit);

        f5.children.Add(s7);

        BTNode w1 = new InverterNode(unit);

        s7.children.Add(w1);

        BTNode c9 = new AtTargetLocation(unit);

        w1.children.Add(c9);

        BTNode a11 = new GoTowardsTargetLocation(unit);

        s7.children.Add(a11);

        BTNode s8 = new SequenceNode(unit);

        f5.children.Add(s8);

        BTNode a12 = new Diffuse(unit, emptySlot);

        s8.children.Add(a12);

        BTNode a13 = new MakeUnitInPosition(unit);

        s8.children.Add(a13);

        BTNode s9 = new SequenceNode(unit);

        f0.children.Add(s9);

        BTNode c10 = new IsCommandInPosition(unit);

        s9.children.Add(c10);

        BTNode c11 = new BeingShotAt(unit);

        s9.children.Add(c11);

        BTNode sf2 = new CSF0(unit, 100f);

        s9.children.Add(sf2);

        BTNode a14 = new Charge(unit);

        sf2.children.Add(a14);

        BTNode a15 = new TakeCover(unit, emptySlot);

        s9.children.Add(a15);

        root = f0;
    }