Exemplo n.º 1
0
        //-----------------------------------------------------------------------------
        public override object save(string serializer_name, CEntity entity, CEntityDef entity_def, object param)
        {
            string db_key = entity.getEntityType() + "_" + entity.getEntityId();

            Dictionary <string, object> map_prop = entity_def.getMapPropertyValue();
            string json_map_prop = JsonConvert.SerializeObject(map_prop);

            Enyim.Caching.Memcached.Results.IStoreOperationResult ret =
                CCouchbaseClient.Instance.ExecuteStore(StoreMode.Set, db_key, json_map_prop, Couchbase.Operations.PersistTo.Zero);

            if (ret.Success)
            {
                //mLog.Info("-------- Db Begin --------");
                //mLog.Info("CEntitySerializerDb save entity to db: entity_type=" + entity.getEntityType() + " entity_id=" + entity.getEntityId());
                //mLog.Info("-------- Db End --------");
            }
            else
            {
                //mLog.Error("CEntitySerializerDb::save() error! ");
                //mLog.Error("save entity to db: entity_type=" + entity.getEntityType() + " entity_id=" + entity.getEntityId());
                //mLog.Error(ret.Message);
                //mLog.Error(json_map_prop);
            }

            return(null);
        }
Exemplo n.º 2
0
        public YmapEntityDef(YmapFile ymap, int index, ref CEntityDef def)
        {
            Ymap        = ymap;
            Index       = index;
            CEntityDef  = def;
            Scale       = new Vector3(new Vector2(CEntityDef.scaleXY), CEntityDef.scaleZ);
            Position    = CEntityDef.position;
            Orientation = new Quaternion(CEntityDef.rotation);
            if (Orientation != Quaternion.Identity)
            {
                Orientation = Quaternion.Invert(Orientation);
            }
            IsMlo = false;

            UpdateWidgetPosition();
            UpdateWidgetOrientation();
        }
Exemplo n.º 3
0
        public void BuildCEntityDefs()
        {
            //recreates the CEntityDefs array from AllEntities.
            if (AllEntities == null)
            {
                CEntityDefs = null;
                return;
            }

            int count = AllEntities.Length;

            CEntityDefs = new CEntityDef[count];
            for (int i = 0; i < count; i++)
            {
                CEntityDefs[i] = AllEntities[i].CEntityDef;
            }

            //TODO: MloInstanceDefs!
        }
Exemplo n.º 4
0
 //-----------------------------------------------------------------------------
 public override object save(string serializer_name, CEntity entity, CEntityDef entity_def, object param)
 {
     return(null);
 }
Exemplo n.º 5
0
 public override string ToString()
 {
     return(CEntityDef.ToString() + ((ChildList != null) ? (" (" + ChildList.Count.ToString() + " children) ") : " ") + CEntityDef.lodLevel.ToString());
 }
