public NetworkedObject(INetworkedObject obj, bool useRealName = false, bool autoCreateObject = true) { this.OriginalObject = obj; this.Fields = obj.GetType(). GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic) .Where(f => f.GetCustomAttributes(typeof(NetworkedField), true).Length > 0) .OrderBy(f => f.Name) .ToArray(); this.setActiveMethod = obj.GetType().GetMethod("LiNGSSetActive", new Type[] { typeof(bool) }); this.IsFieldSimulated = this.Fields.Select(f => (f.GetCustomAttributes(typeof(NetworkedField), true)[0] as NetworkedField).Simulated).ToArray(); this.AutoCreateObject = autoCreateObject; if (useRealName) { this.Name = LiNGSMarkers.AutoCreatedObject + obj.GetType().Name; } else { //Thread safe lock (StaticLock) { this.Name = LiNGSMarkers.AutoCreatedObject + NameId++.ToString(); } } }
public NetworkedObject(INetworkedObject obj, string name) { this.OriginalObject = obj; this.Fields = obj.GetType(). GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic) .Where(f => f.GetCustomAttributes(typeof(NetworkedField), true).Length > 0) .OrderBy(f => f.Name) .ToArray(); this.setActiveMethod = obj.GetType().GetMethod("LiNGSSetActive", new Type[] { typeof(bool) }); this.IsFieldSimulated = this.Fields.Select(f => (f.GetCustomAttributes(typeof(NetworkedField), true)[0] as NetworkedField).Simulated).ToArray(); this.AutoCreateObject = false; this.Name = name; }
public NetworkedObject(INetworkedObject obj, string name) { this.OriginalObject = obj; this.Fields = obj.GetType(). GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic) .Where(f => f.GetCustomAttributes(typeof(NetworkedField), true).Length > 0) .OrderBy(f => f.Name) .ToArray(); this.AutoCreateObject = false; this.Name = name; }