public static void OnPropertyChanged(Entity entity, string propertyName, byte[] valueBytes) { var type = entity.GetType(); Entity component = null; if (EntityDefine.IsComponent(type)) { component = entity; entity = entity.GetParent <Entity>(); } var entityTypeId = EntityDefine.GetTypeId(entity.GetType()); //if (component != null) //{ //} //if (!EntityDefine.PropertyDefineCollectionMap.ContainsKey(entityTypeId)) //{ // Log.Error($"EntityDefine.PropertyDefineCollectionMap has no key {entityTypeId}"); // return; //} //if (!EntityDefine.PropertyDefineCollectionMap[entityTypeId].ContainsKey(propertyName)) //{ // Log.Error($"EntityDefine.PropertyDefineCollectionMap[{entityTypeId}] has no key {propertyName}"); // return; //} var msg = new M2C_OnEntityChanged(); PropertyDefineAttribute attr; if (component != null) { msg.ComponentType = EntityDefine.GetTypeId(component.GetType()); attr = EntityDefine.PropertyDefineCollectionMap[msg.ComponentType][propertyName]; } else { attr = EntityDefine.PropertyDefineCollectionMap[entityTypeId][propertyName]; } msg.EntityId = entity.Id; msg.EntityType = entityTypeId; msg.PropertyId = attr.Id; msg.PropertyValue.bytes = valueBytes; Log.Error($"MessageHelper OnPropertyChanged {type} {propertyName} flag={attr.Flag} "); if (attr.Flag == SyncFlag.AllClients) { Broadcast(entity.Domain, msg); } if (attr.Flag == SyncFlag.OtherClients) { if (entity is Unit u) { BroadcastToOther(u, msg); } } if (attr.Flag == SyncFlag.OwnClient) { if (entity is Unit u) { Send(u, msg); } } }