示例#1
0
        // save cache to speed up load times
        // we store the MetalClassVersion to enable cache rebuild if algo changed
        void SaveCache()
        {
            string MapName       = aicallback.GetMapName();
            string cachefilepath = Path.Combine(csai.CacheDirectoryPath, MapName + "_metal.xml");

            XmlDocument cachedom = XmlHelper.CreateDom();
            XmlElement  metadata = XmlHelper.AddChild(cachedom.DocumentElement, "metadata");

            metadata.SetAttribute("type", "MetalCache");
            metadata.SetAttribute("map", MapName);
            metadata.SetAttribute("version", MetalClassVersion);
            metadata.SetAttribute("datecreated", DateTime.Now.ToString());
            metadata.SetAttribute("ismetalmap", isMetalMap.ToString());
            metadata.SetAttribute("extractorradius", aicallback.GetExtractorRadius().ToString());
            metadata.SetAttribute("mapheight", aicallback.GetMapHeight().ToString());
            metadata.SetAttribute("mapwidth", aicallback.GetMapWidth().ToString());

            XmlElement metalspots = XmlHelper.AddChild(cachedom.DocumentElement, "metalspots");

            foreach (MetalSpot metalspot in MetalSpots)
            {
                XmlElement metalspotnode = XmlHelper.AddChild(metalspots, "metalspot");
                //metalspotnode.SetAttribute( "pos", metalspot.Pos.ToCsv() );
                Float3Helper.WriteFloat3ToXmlElement(metalspot.Pos, metalspotnode);
                metalspotnode.SetAttribute("amount", metalspot.Amount.ToString());
            }

            cachedom.Save(cachefilepath);
        }
示例#2
0
        // protected constructor to force Singleton instantiation
        Metal()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();
            unitcontroller = UnitController.GetInstance();

            unitdefhelp = new UnitDefHelp( aicallback );

            ExtractorRadius = aicallback.GetExtractorRadius();

            unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded );
            unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler( UnitRemoved );

            csai.RegisterVoiceCommand( "showmetalspots", new CSAI.VoiceCommandHandler( this.DrawMetalSpotsCommand ) );
        }
示例#3
0
        }       // Singleton pattern

        Metal() // protected constructor to force Singleton instantiation
        {
            csai           = CSAI.GetInstance();
            aicallback     = csai.aicallback;
            logfile        = LogFile.GetInstance();
            unitcontroller = UnitController.GetInstance();

            unitdefhelp = new UnitDefHelp(aicallback);

            ExtractorRadius = aicallback.GetExtractorRadius();

            unitcontroller.UnitAddedEvent   += new UnitController.UnitAddedHandler(UnitAdded);
            unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved);

            csai.RegisterVoiceCommand("showmetalspots", new CSAI.VoiceCommandHandler(this.DrawMetalSpotsCommand));
        }