public void UpdateLife2DZone(Life2DZone life) { //the life is not running, no locks needed life._bounds = Bounds; //we only will be needed one assignment depending on the orientation (see the public life constructor) //but it doesnt hurt to assign all variables, which is shorter than a switch statement life._coords.X = Bounds.XMin; life._coords.Y = Bounds.YMin; life._coords.Z = Bounds.ZMin; life._orientation = Orient; life._normal = Normal; life._empty = Empty; life._dead = Dead; life._newborn = Newborn; life._state = RuntimeState; life._halfStepDelay = HalfStepDelay; life._delay = Delay; life._autoReset = AutoReset; life.CreatorName = CreatorName; life.MinRankToChange = MinRankToChange; life._life2d = new Life2d(Dim0, Dim1); life._life2d.SetState(To2DArray(CurrentState, Dim0, Dim1)); life._initialState = To2DArray(InitialState, Dim0, Dim1); }
public static Life2DZone Deserialize(string name, string sdata, Map map) { Life2DZone life = new Life2DZone(name, map); byte[] bdata = Convert.FromBase64String(sdata); DataContractSerializer serializer = new DataContractSerializer(typeof(SerializedData)); MemoryStream s = new MemoryStream(bdata); SerializedData data = (SerializedData)serializer.ReadObject(s); data.UpdateLife2DZone(life); return(life); }
public void Deserialize(string group, string key, string value, Map map) { try { Life2DZone life = Life2DZone.Deserialize(key, value, map); if (map.LifeZones.ContainsKey(key.ToLower())) { Logger.Log(LogType.Error, "Map loading warning: duplicate life name found: " + key + ", ignored"); return; } map.LifeZones.Add(key.ToLower(), life); } catch (Exception ex) { Logger.Log(LogType.Error, "LifeSerialization.Deserialize: Error deserializing life {0}: {1}", key, ex); } }
public SerializedData(Life2DZone life) { lock (life._life2d) { Bounds = life._bounds; Orient = life._orientation; Normal = life._normal; Empty = life._empty; Dead = life._dead; Newborn = life._newborn; RuntimeState = life._state; HalfStepDelay = life._halfStepDelay; Delay = life._delay; AutoReset = life._autoReset; CreatorName = life.CreatorName; MinRankToChange = life.MinRankToChange; CurrentState = To1DArray(life._life2d.GetArrayCopy(), out Dim0, out Dim1); InitialState = To1DArray((byte[, ])life._initialState.Clone(), out Dim0, out Dim1); } }
public Task(World w, Life2DZone life) : base(w) { _life = life; }