/// <summary> /// Sets the values of this object from living /// </summary> /// <param name="living"></param> public void FillThis(LivingPlaceable living) { this.serializeNumber = living.serializeNumber; this.netId = living.netId; List <FieldInfo> livingFields = new List <FieldInfo>(); foreach (FieldInfo fieldInfo in this.GetType().GetFields()) { foreach (FieldInfo fieldLiving in living.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { if (fieldInfo.GetType() == fieldLiving.GetType() && fieldInfo.Name == fieldLiving.Name) { fieldInfo.SetValue(this, fieldLiving.GetValue(living)); break; } } } }
/// <summary> /// Fill living from values of this. Equalize any fields that have the same type and the same name /// </summary> /// <param name="living"></param> public void FillLiving(LivingPlaceable living) { living.serializeNumber = this.serializeNumber; living.netId = this.netId; //Debug.LogError(living.PlayerPosesser); List <FieldInfo> livingFields = new List <FieldInfo>( ); foreach (FieldInfo fieldInfo in this.GetType().GetFields()) { foreach (FieldInfo fieldLiving in living.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { if (fieldInfo.GetType() == fieldLiving.GetType() && fieldInfo.Name == fieldLiving.Name) { fieldLiving.SetValue(living, fieldInfo.GetValue(this)); break; } } } // Debug.LogError("at the end" +this.playerPosesser); }