public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime) { if (type == ServerNetObject.ENTITY_POSITION) { ClientReadPosition(type, msg, sendingTime); return; } NetEntityEvent.Type eventType = (NetEntityEvent.Type)msg.ReadRangedInteger(0, Enum.GetValues(typeof(NetEntityEvent.Type)).Length - 1); switch (eventType) { case NetEntityEvent.Type.ComponentState: { int componentIndex = msg.ReadRangedInteger(0, components.Count - 1); (components[componentIndex] as IServerSerializable).ClientRead(type, msg, sendingTime); } break; case NetEntityEvent.Type.InventoryState: { int containerIndex = msg.ReadRangedInteger(0, components.Count - 1); (components[containerIndex] as ItemContainer).Inventory.ClientRead(type, msg, sendingTime); } break; case NetEntityEvent.Type.Status: float prevCondition = condition; condition = msg.ReadSingle(); if (prevCondition > 0.0f && condition <= 0.0f) { ApplyStatusEffects(ActionType.OnBroken, 1.0f); foreach (ItemComponent ic in components) { ic.PlaySound(ActionType.OnBroken, WorldPosition); } } break; case NetEntityEvent.Type.ApplyStatusEffect: { ActionType actionType = (ActionType)msg.ReadRangedInteger(0, Enum.GetValues(typeof(ActionType)).Length - 1); byte componentIndex = msg.ReadByte(); ushort targetID = msg.ReadUInt16(); byte targetLimbID = msg.ReadByte(); ItemComponent targetComponent = componentIndex < components.Count ? components[componentIndex] : null; Character target = FindEntityByID(targetID) as Character; Limb targetLimb = target != null && targetLimbID < target.AnimController.Limbs.Length ? target.AnimController.Limbs[targetLimbID] : null; if (targetComponent == null) { ApplyStatusEffects(actionType, 1.0f, target, targetLimb, true); } else { targetComponent.ApplyStatusEffects(actionType, 1.0f, target, targetLimb); } } break; case NetEntityEvent.Type.ChangeProperty: ReadPropertyChange(msg, false); break; case NetEntityEvent.Type.Invalid: break; } }