Exemplo n.º 6
0
        public static void ConvertJson(FivemJson[] jsonfiles)
        {
            if (jsonfiles == null || jsonfiles.Length <= 0)
            {
                return;
            }

            Ytyp[] ytypfiles = new Ytyp[jsonfiles.Length];
            Ymap[] ymapfiles = new Ymap[jsonfiles.Length];

            for (int i = 0; i < jsonfiles.Length; i++)
            {
                ytypfiles[i] = new Ytyp(jsonfiles[i].filename.Replace(".json", ".ytyp.xml"));
                ytypfiles[i].CMapTypes.name = jsonfiles[i].filename.Replace(".json", "");

                List <CBaseArchetypeDef> unresolved_arc = new List <CBaseArchetypeDef>();

                foreach (FivemArchetype a in jsonfiles[i].archetypes)
                {
                    CBaseArchetypeDef arc = new CBaseArchetypeDef();

                    //arc.lodDist = 0;
                    arc.flags            = 0;
                    arc.specialAttribute = 0;
                    arc.bbMin            = a.aabbMin;
                    arc.bbMax            = a.aabbMax;
                    arc.bsCentre         = a.centroid;
                    arc.bsRadius         = a.radius;
                    //arc.hdTextureDist = 0;
                    arc.name = a.archetypeName;
                    arc.textureDictionary  = a.txdName;
                    arc.clipDictionary     = null;
                    arc.drawableDictionary = null;
                    arc.physicsDictionary  = a.archetypeName;
                    arc.assetType          = assetType.ASSET_TYPE_DRAWABLE;
                    arc.assetName          = a.archetypeName;
                    arc.extensions         = null;

                    arc.lodDist       = 100 + (1.5f * arc.bsRadius);
                    arc.hdTextureDist = 0.75f * arc.lodDist;

                    if (a.archetypeName.StartsWith("0x") || a.txdName.StartsWith("0x"))
                    {
                        unresolved_arc.Add(arc);
                    }
                    else
                    {
                        ytypfiles[i].CMapTypes.archetypes.Add(arc);
                    }
                }

                ymapfiles[i] = new Ymap(jsonfiles[i].filename.Replace(".json", ".ymap.xml"));
                ymapfiles[i].CMapData.name = jsonfiles[i].filename.Replace(".json", "");

                Random            rnd            = new Random();
                List <CEntityDef> unresolved_ent = new List <CEntityDef>();

                foreach (FivemEntity e in jsonfiles[i].entities)
                {
                    CEntityDef ent = new CEntityDef();

                    ent.archetypeName = e.archetypeName;
                    ent.flags         = 0;
                    ent.guid          = (uint)rnd.Next();
                    ent.position      = e.position;
                    ent.rotation      = e.rotation;
                    ent.scaleXY       = 1;
                    ent.scaleZ        = 1;
                    ent.parentIndex   = -1;
                    ent.lodDist       = 100;
                    ent.childLodDist  = 0;
                    ent.lodLevel      = lodLevel.LODTYPES_DEPTH_ORPHANHD;
                    ent.numChildren   = 0;
                    ent.priorityLevel = priorityLevel.PRI_REQUIRED;
                    ent.extensions    = null;
                    ent.ambientOcclusionMultiplier = 255;
                    ent.artificialAmbientOcclusion = 255;
                    ent.tintValue = 0;

                    if (e.archetypeName.StartsWith("0x"))
                    {
                        unresolved_ent.Add(ent);
                    }
                    else
                    {
                        ymapfiles[i].CMapData.entities.Add(ent);
                    }
                }

                ymapfiles[i].UpdatelodDist(ytypfiles[i].CMapTypes.archetypes);
                ymapfiles[i].UpdateExtents(ytypfiles[i].CMapTypes.archetypes);

                ytypfiles[i].WriteXML().Save(ytypfiles[i].filename);
                Console.WriteLine("Saved " + ytypfiles[i].filename);
                ymapfiles[i].WriteXML().Save(ymapfiles[i].filename);
                Console.WriteLine("Saved " + ymapfiles[i].filename);

                if (unresolved_arc?.Any() ?? false)
                {
                    string unresolvedname = ytypfiles[i].CMapTypes.name + "_unresolved";
                    ytypfiles[i].CMapTypes.archetypes = unresolved_arc;
                    ytypfiles[i].CMapTypes.name       = unresolvedname;
                    ytypfiles[i].WriteXML().Save(unresolvedname + ".ymap.xml");
                    Console.WriteLine("Saved " + unresolvedname + ".ymap.xml");
                }

                if (unresolved_ent?.Any() ?? false)
                {
                    string unresolvedname = ymapfiles[i].CMapData.name + "_unresolved";
                    ymapfiles[i].CMapData.entities = unresolved_ent;
                    ymapfiles[i].CMapData.name     = unresolvedname;
                    ymapfiles[i].WriteXML().Save(unresolvedname + ".ymap.xml");
                    Console.WriteLine("Saved " + unresolvedname + ".ymap.xml");
                }
            }
        }